Recalbox Forum

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

    Problème power script

    Recalbox Général
    script
    4
    35
    8069
    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.
    • lainbebop
      lainbebop last edited by

      @supernature2k said in Problème power script:

      PIN356PUSHRESET

      J'ai testé, Appui court = le Pi s'éteint d'un coup (pas équivalent à start/quitter !!)

      Comment arriver au fonctionnement écrit dans le Wiki ?

      j'aimerais :
      Pression courte : quitte l'émulateur
      Pression longue : éteint le Pi proprement (start/quitter)

      NB : voici la ligne que j'ai rajouté dans le recalbox.conf :
      system.power.switch=PIN356PUSHRESET

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

        @lainbebop je ne sais que dire, le script fonctionne correctement chez moi

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

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

          @supernature2k bon 😞 je vais faire la dernière MAJ et si ça ne marche pas je vais reinstaller 😕

          C’est peut être du au fait que j’ai installé le script du wiki ? J’ai envoyé la ligne « uninstall » pourtant, mais ça a peut-être modifié des fichiers 😕

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

            @lainbebop c'est possible oui

            prends bien le PIN356PUSHRESET et cable bien le + sur le pin 5 (GPIO3) et le - sur le pin 6 (GND)

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

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

              @supernature2k alors en gros j’ai un cable qui va du pin3 au bouton sanwa et un cable qui va du pin6 au bouton sanwa. Je ne savais pas qu’il y avait une polarité ?

              Pour la ligne dans recalbox.conf c’est bien celle ci !

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

                @lainbebop non y a pas vraiment de polarité si c'est un bouton simple. Par contre PIN 3?!?

                PIN 3 c'est pour RESET

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

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

                  @supernature2k

                  Pardon pin5 et pin6 selon ce schéma!!

                  alt text

                  C’est un bouton comme ça
                  alt text

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

                    j'ai exactement le même problème lainbebop. J'ai brancher sur 5 et 6 avec un bouton poussoir, configurer PIN356PUSHRESET mais quand je suis dans un émulateur ça fait un hard reset. Bizarrement cela fonctionne bien que sur nintendo 64 mais pour les autres consoles cela fait un hard reset.

                    1 Reply Last reply Reply Quote 1
                    • lainbebop
                      lainbebop last edited by

                      @supernature2k @Tactys
                      J'ai fait la dernière MAJ,

                      • Appui long : rien
                      • Appui court : rien
                      • 2 appuis courts : Pi éteint (hard :/)

                      Tu as aussi tenté d'installer le script sur cette page @Tactys ?

                      Tactys supernature2k 2 Replies Last reply Reply Quote 0
                      • Tactys
                        Tactys @lainbebop last edited by

                        @lainbebop J'ai fait la dernière Maj aussi mais j'ai pas installer le script.

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

                          @lainbebop Hi,
                          J'ai refait un test hier sur une recalbox fraîchement mise à jour et j'ai bien le comportement attendu sur les deux boutons.

                          Peux tu re-verifier ton recalbox.conf et ton cablage?

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

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

                            @supernature2k

                            (on doit tagger et mettre le text dans 2 posts séparés sinon "flagged as spam 😞 )

                            lainbebop 1 Reply Last reply Reply Quote 0
                            • lainbebop
                              lainbebop @lainbebop last edited by

                              This post is deleted!
                              1 Reply Last reply Reply Quote 0
                              • lainbebop
                                lainbebop last edited by

                                Voici le recalbox.conf ! A noter qu'avant la MAJ ne n'avais pas le PIN356PUSHRESET que je l'ai ajouté, et qu'après la MAJ j'avais 10fois cette ligne et plus les autres (qui étaient commentés ";"!) j'ai donc tout supprimé pour ne laisser que celui là :

                                # System Variable
                                # You can configure your recalbox from here
                                # To set a variable, remove the first ; on the line
                                
                                
                                
                                # ------------ A - System Options ----------- #
                                #    Uncomment the system.power.switch you use
                                system.power.switch=PIN356PUSHRESET
                                
                                
                                ## fbcp FrameBuffer Copy Program
                                ## For small TFT screen on GPIO and SPI
                                ## See https://github.com/recalbox/recalbox-os/wiki/Utility---Use-of-fbcp-for-small-TFT-screen-%28EN%29 for details
                                ## Needed for Waveshare 3.2" 3.5" TFT screen, 2.8" Adafruit screen
                                ## See https://github.com/recalbox/recalbox-os/wiki/TFT-Screen-SPI-Bus-%28EN%29
                                ## for support and configuration details needed by /boot/config.txt
                                system.fbcp.enabled=0
                                
                                ## Recalbox Manager (http manager)
                                system.manager.enabled=1
                                ## 1 or 2, depending on the manager version you wish
                                system.manager.version=2
                                
                                ## Recalbox security
                                # enforce security
                                #   samba password required
                                #   disable virtual gamepads
                                system.security.enabled=0
                                
                                ## Recalbox API (REST)
                                system.api.enabled=0
                                
                                ## Allow a specific resolution for ES only from the command : tvservice -m [MODE]
                                ## Leave commented for the default usual behaviour
                                ;system.es.videomode=CEA 4 HDMI
                                
                                ## EmulationStation
                                ### menu style
                                ### default -> default all options menu
                                ### none -> no menu except the game search menu
                                ### bartop -> less menu, only needed for bartops
                                emulationstation.menu=default
                                ### Select a system to show on boot (use rom directory name) (string)
                                emulationstation.selectedsystem=favorites
                                ### Show the gamelist of the first or selected system on boot (0,1)
                                emulationstation.bootongamelist=0
                                ### Disable system view ES will boot and show ONLY the first or selected system (0,1)
                                emulationstation.hidesystemview=0
                                ### Pa**e Gamelists only. Show only games listed in gamelist.xml files (0,1)
                                emulationstation.gamelistonly=0
                                ### Force basicgameList view to be displayed, even if your game systems are scraped (0,1)
                                emulationstation.forcebasicgamelistview=0
                                
                                ## Emulator special keys
                                ## default -> default all special keys
                                ## nomenu -> cannot popup the emulator menu
                                ## none -> no special keys in emulators
                                system.emulators.specialkeys=default
                                
                                ## Show or hide kodi in emulationstation (0,1)
                                kodi.enabled=1
                                ## Start kodi at launch (0,1)
                                kodi.atstartup=0
                                ## set x button shortcut (0,1)
                                kodi.xbutton=0
                                
                                ## Allow a specific resolution for Kodi only from the command : tvservice -m [MODE]
                                ## By default is using the default resolution of your screen
                                kodi.videomode=default
                                
                                ## Kodi can wait for a network component before starting
                                ## waithost is the ip or hostname that must answer to a ping to validate the availability
                                ## waittime is the maximum time waited when kodi boots
                                ## if waitmode is required, kodi will not start if the component is not available
                                ## if waitmode is wish, kodi will start if the component is not available
                                ## if waitmode is not set or has another value, kodi will start immediately
                                ;kodi.network.waitmode=required
                                ;kodi.network.waittime=10
                                ;kodi.network.waithost=192.168.0.50
                                
                                ## Hyperion
                                ## Hyperion allows you to use an ambilight like led system on your recalbox
                                ## Use hypercon to create your configuration file, and copy it in /recalbox/share/system/configs/hyperion/hyperion.config.json
                                hyperion.enabled=0
                                
                                
                                # ------------ B - Network ------------ #
                                ## Set system hostname
                                system.hostname=RECALBOX
                                ## Activate wifi (0,1)
                                wifi.enabled=1
                                ## Wifi SSID (string)
                                wifi.ssid=Livebox-CF56
                                ## Wifi KEY (string)
                                ## after rebooting the recalbox, the "new key" is replace by a hidden value "enc:xxxxx"
                                ## you can edit the "enc:xxxxx" value to replace by a clear value, it will be updated again at the following reboot
                                ## Escape your special chars (# ; $) with a backslash : $ => \$
                                wifi.key=enc:U2FsdGVkX19bTpsXwvHmV1S+UUKJMMot/DmZYLtq8TNmN0c3xQdMHgSLwcUFCnxi
                                
                                # secondary wifi (not configurable via the user interface)
                                ;wifi2.ssid=new ssid
                                ;wifi2.key=new key
                                
                                # third wifi (not configurable via the user interface)
                                ;wifi3.ssid=new ssid
                                ;wifi3.key=new key
                                
                                ## Samba share
                                system.samba.enabled=1
                                ### Virtual Gamepads
                                system.virtual-gamepads.enabled=1
                                ### SSH
                                system.ssh.enabled=1
                                
                                # ------------ C - Audio ------------ #
                                ## Set the audio device (auto, hdmi, jack)
                                audio.device=jack
                                ## Set system volume (0..100)
                                audio.volume=77
                                ## Enable or disable system sounds in ES (0,1)
                                audio.bgmusic=1
                                
                                
                                
                                # -------------- D - Controllers ----------------- #
                                # Enable support for standard bluetooth controllers
                                controllers.bluetooth.enabled=1
                                
                                
                                ## Please enable only one of these
                                # -------------- D1 - PS3 Controllers ------------ #
                                ##Enable PS3 controllers support
                                controllers.ps3.enabled=1
                                ## Choose a driver between bluez, official and shanwan
                                ## bluez -> bluez 5 + kernel drivers, support official and shanwan sisaxis
                                ## official -> sixad drivers, support official and gasia sisaxis
                                ## shanwan -> shanwan drivers, support official and shanwan sisaxis
                                controllers.ps3.driver=bluez
                                
                                
                                # ------------ D2 - GPIO Controllers ------------ #
                                ## GPIO Controllers
                                ## enable controllers on GPIO with mk_arcarde_joystick_rpi (0,1)
                                controllers.gpio.enabled=0
                                ## mk_gpio arguments, map=1 for one controller, map=1,2 for 2 (map=1,map=1,2)
                                controllers.gpio.args=map=1,2
                                
                                
                                # ------------ D3 - Steam Controllers ------------ #
                                ## Enable steam controller service
                                controllers.steam.enabled=0
                                
                                
                                ## DB9 Controllers
                                ## Enable DB9 drivers for atari, megadrive, amiga controllers (0,1)
                                controllers.db9.enabled=0
                                ## db9 arguments
                                controllers.db9.args=map=1
                                
                                ## Gamecon controllers
                                ## Enable gamecon controllers, for nes, snes psx (0,1) 
                                controllers.gamecon.enabled=0
                                ## gamecon_args
                                controllers.gamecon.args=map=1
                                
                                ## XGaming's XArcade Tankstik and other compatible devices
                                controllers.xarcade.enabled=1
                                
                                
                                
                                # ------------ F - Language and keyboard ------------ #
                                ## Set the language of the system (fr_FR,en_US,en_GB,de_DE,pt_BR,es_ES,it_IT,eu_ES,tr_TR,zh_CN)
                                system.language=fr_FR
                                ## set the keyboard layout (fr,en,de,us,es)
                                system.kblayout=fr
                                ## Set you local time
                                ## Select your timezone from : ls /usr/share/zoneinfo/ (string)
                                system.timezone=Europe/Paris
                                
                                
                                
                                # ------------ G - UPDATES ------------ #
                                ## Automatically check for updates at start (0,1)
                                updates.enabled=1
                                # Update type : default to stable
                                updates.type=stable
                                
                                
                                # ------------ H - HERE IT IS - GLOBAL EMULATOR CONFIGURATION ------------ #
                                ## The global value will be used for all emulators, except if the value
                                ## is redefined in the emulator
                                
                                ## Set game resolution for emulators
                                ## select your mode from the command : tvservice -m [MODE]
                                ## CEA 5 HDMI : 1920x1080 @ 60Hz 16:9, clock:74MHz interlaced 
                                ## CEA 4 HDMI : 1280x720 @ 60Hz 16:9, clock:74MHz progressive
                                ## use 'default' for using the default resolution
                                ## use 'auto' : switches to CEA 4 HDMI if supported, else keep the current resolution
                                ## (string)
                                global.videomode=DMT 9 HDMI
                                
                                ## Shader set 
                                ## Automatically select shaders for all systems
                                ## (none, retro, scanlines)
                                global.shaderset=none
                                
                                ## Once enabled, your screen will be cropped, and you will have a pixel perfect image (0,1)
                                global.integerscale=0
                                
                                ## Set gpslp shader for all emulators (prefer shadersets above). Absolute path (string)
                                global.shaders=
                                
                                ## Set ratio for all emulators (auto,4/3,16/9,16/10,custom)
                                global.ratio=auto
                                
                                ## Set smooth for all emulators (0,1)
                                global.smooth=1
                                
                                ## Set rewind for all emulators (0,1)
                                global.rewind=0
                                
                                ## Set autosave/load savestate for all emulators (0,1)
                                global.autosave=0
                                
                                ## Enable retroarchievements (0,1)
                                ## Set your www.retroachievements.org username/password
                                ## Escape your special chars (# ; $) with a backslash : $ => \$
                                global.retroachievements=0
                                global.retroachievements.hardcore=0
                                global.retroachievements.username=
                                global.retroachievements.password=
                                
                                ## Set retroarch input driver (auto, udev, sdl2)
                                ## If you don't have issues with your controllers, let auto
                                global.inputdriver=auto
                                
                                ## If you do not want recalboxOS to generate the configuration for all emulators (string)
                                ;global.configfile=/path/to/my/configfile.cfg
                                
                                # ------------ I - EMULATORS CHOICES ----------- #
                                ## You can override the global configuration here
                                ## Here is the snes example
                                ;snes.videomode=CEA 4 HDMI
                                snes.core=snes9x_next
                                ;snes.shaders=/recalbox/share/shaders/shaders_glsl/mysnesshader.gplsp
                                snes.ratio=4/3
                                ;snes.smooth=0
                                ;snes.rewind=1
                                ;snes.autosave=0
                                ;snes.emulator=libretro
                                ;snes.integerscale=0
                                ## If you do not want recalboxOS to generate the configuration for the emulator : 
                                ;snes.configfile=/path/to/my/configfile.cfg
                                
                                ## Default cores for RPi3
                                snes.core=snes9x_next
                                gba.core=mgba
                                mame.core=mame078
                                nes.core=quicknes
                                
                                ## NeoGeo emulator 
                                ## You can use pifba or a libretro core (fba2x,libretro)
                                neogeo.emulator=libretro
                                ## If you set libretro as neogeo.emulator, the line below sets the retroarch core (fba,imame4all)
                                neogeo.core=fba
                                
                                ## N64 emulator is configured to display a screen with a 640x480 resolution (native n64 resolution)
                                ## So you must use one of these video modes (DMT 4 HDMI,CEA 1 HDMI).
                                ## If your screen is not compatible with one of these video modes, please check the recalbox's wiki.
                                n64.videomode=DMT 4 HDMI
                                ## If you are using a CRT screen, please change the setting above with this one : 
                                # n64.videomode=default
                                
                                ## Dreamcast emulator
                                ## Like N64, such a CPU intensive emulator needs a small resolution
                                ## Consider DMT 4 HDMI (640*480) or DMT 9 HDMI (800*600). If you have a black screen on dreamcast, try DMT 9 HDMI here
                                dreamcast.videomode=DMT 4 HDMI
                                
                                ## Configurations generated by Recalbox
                                system.es.menu=default
                                controllers.xboxdrv.enabled=0
                                controllers.xboxdrv.nbcontrols=2
                                fba.ratio=4/3
                                mame.ratio=4/3
                                nes.ratio=auto
                                nes.emulator=libretro
                                psx.ratio=4/3
                                psx.rewind=0
                                fba.rewind=0
                                

                                Pour les branchements, j'ai juste 2 fils qui partent du bouton, directements branchés sur le GPIO :

                                1_1523001248972_1.jpg

                                0_1523001248964_2.jpg

                                Merci de ton aide !

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

                                  @lainbebop la conf et les branchements sont bons 😕

                                  Peux-tu vérifier que le fichier existe bien?

                                  Tu dois avoir un fichier rpi-pin356-power.py sous /recalbox/scripts/

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

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

                                    @supernature2k

                                    0_1523290293960_Capture d’écran 2018-04-09 à 18.11.01.png

                                    Je pense que oui ?

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

                                      @lainbebop désolé mais là je suis à court d'idées 😕

                                      un petit ps pour voir si le script tourne bien en arrière plan?

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

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

                                        Voilà ce que j'obtiens avec le ps :

                                        PID   USER     COMMAND
                                            1 root     init [3]
                                            2 root     [kthreadd]
                                            3 root     [ksoftirqd/0]
                                            4 root     [kworker/0:0]
                                            5 root     [kworker/0:0H]
                                            6 root     [kworker/u8:0]
                                            7 root     [rcu_sched]
                                            8 root     [rcu_bh]
                                            9 root     [migration/0]
                                           10 root     [migration/1]
                                           11 root     [ksoftirqd/1]
                                           12 root     [kworker/1:0]
                                           13 root     [kworker/1:0H]
                                           14 root     [migration/2]
                                           15 root     [ksoftirqd/2]
                                           16 root     [kworker/2:0]
                                           17 root     [kworker/2:0H]
                                           18 root     [migration/3]
                                           19 root     [ksoftirqd/3]
                                           20 root     [kworker/3:0]
                                           21 root     [kworker/3:0H]
                                           22 root     [kdevtmpfs]
                                           23 root     [netns]
                                           24 root     [perf]
                                           25 root     [khungtaskd]
                                           26 root     [writeback]
                                           27 root     [crypto]
                                           28 root     [bioset]
                                           29 root     [kblockd]
                                           30 root     [kworker/0:1]
                                           31 root     [rpciod]
                                           32 root     [kswapd0]
                                           33 root     [vmstat]
                                           34 root     [fsnotify_mark]
                                           35 root     [nfsiod]
                                           44 root     [kthrotld]
                                           45 root     [bioset]
                                           46 root     [bioset]
                                           47 root     [bioset]
                                           48 root     [bioset]
                                           49 root     [bioset]
                                           50 root     [bioset]
                                           51 root     [bioset]
                                           52 root     [bioset]
                                           53 root     [bioset]
                                           54 root     [bioset]
                                           55 root     [bioset]
                                           56 root     [bioset]
                                           57 root     [bioset]
                                           58 root     [bioset]
                                           59 root     [bioset]
                                           60 root     [bioset]
                                           61 root     [bioset]
                                           62 root     [bioset]
                                           63 root     [bioset]
                                           64 root     [bioset]
                                           65 root     [bioset]
                                           66 root     [bioset]
                                           67 root     [bioset]
                                           68 root     [bioset]
                                           69 root     [VCHIQ-0]
                                           70 root     [VCHIQr-0]
                                           71 root     [VCHIQs-0]
                                           72 root     [iscsi_eh]
                                           73 root     [dwc_otg]
                                           74 root     [kworker/1:1]
                                           75 root     [DWC Notificatio]
                                           76 root     [kworker/u8:1]
                                           77 root     [irq/92-mmc1]
                                           78 root     [VCHIQka-0]
                                           79 root     [SMIO]
                                           80 root     [deferwq]
                                           81 root     [kworker/u8:2]
                                           82 root     [bioset]
                                           83 root     [mmcqd/0]
                                           84 root     [kworker/2:1]
                                           85 root     [jbd2/mmcblk0p2-]
                                           86 root     [ext4-rsv-conver]
                                           87 root     [kworker/2:1H]
                                           88 root     [kworker/1:2]
                                           91 root     [kworker/0:1H]
                                           92 root     [kworker/3:1]
                                          114 root     /sbin/syslogd -n
                                          117 root     /sbin/klogd -n
                                          155 root     dbus-daemon --fork --print-address 5 --print-pid 6 --session
                                          162 root     [kworker/3:1H]
                                          165 root     [kworker/1:1H]
                                          166 root     [kworker/0:2]
                                          167 root     /sbin/udevd -d
                                          204 root     [cfg80211]
                                          206 root     [brcmf_wq/mmc1:0]
                                          207 root     [brcmf_wdog/mmc1]
                                          210 root     [kworker/3:2]
                                          242 dbus     dbus-daemon --system
                                          255 root     /usr/sbin/connmand -n
                                          310 root     [ipv6_addrconf]
                                          317 root     /usr/sbin/wpa_supplicant -u
                                          319 root     [kworker/3:3]
                                          411 root     [jbd2/mmcblk0p3-]
                                          412 root     [ext4-rsv-conver]
                                          531 root     /usr/sbin/lircd -n --driver=default --device=/dev/lirc0 --output
                                          921 root     {emulationstatio} /usr/bin emulationstation
                                         1009 root     /usr/libexec/bluetooth/bluetoothd --noplugin=sixaxispair
                                         1093 root     /usr/sbin/ntpd -g
                                         1099 avahi    avahi-daemon: running [RECALBOX.local]
                                         1109 root     /usr/sbin/dropbear -R
                                         1122 root     smbd -D --configfile=/etc/samba/smb.conf
                                         1124 root     {smbd-notifyd} smbd -D --configfile=/etc/samba/smb.conf
                                         1125 root     {cleanupd} smbd -D --configfile=/etc/samba/smb.conf
                                         1140 root     nmbd -D --configfile=/etc/samba/smb.conf
                                         1154 root     {powerswitch.sh} /bin/bash /recalbox/scripts/powerswitch.sh star
                                         1164 root     python /recalbox/scripts/rpi-pin356-power.py -m push
                                         1170 root     node virtualgamepads.js
                                         1189 root     {S94manager} /bin/sh /etc/init.d/S94manager start
                                         1191 root     node dist/server.js
                                         1207 root     /sbin/getty 38400 tty2
                                         1209 root     [kworker/u9:0]
                                         1210 root     [hci0]
                                         1211 root     [hci0]
                                         1213 root     [kworker/u9:1]
                                         1214 root     /usr/bin/hciattach /dev/serial1 bcm43xx 921600 noflow -
                                         1215 root     [kworker/u9:2]
                                         1216 root     /usr/bin/node server.js
                                         1320 root     /usr/sbin/dropbear -R
                                         1357 root     -sh
                                         1369 root     ps
                                        

                                        TEST 1

                                        J'ai réinstallé RECALBOX sur une autre SD, sans support externe (j'ai débranché ma clé usb), pour tester.
                                        Donc install propre, sans jeux si ce n'est ceux déjà présents dans RECALBOX.

                                        Et bien c'est pareil !

                                        • Appui court : rien
                                        • Appui long : rien ou coupure du courant
                                        • Appuis répétés : coupure du courant

                                        TEST 2

                                        J'ai débranché mon bouton du GPIO et j'ai mis un couteau (en métal) entre les 2 PIN 5 et 6 : même comportement qu'avec le bouton, coupure du courant du Pi

                                        T_T

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

                                          ( @supernature2k )

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

                                            @lainbebop

                                            try this please:

                                            import RPi.GPIO as GPIO
                                            import time
                                            import os
                                            import thread
                                            import datetime
                                            import socket
                                            import sys
                                            import argpa**e
                                            from datetime import datetime
                                            from configgen import recalboxFiles
                                            # this last one retrieves emulators bin names
                                            
                                            pa**er = argpa**e.ArgumentPa**er(description='power manager')
                                            pa**er.add_argument("-m", help="mode onoff or push", type=str, required=True)
                                            args = pa**er.pa**e_args()
                                            
                                            mode = args.m
                                            
                                            IPADDR = "127.0.0.1"
                                            PORTNUM = 55355
                                            # IP and port for retroarch network commands
                                            
                                            POWERPLUS = 3
                                            RESETPLUS = 2
                                            LED = 14
                                            
                                            GPIO.setwarnings(False)		# no warnings
                                            GPIO.setmode(GPIO.BCM)		# set up BCM GPIO numbering 
                                             
                                            GPIO.setup(RESETPLUS, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                                            # GPIO on pin 3 is the GPIO 2 in BCM mode
                                            #to Reset+
                                            
                                            GPIO.setup(POWERPLUS, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                                            # GPIO on pin 5 is the GPIO 3 in BCM mode
                                            #to Power+
                                            
                                            GPIO.setup(LED, GPIO.OUT)
                                            GPIO.output(LED, True)
                                            # GPIO on pin 8 is the GPIO 14 in BCM mode
                                            #to LED+
                                            
                                              
                                            # Define a threaded callback function to run in another thread when events are detected  
                                            def button_pressed(channel):
                                            	if channel == POWERPLUS:
                                            		speed=0.15
                                            		shutdownstring="shutdown -h now"
                                            		nwcommand="QUIT"
                                            		
                                            	elif channel == RESETPLUS:
                                            		speed=0.05
                                            		shutdownstring="shutdown -r now"
                                            		nwcommand="RESET"
                                            		
                                            	timer = 0
                                            	flag = True
                                            	while flag:
                                            		if GPIO.input(channel) == False:
                                            			timer += 1
                                            			print "Button pressed"
                                            		elif GPIO.input(channel) == True:
                                            		
                                            			print "Button released"
                                            			print timer
                                            		
                                            			#timer adds 1 each 0.1 seconds if timer = 10, button is pressed for 1s
                                            			if (timer > 10):
                                            				offreset(speed, shutdownstring)
                                            				print "shutdown"
                                            			elif (timer >=1):
                                            				print "retroarch"
                                            				killthats**t(channel)
                                            				
                                            			timer = 0
                                            			flag = False
                                            		time.sleep(0.1)
                                            		
                                            	
                                            #	on power short press, trying to kill all listed emus 
                                            def killthats**t(channel):
                                            	if channel == POWERPLUS:
                                            		for bin in recalboxFiles.recalboxBins:
                                            				print bin
                                            				proc = os.path.basename(bin)
                                            				print proc
                                            				os.system("killall -9 "+proc)
                                            
                                            # 	on long button press clean stop	of ES then shutdown -h or -r		
                                            def offreset(speed, shutdownstring):
                                            	thread.start_new_thread( blink, (speed, ))
                                            	flag=True
                                            	pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
                                            	os.system("/etc/init.d/S31emulationstation stop")
                                            	while flag:
                                            		flag = False
                                            		for pid in pids:
                                            				try:
                                            					print pid
                                            					commandpath = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
                                            					if "emulationstation" in commandpath:
                                            						flag = True
                                            				except IOError:
                                            					continue
                                            	os.system(shutdownstring)
                                            
                                            # threaded blinking function for LED	
                                            def blink(speed):
                                            	while True:  
                                            			GPIO.output(LED, False)
                                            			time.sleep(speed)
                                            			GPIO.output(LED, True)
                                            			time.sleep(speed)
                                            
                                            
                                            # 	sending network command to retroarch (only exit and reset atm)		
                                            def retroarch(nwcommand):
                                            	try:
                                            		s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                                            	except socket.error:
                                            		print 'Failed to create socket'
                                            		sys.exit()
                                            	s.sendto(nwcommand, (IPADDR, PORTNUM))
                                            		
                                            
                                            GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=button_pressed, bouncetime=2)
                                            GPIO.add_event_detect(POWERPLUS, GPIO.BOTH, callback=button_pressed, bouncetime=2)
                                            while True:
                                            	time.sleep(0.2)
                                            

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

                                            lainbebop 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Want to support us ?

                                            76
                                            Online

                                            99.6k
                                            Users

                                            28.1k
                                            Topics

                                            187.1k
                                            Posts

                                            Copyright © 2021 recalbox.com