I am working on a custom startup script for the Kintaro super kuma 9000
(link is down ATM) case for my raspberry pi 3B+
Here is the minimal example:
import RPi.GPIO as GPIO
import os
import time
LED_PIN = 7
POWER_PIN = 5
def led(status):
if status:
GPIO.output(LED_PIN, GPIO.HIGH)
else:
GPIO.output(LED_PIN, GPIO.LOW)
def power_interrupt(channel):
if GPIO.input(POWER_PIN) == GPIO.HIGH:
print("power off\n")
led(0)
# os.system('killall emulationstation')
else:
print('power on\n')
led(1)
# os.system('emulationstation')
if __name__ == '__main__':
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_PIN, GPIO.OUT)
GPIO.setup(POWER_PIN, GPIO.IN)
GPIO.add_event_detect(POWER_PIN, GPIO.RISING, callback=power_interrupt)
while True: time.sleep(5)
The script works fine as is, but if I uncomment the commands that start/stop EmulationStation
, the script is no longer responsive to GPIO inputs.
Why does emulationstation block the GPIO event loop? And how can I keep it from blocking?
For clarity's sake, here is what the Kintaro board looks like:
pass
. Unfortunately, the pi is still unresponsive to GPIO inputs, even withsleep(x)
– Elrond Supports Monica Mar 2 '20 at 21:55