XBMC: Difference between revisions
→OSMC Shutdown Button
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)
#
▲def Shutdown(channel):
▲ os.system("poweroff")
▲# 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>
|