I have a 256 meg raspberry pi in a laser cut case with an RGB Negative 2x16 LCD Pi Plate on it... with a wifi dongle, power, and connected to a Bose Soundock II
i use the buttons on the Pi to turn the radio on, off, and to check current station. I also use left and right to "tune in" one of the internet radio stations
it was very easy, based on the LCDtest.py code, and code from Meistervision on youtube who has an awesome 1 hour tutorial on how to build a great internet radio...
i used chron to start up the code below when i turn this pi on
you will have to install the MPD MPC apps... check out Meistervision on youtube: http://www.youtube.com/watch?v=KM4n2OtwGl0
in any case here is my code based on both
- Code: Select all
#!/usr/bin/python
from time import sleep
from Adafruit_I2C import Adafruit_I2C
from Adafruit_MCP230xx import Adafruit_MCP230XX
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import smbus
import os
# initialize the LCD plate
# use busnum = 0 for raspi version 1 (256MB) and busnum = 1 for version 2
lcd = Adafruit_CharLCDPlate(busnum = 0)
# clear and initialize purple display
lcd.clear()
lcd.backlight(lcd.VIOLET)
lcd.message("Internet Radio\nStarting")
os.system("mpc stop")
sleep(1)
while 1:
while 1:
if (lcd.buttonPressed(lcd.DOWN)):
lcd.clear()
lcd.message("Radio Off")
os.system("mpc stop")
sleep(1)
lcd.backlight(lcd.OFF)
break
if (lcd.buttonPressed(lcd.UP)):
lcd.clear()
lcd.backlight(lcd.VIOLET)
lcd.message("Radio On")
os.system("mpc play 1")
sleep(1)
lcd.backlight(lcd.OFF)
break
if (lcd.buttonPressed(lcd.LEFT)):
lcd.clear()
lcd.backlight(lcd.VIOLET)
lcd.message("Previous Station")
os.system("mpc prev")
#sleep(1)
lcd.backlight(lcd.OFF)
break
if (lcd.buttonPressed(lcd.RIGHT)):
lcd.clear()
lcd.backlight(lcd.VIOLET)
lcd.message("Next Station")
os.system("mpc next")
#sleep(1)
lcd.backlight(lcd.OFF)
break
f=os.popen("mpc current")
station = ""
for i in f.readlines():
station += i
# Send some text
lcd.clear()
lcd.backlight(lcd.VIOLET)
lcd.message(station)
sleep(5)
lcd.backlight(lcd.OFF)
sleep(5)
{attachment=0]PIRadio.jpg[/attachment]

