Kodi Community Forum
newbie with Raspberry Pi - hardware button on gpio - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: newbie with Raspberry Pi - hardware button on gpio (/showthread.php?tid=180340)



newbie with Raspberry Pi - hardware button on gpio - tobbes - 2013-12-13

Hello experts,

I am a little frustrated with my Pi.
I want to set a music box (most time headless) with my Pi running RASPBMC (Frodo 12.2).
A little 16x2 LCD connected by LCDproc shows the important info.

Now I want to choose a radio stream with buttons connected to gpio. The Pi is playing the first entry in a playlist started at boot time (confluence skin) and it would be nice if I could implement a up, a down and a enter button to choose an other entry in the list.

I tried xbmc-command (https://github.com/mychris/xbmc-command) but there I could only take the "next" command which means that I must wait 10seconds for the Pi to start and show the next stream.

Buttons are working. If I hit a button I can see "button is pressed".
Code:
#!/usr/bin/env python
from time import sleep
import os
import RPi.GPIO as GPIO
import xbmc
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
GPIO.setup(22, GPIO.IN)
GPIO.setup(2, GPIO.IN)
while True:
if ( GPIO.input(17) == False ):
os.system('xbmc-command play-pause')
# print('17 gedrueckt')
if ( GPIO.input(22) == False ):
os.system('xbmc-command next')
# print('22 gedrueckt')
if ( GPIO.input(2)== False ):
# os.system('xbmc-command play-pause')
print('2 gedrueckt')
How could I get up, down and enter buttons running.
Thanks for helping a noob ...

Tobbes


RE: newbie with Raspberry Pi - hardware button on gpio - el_Paraguayo - 2013-12-13

Have you seen this thread: http://forum.xbmc.org/showthread.php?tid=154211&highlight=gpio