0

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:

Kintaro super kuma 9000 front

Kintaro super kuma 9000 back

  • 1
    I'd guess the busy loop makes it unresponsive as you will be using 100% CPU. Perhaps change while/pass to while/sleep(1). – joan Mar 2 '20 at 17:41
  • @joan Thanks for the reply. That's what I had originally, but I thought it didn't do anything, so I removed it in place of pass. Unfortunately, the pi is still unresponsive to GPIO inputs, even with sleep(x) – Elrond Supports Monica Mar 2 '20 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.