Our goal was to make an kitchen Internet radio player where we could change the volume and stations without touching the player. For this project we used:
- Raspberry Pi 3 (or 2 with a Wifi dongle)
- Pimoroni SkyWriter (~$20US)
- USB powered portable speaker
The Pimoroni SkyWriter supports both gesture and touch control.
To install the Pimoroni SkyWriter python libraries:
curl -sS get.pimoroni.com/skywriter | bash
For the internet music interface we used the mpd , Music Player Daemon, it can be installed by:
sudo apt-get install mpd mpc
The SkyWriter can be wrapped in plastic wrap and the gestures can still be picked up. For a more robust project it would probably be best to design a more waterproof enclosure.
A few years ago we found that the mpc calls were bullet-proof, but when we did this project we found that the mpd service would often lock up if a new internet radio station was selected (mpc next). For this reason we used external calls to adjust the volume and we restarted the mpd service when we changed radio stations
We used a gesture of up/down to adjust the volume, and a left/right to change the station.
Below is our final code:
#!/usr/bin/env python import skywriter import signal import os thevolume = 70 #starting volume thestation = 1 #starting station # Some internet radio stations stations = (('http://126.96.36.199:11029','1.FM Amsterdam Trance Radio'), ('http://www.partyviberadio.com:8000','Raggae Roots'), ('http://188.8.131.52:7136','Comedy 104'), ('http://eu.radioboss.fm:8121','Yoga'), ('http://184.108.40.206:11269','Baroque')) def setvolume(voldif): global thevolume if (thevolume + voldif >= 0) and (thevolume + voldif 0) and (direction + thestation <= len(stations))): thestation = thestation + direction os.system('mpc clear') os.system('sudo service mpd restart') os.system('mpc add ' + stations[thestation] ) os.system('mpc play') print thestation, stations[thestation], stations[thestation] @skywriter.flick() def flick(start,finish): print('Got a flick!', start, finish) if (finish == 'north'): setvolume(5) if (finish == 'south'): setvolume(-5) if (finish == 'west'): newstation(-1) if (finish == 'east'): newstation(1) # start playing the radio at defaults setvolume(0) newstation(0) signal.pause() # wait for a new gesture