RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Early Access: Scripting and Display Off / Energy Saving Feature

    Scheduled Pinned Locked Moved Ideas and Development
    powersaverc++emustationdisplay control
    16 Posts 4 Posters 1.9k 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.
    • LolonoisL
      Lolonois
      last edited by Lolonois

      I am thinking to implement a video power off functionality for the Rpi when running with a HDMI attached monitor. (As in #511).

      I assume onSleep() / onWake() are the methods to be able to do the video signal off/on logic (es-core/src/Window.cpp).

      What is puzzling me that this on/off logic is specific to the triple (architecture, platform, video port), e.g.:

      • (Rpi, Raspbian/Linux, HDMI)
      • (Rpi, Raspbian/Linux, GPIO)
      • (x86/x86_64, Windows, HDMI)
      • (x86/x86_64, Distro-x/Linux, DP)
      • ...

      You can imagine the combinations (think also of the ARM architectures Odroid, Vero4k, ...).

      For the triple (Rpi, Raspbian/Linux, HDMI) it is quite obvious what to implement by using vcgencmd. When not connected to HDMI/DVI tvservice -s may give a clue what video port is used (e.g. GPIO).

      Since I would like to avoid to clutter the code with #ifdef's for the various combinations outlined above I am asking what is the "RetroPie-way" to implement this power saving feature. A customizable script as briefly discussed in #377? Or something else?

      What are your ideas, clues, comments?

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

        IMHO, the most flexible way would be to call a script for a certain event, or a series of scripts.
        I can imagine a script folder for each event (something like ~/.emulationstation/scripts/events/<event_name>) and users can just drop scripts to do things on certain events (stop or start BGM music, toggle LEDs, etc.).

        J 1 Reply Last reply Reply Quote 0
        • J
          jdrassa @mitu
          last edited by

          @mitu said in Display Off / Energy Saving Feature:

          IMHO, the most flexible way would be to call a script for a certain event, or a series of scripts.
          I can imagine a script folder for each event (something like ~/.emulationstation/scripts/events/<event_name>) and users can just drop scripts to do things on certain events (stop or start BGM music, toggle LEDs, etc.).

          @mitu I actually implemented something along these lines last year. It was inspired by the scripting support in Pegasus. I think it was pretty much complete. I should really dust it off and submit a PR.

          Get latest build of EmulationStation for Windows here

          cyperghostC 1 Reply Last reply Reply Quote 1
          • cyperghostC
            cyperghost @jdrassa
            last edited by cyperghost

            @jdrassa Please do this and hopefully a PR will be accepted ;) Scripts can be utilized then to make live easier (or pure hell if something goes wrong)
            On the other hand it can suffer the same fate as the runcommand USER MENU (!? - sorry if I'm wrong here but afaik just a bunch of users use this fantastic entry point for setting up some stuff)

            1 Reply Last reply Reply Quote 1
            • LolonoisL
              Lolonois
              last edited by

              @mitu Thanks for the suggestions. Using scripts is ok as long the Arcade/Retropie owner controls who can access them and has control which get deployed.

              One more reason that users must understand that a Retropie should never connected directly to the Internet, at least not without precaution (read: hardening) of the OOTB configuration. But that's the flipside of the medal.

              1 Reply Last reply Reply Quote 0
              • LolonoisL
                Lolonois
                last edited by

                Just filed the PR #550.

                Can you (maybe @mitu) please advise

                • where to fulfill the pre-req that the path are created during ES setup and
                • how to deploy a short readme in this folder during setup to explain when the scripts are called and that they have to have the executable flag set

                Thanks and I am happy about feedback regarding the proposed changes.
                @jdrassa do you have something to amend by addition?

                J mituM 2 Replies Last reply Reply Quote 1
                • J
                  jdrassa @Lolonois
                  last edited by

                  @Lolonois I gave it a quick look. The actually script execution portion looks pretty similar to what I implemented. What I have is a bit more comprehensive. It covers more events of interest beyond wake/sleep. I'd prefer to get that merged first and then have you update your PR to work with it. I am going to try to make time this weekend and dust if off and get it ready.

                  Get latest build of EmulationStation for Windows here

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

                    @Lolonois said in Display Off / Energy Saving Feature:

                    where to fulfill the pre-req that the path are created during ES setup and
                    how to deploy a short readme in this folder during setup to explain when the scripts are called and that they have to have the executable flag set

                    I think both can be done through the ES scriptmodule installation, though I think there should be a sample scripts folder, including a README.

                    EDIT: Why enable it just for the RPI ? I think we might find alternatives for Odroid, PC (Ubuntu, Debians).

                    LolonoisL 1 Reply Last reply Reply Quote 0
                    • LolonoisL
                      Lolonois @jdrassa
                      last edited by

                      @jdrassa quite impressive list of events,did not knew all of them. Thanks for sharing and documenting them in one place.
                      While your PR is pending I will adapt mine to be applicable on top of yours.

                      LolonoisL 1 Reply Last reply Reply Quote 0
                      • LolonoisL
                        Lolonois @mitu
                        last edited by

                        @mitu said in Display Off / Energy Saving Feature:

                        Why enable it just for the RPI ?

                        With the more generic scripting approach there is no need to do so, right.
                        Whenever a maker of a Arcade wants that there should be some action on event x then she/he had put a script into the respective folder deliberatly. Without any script there is no action on any platform/arch although the event was fired.

                        Thanks.

                        1 Reply Last reply Reply Quote 0
                        • LolonoisL
                          Lolonois @Lolonois
                          last edited by

                          @jdrassa I am done with aligning my PR with yours. Changes include:

                          • renamed "DisplayOffTime" to "SystemSleepTime"
                          • Initially the SystemSleepTime is zero, thus off/no event fired. Once the user sets a value > 0 he/she gets a one time note to check the Retropie Wiki how to put events into user-action (i.e. providing a script in the appropriate folder).
                          • removed limitation to _RPI_

                          Now, for the tricky part: How to get it into the mainline?

                          I see these options:

                          • Wait until jdrassa's PR #551 is accepted, then push-force mine #550 to reflect my additions on top of jdrassa's PR.
                          • @jdrassa you may provide me write access to PR #551 so I could integrate my additions
                          • Some other option I am not aware of.

                          @BuZz et al: What is the suggested way the retropie repo owner do prefer?

                          Thanks.

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

                            IMHO you should have a separate PR building off @jdrassa's additions and force-push on your existing PR.

                            LolonoisL 1 Reply Last reply Reply Quote 0
                            • LolonoisL
                              Lolonois @mitu
                              last edited by

                              @mitu and all my PR 550 now integrates @jdrassa scripting framework/API PR 551.

                              Please see jdrassa's wiki page on the scripting support.

                              Additions to PR 551 from jdrassa include:

                              1. added GUI to configure time when station enters "sleep" state when no user interaction
                              2. only honor executable scripts/binaries for event system calls
                              3. added extra events when screensaver starts and gets stopped (currently not yet documented in the wiki page above)

                              The events I focused on are:
                              screensaver-start fired on screensaver activation
                              screensaver-stop fired on screensaver deactivation
                              sleep fired when station is without user input for a specified time (see PR)
                              wake fired when station returns from sleep (i.e. user input)

                              For early access users:

                              git clone https://github.com/RetroPie/EmulationStation.git
                              cd EmulationStation
                              git fetch origin pull/550/head:event-scripting
                              git checkout event-scripting
                              cmake . && make
                              ./emulationstation --debug
                              

                              Please share your questions, suggestions, findings aso. here.

                              cyperghostC 1 Reply Last reply Reply Quote 2
                              • cyperghostC
                                cyperghost @Lolonois
                                last edited by cyperghost

                                @Lolonois said in Early Access: Scripting and Display Off / Energy Saving Feature:

                                screensaver-start fired on screensaver activation
                                screensaver-stop fired on screensaver deactivation
                                sleep fired when station is without user input for a specified time (see PR)
                                wake fired when station returns from sleep (i.e. user input)

                                The ScreenSaver Options are very usefull. Is it intended to work on all ScreenSavers (DIM, Black Screen, Video and Picture) if this works on all I think I'll write a small script for the video collections @Malixx ... they can be found here and then the videos files do not need to be linked to gameslists and can work as own module ;)

                                1 Reply Last reply Reply Quote 2
                                • LolonoisL
                                  Lolonois
                                  last edited by

                                  @cyperghost said in Early Access: Scripting and Display Off / Energy Saving Feature:

                                  Is it intended to work on all ScreenSavers ?

                                  Yes. No distinction between type of screensaver (video, slideshow, dim, blank). Currently the type is not passed as argument for a script.

                                  1 Reply Last reply Reply Quote 0
                                  • LolonoisL
                                    Lolonois
                                    last edited by Lolonois

                                    Update: Please use PR 560 (note the 6) from now on for testing. Needed to reapply PR since fork and upstream diverted too much. So:

                                    git clone --recursive https://github.com/RetroPie/EmulationStation.git
                                    cd EmulationStation
                                    git fetch origin pull/560/head:event-scripting
                                    git checkout event-scripting
                                    cmake . && make
                                    ./emulationstation --debug
                                    
                                    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.