Homepage › Forums › RetroPie Project › Everything else related to the RetroPie Project › Exit emulators via gpio signal?
- This topic has 5 replies, 4 voices, and was last updated 10 years ago by
brunchero.
-
AuthorPosts
-
10/07/2014 at 11:22 #81579
ronan
ParticipantHi,
I’m mounting a retropie based game station in an old NES case, and I’d like to use the nes reset switch to exit the current game and return to emulationstation.
Is there any way to send this kind signal to emulationstation via a python script? I already have a script running for the mausberry shutdown circuit, if possible it would be great to have this on the same script.
I use usb controllers, so I don’t need a full gpio/controller mapping; I just need to simulate an escape key press, or send directly a signal to emulationstation or the current running emulator to exit.
10/09/2014 at 09:44 #81624ronan
ParticipantSo I tried to simulate an ESC key press with python-uinput, and while it works the emulators doesn’t react.
So I found a simpler way: I look at all the running processes, and if I find one with a command path starting with “/opt/retropie/emulators/” I send it a “kill -INT [pid]”.
Not really future-proof if the emulators path change, but good enough.
10/23/2014 at 16:51 #81962ronan
ParticipantMy script is on github, feel free to use it or suggest improvements: https://github.com/RonanL/retropie-mausberry-switch/blob/master/python/nespi.py
10/23/2014 at 17:04 #81963imnew
ParticipantI’m yet to receive a response on this site – can someone reply to this please as I’m not sure whether theres some bat shit invisible mode on or something.
thanks
12/11/2014 at 08:13 #83495tool212
ParticipantThis is what I want mine to do. I am Working on one for a Xmas gift and I am 99% complete. Everything works including the power button on the NES. I am stuck on the shutdown I have everything soldered to the mausberry switch and I am using gpio 23 and gpio 24. on boot up i can see error erc/switch.sh line9, line 11 echo write error device not responding or busy.
In your code it appears you are using 23 24 and 25. could you send me a pic or diagram on how you have it wired.
Thanks04/11/2015 at 20:09 #94577brunchero
ParticipantThanks Ronan, your script was the code I needed for my Retro RPi2!
I adjusted it to fit my GPIO stuff with some LEDs added, and attached my version in case anyone is interested. (I use the retropi 2.6 image.)
My changes:
– made it a very basic python daemon, so I could add it to init-scripts
– use BCM GPIO 3 for shutdown, since it also can startup the rpi when pulled low
– for that reason, use FALLING interrupts
– use SIG TERM for emulator, to allow clean exit (save srm?), wait 5 seconds and then send SIG KILL to the process in case TERM did not help
– added LED when nespi.py daemon is running
– added LED when emulator is running, check every secondTo simplify the emulator LED, I hacked runcommand.sh to write its own PID into a temp file on start, and remove it on script end.
I also wanted my own ACT LED for sd card activity, which, as turned out, is super easy using the device tree overlay in config.txt.
dtoverlay=act_led_gpio=22
-
AuthorPosts
- The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.