RETROFLAG NESPI 4 IMPROVED SHUTDOWN SCRIPT
-
Hi mates, i used before an improved shutdown script for the retroflag cases in raspberry pi 3, the script change SafeShutdown.py and leaves it like that:
#!/usr/bin/env python3 from gpiozero import Button, LED import os from signal import pause import subprocess powerPin = 3 resetPin = 2 ledPin = 14 powerenPin = 4 hold = 1 led = LED(ledPin) led.on() power = LED(powerenPin) power.on() #functions that handle button events def when_pressed(): led.blink(.2,.2) output = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--es-pid'])) if output: os.system("/opt/RetroFlag/multi_switch.sh --es-poweroff") else: os.system("sudo shutdown -h now") def when_released(): led.on() def reboot(): output = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--es-pid'])) output_rc = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--rc-pid'])) if output_rc: os.system("/opt/RetroFlag/multi_switch.sh --closeemu") elif output: os.system("/opt/RetroFlag/multi_switch.sh --es-restart") else: os.system("sudo reboot") btn = Button(powerPin, hold_time=hold) rebootBtn = Button(resetPin) rebootBtn.when_pressed = reboot btn.when_pressed = when_pressed btn.when_released = when_released pause()
and it uses the multi_swith.sh script to make a more elegant shutdown and reset, you can see it here:
https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh
I dont know why in Pi 4 is not working, i installed it and changed the SafeShutdown.py whith the code sayed before but not working. Any idea?
-
Use code blocks for fencing the script code - see https://www.markdownguide.org/extended-syntax/#fenced-code-blocks.
Maybe the pin numbers are different on the NesPi4 - is the script supposed to work on it. What exactly is not working ? -
@mitu thanks for the codeblocks sugerence i never ear about it.
In raspberry 3 retroflag cases if you use default script if you push power button it shutdown the pi and reset button reboot it.
With this code the power button, shutdown the pi saving changes and the reset button restart only emulationstation if you are in main menu, or exit game if you are in a game.I checked pins and are the same but i dont know why in pi4 you push the button and the pi do nothing 😟
-
This post is deleted!
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.