Skip to content

Instantly share code, notes, and snippets.

@DjLeChuck
Created February 8, 2017 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DjLeChuck/445ce3d37f41f12d5bf8cb9482db4027 to your computer and use it in GitHub Desktop.
Save DjLeChuck/445ce3d37f41f12d5bf8cb9482db4027 to your computer and use it in GitHub Desktop.
rpi-exit-emu-1b.py
#!/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()
@melpheos
Copy link

melpheos commented Sep 3, 2023

Replace clock() by process_time() in both instances in the script.
time.clock has been deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment