RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    RETROFLAG NESPI 4 IMPROVED SHUTDOWN SCRIPT

    Scheduled Pinned Locked Moved Help and Support
    multiswitch.shpi 4shutdown switch
    4 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Codafire
      last edited by Codafire

      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?

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        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 ?

        C 1 Reply Last reply Reply Quote 0
        • C
          Codafire @mitu
          last edited by

          @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 😟

          C 1 Reply Last reply Reply Quote 0
          • C
            Codafire @Codafire
            last edited by Codafire

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            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.