{SOLVED} How to make a momentary push button that exit games and take me back to game menu ?
-
@O-M-A-A You misunderstood the instructions - maybe I wasn't so clear.
You already have a script - the one your posted. Modify it and add the code I posted. In addition to the new script you have, download and put themulti_switch.sh
script, which you can get from https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh, into the/home/pi/scripts
folder, then make it executable (chmod +x /home/pi/scripts/multi_switch.sh
).
Run your original script (now modified) and see if you get the desired behavior. -
@O-M-A-A This does not make sense
Please use command
wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh -O /home/pi/scripts/multi_switch.sh
and then again
chmod +x /home/pi/scripts/multi_switch.sh
-
@mitu thank you very much for your response,
I will try it now, and I hope I get it now -
Is this what u guys meant ?
shutdown.py contains the modified script, while I downloaded the multi_switch.sh and drop it this destination, then I executed this command (chmod +x /home/pi/scripts/multi_switch.sh)., the power button is working but not the exit emu button.
I hope this is what u guys meant !! -
@O-M-A-A said in How to make a momentary push button that exit games and take me back to game menu ?:
I hope this is what u guys meant !!
Not really:
Run your original script (now modified) and see if you get the desired behavior.
You need to run
shutdown.py
, not the other way around. -
@mitu
the original script's name is shutdown.py, I did modified it, or what did u mean ? -
-
@cyperghost just copied it and paste it ;D
-
Can you take a picture of how the buttons are wired ?
-
@O-M-A-A How do you start the script? How do you start the shutdown.py script?
-
This post is deleted! -
@cyperghost @mitu
sry for the delay, I was having some error when replaying to u guys.I actually found a command, when I just executed it, it made the shutdown.py script and power button works immediately.
this is the command:
-
Why are you posting an image of a text, instead of posting the text ? It makes it harder to copy it and verify the URL/file. We know now how the script looks like, the issue is why the 2nd button doesn't work - can you show us how you wired the buttons to the PI ?
-
@mitu I received error when posting it as it marked as a spam, give me seconds
-
@O-M-A-A The link to the script is not so important now.
-
-
the white and grey wires are for the power button, while the brown and red are for the exit emu button
-
@O-M-A-A I don't think the brown/red are tied to GPIO 7.
Modify the script and change 2nd buttons's pin number from 7 to 33 and see if you get a different result:
#!/usr/bin/python import RPi.GPIO as GPIO import time import subprocess GPIO.setmode(GPIO.BOARD) # we will use the pin numbering to match the pins on the Pi, instead of the # GPIO pin outs (makes it easier to keep track of things) # use the same pin that is used for the reset button (one button to rule them all!) GPIO.setup(5, GPIO.IN) GPIO.setup(33, GPIO.IN) oldButtonState1 = True oldButtonState2 = True while True: #grab the current button state buttonState1 = GPIO.input(5) buttonState2 = GPIO.input(33) # check to see if button has been pushed if buttonState1 != oldButtonState1 and buttonState1 == False: # shutdown subprocess.call("shutdown -h now", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) oldButtonState1 = buttonState1 if buttonState2 != oldButtonState2 and buttonState2 == False: # Reset emulator subprocess.call("/home/pi/scripts/multi_switch.sh --es-closeemu", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) oldButtonState2 = buttonState2
-
@mitu didn't work,
would it be fine if u get access to my computed and try it yourself as maybe the way I'm doing it is wrong. -
@O-M-A-A said in How to make a momentary push button that exit games and take me back to game menu ?:
would it be fine if u get access to my computed and try it yourself as maybe the way I'm doing it is wrong.
Can't do that, I'm sorry.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.