Recalbox Forum

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

    Push button (ON/OFF) script problems?

    Recalbox General
    push button onoff script
    13
    34
    16810
    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.
    • paradadf
      paradadf Staff last edited by

      Hello everyone!
      I installed a momentary switch as described on the wiki and it works great. The only issue I'm having is that sometimes, when I plug/unplug an usb controller or usb stick, Recalbox turns off (or on) out of the blue. Has someone else experience this behavior?

      If your question was answered, please mark it as solved: Topic Tools -> Ask a question + Topic Tools -> Mark as Solved

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

        I've had such weird behaviours when playing around with the HDMI cable without using the power script ... D**n, what an unuseful comment I just wrote lol

        Former dev - Please reply with @substring so that i am notified when you answer me
        Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

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

          Some switches are very sensitive (especially old ones) and it can trigger some events when slightly moved.
          I have the same problem with my NES power switch.

          You can easily edit the script and change the function so that the button must be pressed x seconds to trigger the shutdown. it should solve this kind of problem.

          D**n, THAT IS a useful comment 😛

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

          1 Reply Last reply Reply Quote 0
          • paradadf
            paradadf Staff last edited by

            😆 thanks! I'll try it and report back!

            If your question was answered, please mark it as solved: Topic Tools -> Ask a question + Topic Tools -> Mark as Solved

            1 Reply Last reply Reply Quote 0
            • lackyluuk
              lackyluuk Translator last edited by

              I have this behaviour as well. But I am not using any start / stop scripts. I just start recalbox and sometimes it reboots when I plug in a USB controller. I do not know what to do 😞

              The only scripts I use are two selfmade scripts for changing the system volume via gpio and a fan control. But I do not think this has an impact.

              NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

              PenPen dh04000 2 Replies Last reply Reply Quote 0
              • PenPen
                PenPen @lackyluuk last edited by PenPen

                @lackyluuk said in Push button (ON/OFF) script problems?:

                The only scripts I use are two selfmade scripts for changing the system volume via gpio and a fan control.

                Hi,
                Coud you explain your fan control script ? Thx

                Raspberry Pi 3 > NeoGeo piX
                Recalbox 4.1 OC@1375Mhz
                https://forum.recalbox.com/topic/4006/wip-neogeo-pix

                1 Reply Last reply Reply Quote 0
                • paradadf
                  paradadf Staff last edited by

                  I've looked into
                  https://github.com/recalbox/recalbox-buildroot/blob/rb-4.1.X/board/recalbox/fsoverlay/recalbox/scripts/powerswitch.sh
                  and
                  https://github.com/recalbox/recalbox-buildroot/blob/rb-4.1.X/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin56-power.py
                  but I still can't find which value I should change. Any hints, please?

                  If your question was answered, please mark it as solved: Topic Tools -> Ask a question + Topic Tools -> Mark as Solved

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

                    @paradadf

                    I'm working on a super script, I think it will help you.

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

                    paradadf 1 Reply Last reply Reply Quote 1
                    • paradadf
                      paradadf Staff @supernature2k last edited by

                      @supernature2k the word SUPER before any other is always nice to read! Looking forward!

                      If your question was answered, please mark it as solved: Topic Tools -> Ask a question + Topic Tools -> Mark as Solved

                      1 Reply Last reply Reply Quote 0
                      • lackyluuk
                        lackyluuk Translator last edited by lackyluuk

                        @PenPen: I am sorry for this way too late answer. Not sure if you need an answer anymore

                        Here is an example with GPIO pin 14 for controlling the fan. The indents might not be correct 😉 I had a little trouble with copy/paste the code 😄
                        Hope I can help you with this

                        #!/usr/bin/env python
                        
                        import os
                        import time
                        import RPi.GPIO as GPIO
                        
                        GPIO.setwarnings(False)
                        GPIO.setmode(GPIO.BCM)
                        #Set max. temperature of CPU
                        TEMP_MAX = 67
                        ON_TIME = 200
                        #Set pin 14 as transistor gate
                        GATE = 14
                        #Set pin 14 as an output and shut down
                        GPIO.setup(GATE, GPIO.OUT)
                        GPIO.output(GATE, False)
                        
                        def getCPUtemperature():
                        	 res = os.popen('vcgencmd measure_temp').readline()
                        	return(res.replace("temp=","").replace("'C\n",""))
                        
                        while True:
                        
                        		temp_float = float(getCPUtemperature())
                        
                        	try:
                        		if (temp_float > TEMP_MAX):
                        			# ein
                        			GPIO.output(GATE, True)
                        			time.sleep(ON_TIME)
                        			# aus
                        			GPIO.output(GATE, False)
                        		else:
                        			GPIO.output(GATE, False)
                        		
                        except KeyboardInterrupt:
                        	print float(getCPUtemperature())
                        	print "power off fan..."
                        	GPIO.output(GATE, False)
                        	print "cancelling..."
                        

                        Forgot to attach a short drawing. I used the official RaspberryPI 5V DC fan.

                        0_1474305851135_Unbenannt.PNG

                        NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                        PenPen 1 Reply Last reply Reply Quote 1
                        • supernature2k
                          supernature2k last edited by

                          Awesome!!!!!

                          But I'm not sure 'bout the infinite loop.

                          Maybe add a time.sleep somewhere for less CPU?

                          whatcha think @subs ?

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

                          1 Reply Last reply Reply Quote 0
                          • PenPen
                            PenPen @lackyluuk last edited by

                            @lackyluuk said in Push button (ON/OFF) script problems?:

                            @PenPen: I am sorry for this way too late answer. Not sure if you need an answer anymore

                            Thanks ! I'll buy composants tomorrow.

                            Raspberry Pi 3 > NeoGeo piX
                            Recalbox 4.1 OC@1375Mhz
                            https://forum.recalbox.com/topic/4006/wip-neogeo-pix

                            1 Reply Last reply Reply Quote 0
                            • lackyluuk
                              lackyluuk Translator last edited by

                              @supernature2k yes, this could be a good idea. Would it be useful to have a time.sleep in the while loop? So it checks the temp only every 2 seconds for example.

                              NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

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

                                Yes I think so, at the end of the while.

                                1 or 0.5 seconds would be ok too I guess.

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

                                1 Reply Last reply Reply Quote 1
                                • dh04000
                                  dh04000 @lackyluuk last edited by

                                  @lackyluuk said in Push button (ON/OFF) script problems?:

                                  The only scripts I use are two selfmade scripts for changing the system volume via gpio and a fan control. But I do not think this has an impact.

                                  How do you do this? The gpio volume control? Could you post this script?

                                  Also, I have OP's problem with crashing after installing the gpio on/off button with usb controller unpluging, as well as sometimes random.

                                  @supernature2k said in Push button (ON/OFF) script problems?:

                                  Some switches are very sensitive (especially old ones) and it can trigger some events when slightly moved.
                                  I have the same problem with my NES power switch.

                                  You can easily edit the script and change the function so that the button must be pressed x seconds to trigger the shutdown. it should solve this kind of problem.

                                  D**n, THAT IS a useful comment 😛

                                  How do I change the time to be longer? I think my gpio momentary switch might be picking up some signal from my speakers, wifi, light system, something....

                                  1 Reply Last reply Reply Quote 0
                                  • lackyluuk
                                    lackyluuk Translator last edited by lackyluuk

                                    @dh04000 Here is a wiki article that I wrote. This should help you. I used the Hifiberry Shield to access the ALSA controls.

                                    https://github.com/recalbox/recalbox-os/wiki/Audio-HiFiBerry-(EN)

                                    NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

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

                                      Hello, I'm completley new to this stuff so just to make shure I don't damage my Raspberry can someone confirm that following these steps will make the fan-control script work?

                                      1. On my Linux Desktop I create an empty textfile in which I paste the fan-script posted here.
                                      2. I rename the file into fancontrol.py and move it into /recalbox/share/system/ on the sd-card.
                                      3. On Recalbox i quit emulationstation, open the terminal and navigate to the share/system directory and make my script executable with chmod +x fancontrol.py so it is ran at boot

                                      And last question (for now:) - where in the script should i paste the time.sleep(1) so it only checks every second for the temp?
                                      Thanks in advance!

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

                                        Where the hell do I paste the fan script ????

                                        1 Reply Last reply Reply Quote 0
                                        • lackyluuk
                                          lackyluuk Translator last edited by

                                          calm down @miserytom 😄

                                          I suggest you to put it into /recalbox/scripts and then in /etc/init.d (where all startup scripts are located) you could place another script which is starting your fan script in a background process

                                          NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                                          azvarel Pedro Vieira 2 Replies Last reply Reply Quote 0
                                          • azvarel
                                            azvarel @lackyluuk last edited by

                                            @paradadf

                                            I'm having a similar problem, I noticed two situations that happened with version 4.0 final the first was that in recalbox.conf the system.power.switch=PIN56ONOFF command duplicated several times, and the second that if I do screenscrapper of a very large romset example GBA simply out of nothing Rpi is turned off.

                                            There is a third option, the wifi in the recalbox shows that it is not connected, however I get access with your ip (this for me is very strange)

                                            Zodian Theme | #SNESProject

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

                                            Want to support us ?

                                            80
                                            Online

                                            99.0k
                                            Users

                                            28.1k
                                            Topics

                                            187.1k
                                            Posts

                                            Copyright © 2021 recalbox.com