Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Add a shutdown button

    GamePad/GPIO/USB encoder
    button
    3
    4
    1819
    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.
    • webodan
      webodan last edited by webodan

      Hello,

      I want to add a shutdown button to my recalbox, and I'm using a device that takes the pins that this tutorial uses. I decided on using PIN 13 (GPIO27) instead of PIN 5 because it's unpopulated.

      At the moment I'm trying to modify the code used by the recalbox script to accomplish the same functionality as when using pins 5 and 6 but I can't get it to work. I changed all the mentions to PIN GPIO3 with GPIO27 (lines that had (3, GPIOwhatever) changed to 27,GPIOwhatever) but it still doesn't run. Is there anything else I have to change to get this to work properly? I tried making my own script but it was shutting down way too slow (it even stopped waiting for some reason instead of fully shutting down immediately) so I'd like to have the same behavior as the recalbox script has, by using my own pin.

      Thanks.

      supernature2k 1 Reply Last reply Reply Quote 0
      • supernature2k
        supernature2k @webodan last edited by

        @webodan WHich script are you using/modifying?

        Pi powered NES | Gameboy HD | RecalStation | RecalDrive
        Upvote messages if it has been useful ;)

        1 Reply Last reply Reply Quote 0
        • webodan
          webodan last edited by webodan

          Hello @supernature2k,

          I've modded /recalbox/scripts/rpi-pin56-power.py leaving it like this:


          import RPi.GPIO as GPIO
          import os

          GPIO.setmode(GPIO.BCM)

          GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)

          def shutdown():
          os.system("shutdown -h now")

          GPIO.wait_for_edge(27, GPIO.FALLING)
          shutdown()


          It does work, but I have to push the button twice so it shuts down fully, if possible i'd like it to close the emulator and shut down fully in one press.

          Thanks in advance.

          edit: i've attempted removing GPIO.wait_for_edge(27, GPIO.FALLING) it did shutdown properly in the first try, but after rebooting back to the library it keeps shutting down automatically so that's not what i want

          1 Reply Last reply Reply Quote 0
          • Andrei
            Andrei last edited by

            Did you manage to make it work? I am looking for the same thing, to change from gpio3 (5) to any other.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Want to support us ?

            80
            Online

            98.9k
            Users

            28.1k
            Topics

            187.1k
            Posts

            Copyright © 2021 recalbox.com