Voici le script en question:
this:
import RPi.GPIO as GPIO
import time
import os
import thread
import datetime
import socket
import sys
import argpa**e
from datetime import datetime
from configgen import recalboxFiles
this last one retrieves emulators bin names
NUMGPIO = 3
GPIO.setwarnings(False) # no warnings
GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
GPIO.setup(NUMGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO on pin 3 is the GPIO 2 in BCM mode
#to button
Define a threaded callback function to run in another thread when events are detected
def button_pressed(channel):
| timer = 0 |
| flag = True |
| while flag: |
| if GPIO.input(channel) == False: |
| timer += 1 |
| elif GPIO.input(channel) == True: |
| |
| |
| |
| |
| |
| if (timer >1): |
| |
| killthats**t(channel) |
| |
| timer = 0 |
| flag = False |
| time.sleep(0.1) |
on power short press, trying to kill all listed emus
def killthats**t(channel):
if channel == NUMGPIO:
for bin in recalboxFiles.recalboxBins:
print bin
proc = os.path.basename(bin)
print proc
os.system("killall -9 "+proc)
GPIO.add_event_detect(NUMGPIO, GPIO.BOTH, callback=button_pressed, bouncetime=2)
while True:
time.sleep(0.2)
Pi powered NES | Gameboy HD | RecalStation | RecalDrive
Upvote messages if it has been useful 
0