Created
February 8, 2017 08:07
-
-
Save DjLeChuck/445ce3d37f41f12d5bf8cb9482db4027 to your computer and use it in GitHub Desktop.
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
Replace clock() by process_time() in both instances in the script.
time.clock has been deprecated