Created
January 27, 2013 17:13
-
-
Save pocketkk/4649274 to your computer and use it in GitHub Desktop.
Pianobar Raspberry PI LCD CTL file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# REMOTE CONTROL | |
# pianobar can be controlled through a fifo. You have to create it | |
# yourself by executing | |
# mkfifo ~/.config/pianobar/ctl | |
# Adjust the path if you set up a $XDG_CONFIG_HOME. Afterwards you can | |
# write commands directly into the fifo. Example (next song): | |
# echo -n 'n' > ~/.config/pianobar/ctl | |
# n is the keybinding for "next song". If you customized your keybindings | |
# you have to use these characters to control pianobar. This behaviour | |
# may change in the future! | |
# Another example: | |
# while true; do; | |
# nc -l -p 12345 -s localhost localhost > ~/.config/pianobar/ctl; | |
# sleep 1; | |
# done | |
# echo -ne 'n\x1a' | nc -q 0 127.0.0.1 12345 | |
# EVENTCMD | |
# pianobar can report certain "events" to an external application (see | |
# CONFIGURATION ). This application is started with the event name as | |
# it's first argument. More information (artist, title, album, | |
# stationName, error code, error description, song length in | |
# milliseconds, rating) is supplied through stdin. | |
# Currently supported events are: artistbookmark, songban, songbookmark, | |
# songexplain, songfinish, songlove, songmove, songshelf, songstart, | |
# stationaddmusic, stationaddshared, stationcreate, stationdelete, | |
# stationfetchplaylist, stationquickmixtoggle, stationrename | |
# An example script can be found in the contrib/ directory of pianobar's | |
# source distribution. | |
# | |
# su USER -c 'command &' | |
require "/home/pi/projects/lcd/lcd" | |
require "/home/pi/projects/light" | |
light = Light.new | |
GREEN=" 0x00 0xff 0x00 " | |
BLUE=" 0x00 0x00 0xff " | |
RED=" 0xff 0x00 0x00 " | |
WHITE=" 0Xff 0xff 0xff " | |
def return_color(hex) | |
hex_array=hex.scan(/../) | |
color_string="" | |
hex_array.each do |hex| | |
puts hex | |
dd=hex.to_i(16).to_s(16) | |
color_string << " 0x" << dd << " " | |
puts color_string | |
end | |
return color_string | |
end | |
event = ARGV.first | |
lcd = Display.new("/dev/ttyAMA0", 9600) | |
if event == 'songstart' | |
light.color(BLUE) | |
d = {} | |
lcd.clear | |
STDIN.each_line { |line| d.store(*line.chomp.split('=', 2)) } | |
title=d['title'] | |
artist=d['artist'] | |
lcd.print(title, 1) | |
lcd.print(artist,2) | |
end | |
if event == 'songlove' | |
light.color(GREEN) | |
d={} | |
STDIN.each_line { |line| d.store(*line.chomp.split('=', 2)) } | |
title=d['title'] | |
artist=d['artist'] | |
lcd.clear_line(3) | |
lcd.print("Loving..." << title, 3) | |
sleep(5) | |
lcd.clear_line(3) | |
light.color(BLUE) | |
end | |
if event == 'songban' | |
light.color(RED) | |
d={} | |
STDIN.each_line { |line| d.store(*line.chomp.split('=', 2)) } | |
title=d['title'] | |
artist=d['artist'] | |
lcd.clear_line(3) | |
lcd.scroll("Banning..." << title, 3) | |
sleep(5) | |
lcd.clear_line(3) | |
light.color(BLUE) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment