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

    Powering off via UI while using a Mausberry Circuit

    Scheduled Pinned Locked Moved Help and Support
    mausberrypower offcircuitmenuled
    72 Posts 4 Posters 18.0k 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.
    • caver01C
      caver01
      last edited by

      @meleu that didn't work. So, I reverted emulationstation.sh back to default, then followed your instructions to create the service, setup the killes.sh in /home/pi/bin

      As far as I know, it saves the metadata, but what it doesn't do is trigger the mausberry circuit.

      I switched back to my original pyton script for the circuit. Then I added these lines at the beginning of killes.sh:

      #this is the GPIOpin connected to the 1k-ohm resistor, leading to the base of NPN transistor (emitter and collector to power switch poles)
      GPIOpin=18
      
      # Export the GPIOpin and and set direction
      echo "$GPIOpin" > /sys/class/gpio/export
      echo "out" > /sys/class/gpio/gpio$GPIOpin/direction
      # Trigger the transistor on GPIOpin to short the mausberry switch
      echo "1" > /sys/class/gpio/gpio$GPIOpin/value
      

      I need to export the pin used for the transistor because I am not using the BASH script, and nothing in the Python script uses the transistor. Even if I did define the transistor pin in the python script, I would still need to export it here (or somewhere) because python interacts with GPIO differently than BASH and does not need the pins exported to user space.

      As a test, I can still drop to command prompt and enter the echo commands above manually and it will trigger the circuit and power down, so it should be possible.

      I am not certain that shutdown is even invoking the killes.sh.

      My 4-player cocktail style cabinet built as a custom "roadcase"

      1 Reply Last reply Reply Quote 0
      • caver01C
        caver01
        last edited by

        I though of another problem incorporating the Mausberry trigger—reboots will become shutdowns. That’s not the end of the world, but worth mentioning.

        My 4-player cocktail style cabinet built as a custom "roadcase"

        1 Reply Last reply Reply Quote 0
        • caver01C
          caver01 @meleu
          last edited by

          @meleu Ok, so I think I know why your solution did not work for my case. I hadn't flagged my killes.sh as executable. I am hoping that resolves the problem (I was inadvertently NOT watching the other thread when you added that step.) I am not at home to try it, but I did the CHMOD remotely and I am anxious to test it. If my addition to the killes.sh triggers my mausberry circuit to turn off, we have a great solution. This would simplify mine and many other 3rd party shutdown needs as handling the metadata issues safely. It's a smart idea.

          One bit of fallout I mentioned above with my change is that every restart would trigger my mausberry to cut power. I would lose the reboot ability, but this is a worth sacrifice for simplifying everything else in my opinion.

          Also, I plan to drop the use of the mausberry script completely--I am shifting to my GPIO inputs solution--GPIOnext--to handle the shutdown trigger. I will connect the mauseberry's input wire to a 3.3v GPIO rail.

          My 4-player cocktail style cabinet built as a custom "roadcase"

          meleuM 1 Reply Last reply Reply Quote 0
          • meleuM
            meleu @caver01
            last edited by meleu

            @caver01 said in Powering off via UI while using a Mausberry Circuit:

            every restart would trigger my mausberry to cut power. I would lose the reboot ability

            I can't see why my systemd trick would cause that (edit: oh, I've just remembered that you added some lines to killes.sh). Can you please make a test to check?

            Do all the steps I showed on that topic and try to reboot your system. Describe here what happens.

            And then perform this command: sudo systemctl disable killes; sudo systemctl stop killes and reboot your system. Describe here what happens.

            I'm anxious for your feedback. :-)

            • Useful topics
            • joystick-selection tool
            • rpie-art tool
            • achievements I made
            caver01C 2 Replies Last reply Reply Quote 0
            • caver01C
              caver01 @meleu
              last edited by caver01

              @meleu Yes, that's the plan. It's going to be several hours before I can test. You remembered my addition. . . I am adding a line that is going to twiddle GPIO 18 to my transistor, which should tell the MB circuit it is time to start watching its GPIO connection for power-down (of course it will try to initiate a shutdown too at that point).

              My 4-player cocktail style cabinet built as a custom "roadcase"

              meleuM 1 Reply Last reply Reply Quote 0
              • meleuM
                meleu @caver01
                last edited by

                @caver01 Oh... Maybe adding those lines to the killes.sh isn't the perfect solution. Let's solve the saving metadata issue first and later we can try to solve your shutdown/reboot issue. ;-)

                • Useful topics
                • joystick-selection tool
                • rpie-art tool
                • achievements I made
                caver01C 1 Reply Last reply Reply Quote 0
                • caver01C
                  caver01 @meleu
                  last edited by

                  @meleu Agreed. However, is there a way, during a soft reboot to detect whether the shutting down is a result of a reboot request as opposed to a shutdown/poweroff? If a reboot command leaves some trace that we could try to detect with a conditional, I could hold back that command if found.

                  My 4-player cocktail style cabinet built as a custom "roadcase"

                  meleuM 1 Reply Last reply Reply Quote 0
                  • meleuM
                    meleu @caver01
                    last edited by

                    @caver01 I know that there are "systemd ways" to launch a script for reboot or poweroff exclusively. I'm not a systemd expert but I know it can be done.

                    • Useful topics
                    • joystick-selection tool
                    • rpie-art tool
                    • achievements I made
                    caver01C 1 Reply Last reply Reply Quote 0
                    • caver01C
                      caver01 @meleu
                      last edited by

                      @meleu LOL and here I thought you did all of that exciting sysetmd research!

                      My 4-player cocktail style cabinet built as a custom "roadcase"

                      meleuM 1 Reply Last reply Reply Quote 0
                      • meleuM
                        meleu @caver01
                        last edited by

                        @caver01 I just researched enough to find that solution. And then went to do something more interesting (usually play Mega Man :-) ).

                        • Useful topics
                        • joystick-selection tool
                        • rpie-art tool
                        • achievements I made
                        1 Reply Last reply Reply Quote 0
                        • caver01C
                          caver01 @meleu
                          last edited by caver01

                          @meleu said in Powering off via UI while using a Mausberry Circuit:

                          Do all the steps I showed on that topic and try to reboot your system. Describe here what happens.

                          And then perform this command: sudo systemctl disable killes; sudo systemctl stop killes and reboot your system. Describe here what happens.

                          SO, for starters, I have already done what you prescribed in the other thread to build the service and the killes.sh. Mine is till in the ~/bin folder, which is fine by me for now. After setting the killes.sh as executable, it works great! That is to say, I can do a software shutdown from command line for instance, and it definitely saves my metadata. Favorites and custom collections are awesome. Moreover, my additional line which triggers the NPN transistor does indeed let the Mausberry circuit know that a shutdown is imminent and it properly notices the drop on the GPIO it is monitoring and it cuts power. I really like this clever solution.

                          It also cuts power when I initiate a reboot. That makes sense to me, and for now I am willing to live with it. The point is that software shutdown requests properly exit ES and no longer lock up my Mausberry circuit.

                          Seems to me, the improvement to this would be to set a conditional statement before my GPIO command to trigger the transistor such that it checks to see if this is a shutdown/poweroff or if this is a reboot. I just don't know what to check to verify one way or the other--yet.

                          As for your command above, I initiated the command as you suggested and the system immediately did a shutdown, mausberry circuit powered off.

                          My 4-player cocktail style cabinet built as a custom "roadcase"

                          1 Reply Last reply Reply Quote 1
                          • 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.