XBMC: Difference between revisions

30 bytes removed ,  4 years ago
Line 192:
 
<syntaxhighlight lang="python">
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os
import sys
Line 200:
sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")
 
# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode.
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
# Add ourOur function on what to executedo when the button is pressed event happens
def Shutdown(channel):
os.system("poweroff")
# OurAdd our function on what to doexecute when the button is pressed event happens
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
def Shutdown(channel):
 
os.system("poweroff")
# Now wait!
while 1:
# Add our function to execute when the button pressed event happens
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
# Now wait!
while 1:
time.sleep(1)
</syntaxhighlight>