rpi-exit-emu-1b.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#Import libs | |
import RPi.GPIO as GPIO | |
import os | |
import time | |
#Set Environment | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setwarnings(False) | |
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
#Code | |
try: | |
while True: | |
GPIO.wait_for_edge(10, GPIO.FALLING) | |
pressedat = time.clock() | |
while GPIO.input(10) == GPIO.LOW: | |
releasedat = time.clock() | |
if (releasedat - pressedat) >= 0.500: | |
os.system("killall -9 retroarch mupen64plus fba2x scummvm &> /dev/null") | |
#Reset Control Vars | |
releasedat = pressedat = 0 | |
#Cleaning Gpio ports on Error or Exit | |
finally: | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment