Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Built an awesome internet Radio with 2x16 RGB LCD Pi Plate :)

by waltermixxx on Mon Mar 04, 2013 8:25 pm

i bought three 256meg raspberry Pi's when they first came out... not sure why, but now I know.... ( i have since purchased 1 512 meg pi :)... in any case, with so many of them it would make it easy to dedicate one or two for some real live projects ( and not bread board projects... ) in any case, I digress....

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 :) Thanks Adafruit for a store i would have loved to have as a child... (you kids are spoiled :) )

Code: Select all | TOGGLE FULL SIZE
#!/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]
Attachments
PIRadio.jpg
Pi Internet Radio :) Party On....(and on)
PIRadio.jpg (149.58 KiB) Viewed 1110 times
Last edited by waltermixxx on Mon Mar 04, 2013 8:54 pm, edited 1 time in total.
waltermixxx
 
Posts: 16
Joined: Sat Apr 10, 2010 1:36 am

Re: Built an awesome internet Radio with 2x16 RGB LCD Pi Plate :)

by waltermixxx on Mon Mar 04, 2013 8:39 pm

I did want to note that the portion of the code that prints the station and the song title needs work, originally designed to work on a 4x20 lcd. :)
i was too excited to mess around with getting the text to appear correctly ( Underground 80's new wave... !!!)
this is the bit here:

Code: Select all | TOGGLE FULL SIZE
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)


if anyone could help with getting it to appear properly on a 16x2 negative rgb backlit display via I2C i would be greatful... i image a some kind of loop that counts to 16 then adds a /n then continues?
:) any help would be appreciated :) I'm very new to python and this is my very first attempt and most of this code was borrowed and cobled together :)
waltermixxx
 
Posts: 16
Joined: Sat Apr 10, 2010 1:36 am

Re: Built an awesome internet Radio with 2x16 RGB LCD Pi Plate :)

by adafruit_support_bill on Tue Mar 05, 2013 5:43 am

Nice project! Thanks for posting. :D
User avatar
adafruit_support_bill
 
Posts: 28220
Joined: Sat Feb 07, 2009 9:11 am