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

[Merged] Power Saver feature

Scheduled Pinned Locked Moved Ideas and Development
emulationstatiotestingpowersaver
164 Posts 10 Posters 62.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.
  • H
    Hex
    last edited by Hex 8 Nov 2017, 23:03 30 Jun 2017, 02:44

    NOTE: As of 6th Aug there were some bugs that were noticed and are actively being removed. As of 10th Aug the bugs are squashed. Will be merged in a couple of days Merged as of v2.5.2

    Hello guys, need your help in testing power saver functionality for ES. I shall also post compiled binaries later for all RPi s.

    PR submitted : https://github.com/RetroPie/EmulationStation/pull/172
    Repository : http://github.com/hex007/EmulationStation
    branch : feature-powersaver
    Latest Binary : https://retropie.org.uk/forum/topic/11304/testers-needed-power-saver-features-pr-172/153

    • Enable the feature in: OtherSettings > Enable Power Savings Is Enabled by default now
    • Dim and blank screensavers aren't triggered if PS enaled. All screensavers work nicely with PS
    • PS is disabled if you have video screensaver enabled which works. PS works dynamically with VS giving you best power savings
    • PS is disabled when you are on the gamelist which has videos.
    • PS can be forced on such gamelist by changing views to "Detail" instead of "Video" or "Automatic"

    You can use @meleu 's tool to compile if you cannot wait till I upload binaries. I shall also be accepting binaries from testers so if you were able to compile it then i can post it.

    Raspberry pi 1/Zero/ZeroW : https://www.dropbox.com/s/o7v4ohrud8ugsyv/emulationstation_feature_powersaver?dl=0
    Raspberry pi 2/3 : URL

    Sent from 20,000 leagues under the sea.

    Powersaver Emulation station : https://github.com/hex007/EmulationStation
    ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

    M 1 Reply Last reply 30 Jun 2017, 03:01 Reply Quote 5
    • M
      meleu @Hex
      last edited by meleu 30 Jun 2017, 03:01

      @Hex Sorry, but I didn't get what's the purpose of that video... What are you trying to show?

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      1 Reply Last reply Reply Quote 1
      • H
        Hex
        last edited by 30 Jun 2017, 03:04

        The video is just to show that it works well with Video Previews. Status is shown at the bottom where ES version is shown. Hence the constant opening of Menu

        Sent from 20,000 leagues under the sea.

        Powersaver Emulation station : https://github.com/hex007/EmulationStation
        ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

        M 1 Reply Last reply 30 Jun 2017, 03:07 Reply Quote 0
        • M
          meleu @Hex
          last edited by 30 Jun 2017, 03:07

          @Hex What's that MUSIC PLAYER option in MAIN MENU? I don't see that in the official branch.

          • Useful topics
          • joystick-selection tool
          • rpie-art tool
          • achievements I made
          1 Reply Last reply Reply Quote 1
          • H
            Hex
            last edited by 30 Jun 2017, 03:10

            @meleu That is my implementation of an interface with an audio player for background music. Feel free to test that too. The python server backend is in audio-server folder of my master branch

            Sent from 20,000 leagues under the sea.

            Powersaver Emulation station : https://github.com/hex007/EmulationStation
            ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

            M 1 Reply Last reply 30 Jun 2017, 03:14 Reply Quote 0
            • M
              meleu @Hex
              last edited by 30 Jun 2017, 03:14

              @Hex Oh, I got it.

              I just think that a video showing the exact version you're willing to see merged into the official branch should be a better illustration. :-)

              By the way, what exactly the Power Saving feature do to save power?

              • Useful topics
              • joystick-selection tool
              • rpie-art tool
              • achievements I made
              1 Reply Last reply Reply Quote 0
              • H
                Hex
                last edited by Hex 30 Jun 2017, 03:20

                @meleu In ES there is a loop that receives key presses/events. The most cpu intensive is a infinite while loop. I have modified it to wait for events rather than checking for event every cycle. It dynamically switches between polling and waiting for a great feature. The rest of the commit is just for wrapping and interfacing.

                For the exact location of this feature : https://github.com/RetroPie/EmulationStation/pull/172/files#diff-0d7037121f70d0897714deabb3ea71e1R302

                Sent from 20,000 leagues under the sea.

                Powersaver Emulation station : https://github.com/hex007/EmulationStation
                ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                M C Z 3 Replies Last reply 30 Jun 2017, 03:29 Reply Quote 1
                • M
                  meleu @Hex
                  last edited by meleu 30 Jun 2017, 03:29

                  @Hex Looks like the most elegant approach than the infinite while loop. Is there any disadvantage in making PS enabled by default?

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  1 Reply Last reply Reply Quote 0
                  • H
                    Hex
                    last edited by 30 Jun 2017, 03:36

                    No there isnt and disadvantage but it is currently in testing so I have added a switch to enable and disable it. When it is ready after testing then I can enable it by default.

                    Sent from 20,000 leagues under the sea.

                    Powersaver Emulation station : https://github.com/hex007/EmulationStation
                    ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                    M 1 Reply Last reply 30 Jun 2017, 03:54 Reply Quote 2
                    • M
                      meleu @Hex
                      last edited by 30 Jun 2017, 03:54

                      @Hex it somehow reminded me the Observer Pattern when I was studying Design Patterns back in 2009. :-)

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      1 Reply Last reply Reply Quote 0
                      • C
                        cyperghost @Hex
                        last edited by cyperghost 30 Jun 2017, 07:00

                        @Hex I like your build very much.

                        In ES there is a loop that receives key presses/events.

                        I guessed that... I already told @pjft and you (??) in this thread. Why is there a loop wating for key events? Triggers to interrupts are a good way avoiding this. So you hunted that nasty workaround down :D

                        I have a "wish" to the Music Player.... Would it not be better to use mpg123 instead OMX Player? Just for background? The intention is following. OMXPlayer is already used for video playback and video preview. To have an independent process use an independent software just for background. MPG123 gots only 2% CPU usage. The control is just easy and you don't need a python backend.

                        STOP/PLAY ... even restart can be done by script (or if you develop ES in C++ there are much more options I guess)

                        Start/Stop Toogle, Start if mpg123 isn't started.sh

                        #!/bin/bash
                        #Toggle MPG123 Music Player to mute/unmute condition
                        #Simple by checking running PID and sent -STOP or -CONT term
                        #Is no PID of MPG123 is available it will be launched
                        command="mpg123"
                        pids="$( pgrep "$command" )"
                        if [[ -z "$pids" ]]; then
                        "$command" -Z /media/usb0/BGM/*.mp3 >/dev/null 2>&1 &
                        exit 0
                        fi
                        for pid in $pids; do
                        state="$( ps -ostate= -p "$pid" )"
                        stopped=0
                        case "$state" in
                        *T*) stopped=1 ;;
                        esac
                        if (( stopped )); then
                        kill -s CONT "$pid" >/dev/null 2>&1
                        # printf '"%s" (%d) has been unpaused\n' "$command" "$pid"
                        else
                        kill -s STOP "$pid" >/dev/null 2>&1
                        # printf '"%s" (%d) has been paused\n' "$command" "$pid"
                        fi
                        done

                        The Next Track command is simply
                        It kills mpg123 and restart it again in random mode ... so you randomly got BGM music. Hey... It's a decent ( @Hex - what the hell is your background song?) background music and not your sisters beloved POP album :D

                        #!/bin/bash
                        #This changes track by killing musicplayer
                        #and reloading it
                        pkill mpg123 >/dev/null 2>&1
                        sleep 1
                        mpg123 -Z /media/usb0/BGM/*.mp3 >/dev/null 2>&1 &

                        STOP

                        #!/bin/bash
                        #This STOPs musicplayer
                        pkill -STOP mpg123

                        CONTINUE

                        #!/bin/bash
                        #This STOPs musicplayer
                        pkill -CONT mpg123

                        Even we can using BGM in gameplay via User Menu

                        #!/bin/bash
                        #This STOPs musicplayer
                        pkill -CONT mpg123; exit 2
                        1 Reply Last reply Reply Quote 1
                        • Z
                          Zigurana @Hex
                          last edited by 30 Jun 2017, 07:09

                          @Hex Hi, did you do any power consumption profiling with PS enabled/disabled?
                          I am wondering how much this actually saves in terms of power consumption.

                          I think one way to do it would be through one of those usb-power consumption doodaa's, but they might not be precise enough.
                          In any case, this is very relevant to my interests, with the RaspiBoy coming up soon!

                          If tetris has thought me anything, it's that errors pile up and that accomplishments dissappear.

                          C 1 Reply Last reply 30 Jun 2017, 07:13 Reply Quote 0
                          • C
                            cyperghost @Zigurana
                            last edited by 30 Jun 2017, 07:13

                            @Zigurana May you test out please?

                            The CPU usages are triggered in this thread
                            https://retropie.org.uk/forum/topic/11178/emulationstation-cpu-usage

                            It's a the STANDARD ES for RetroPie 4.2
                            We ( @Sano and me) used top for CPU usage measurement

                            SanoS 1 Reply Last reply 30 Jun 2017, 07:21 Reply Quote 0
                            • SanoS
                              Sano @cyperghost
                              last edited by Sano 30 Jun 2017, 07:21

                              @cyperghost
                              I also used pidstat (part of sysstat package) that monitors the CPU usage of a single PID :)
                              @Zigurana
                              you may try powerstat or powertop

                              1 Reply Last reply Reply Quote 1
                              • H
                                Hex
                                last edited by 30 Jun 2017, 07:48

                                @cyperghost I wrote the server in 2012 when Raspberry pi 1 was released. I had the source code and it was well designed enough that it didnt take long for me to write an interface. The best feature is that all control requests silently fail if backend is not running. The Music player is very advanced with a websockets server support already coded into the backend thus if a day comes to incorporate a full fledged MusicPlayer it would be a breeze.

                                Sent from 20,000 leagues under the sea.

                                Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                C 1 Reply Last reply 1 Jul 2017, 12:51 Reply Quote 1
                                • H
                                  Hex
                                  last edited by 30 Jun 2017, 07:49

                                  @Zigurana I dont have the USB doctor device so I cannot test it. Someone else can if they have one.

                                  Sent from 20,000 leagues under the sea.

                                  Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                  ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    cyperghost @Hex
                                    last edited by cyperghost 7 Jan 2017, 13:52 1 Jul 2017, 12:51

                                    @Hex Sorry I missed your post!
                                    Yes the phython backend works surely fine but it is a script that has to be configurated. That's my main misgiving or may I am wrong? I think easy access can be givento users by a standarized playlist location and in this playlist all songs from different locations can be stored...

                                    Sorry for being inconvinient :)

                                    About your PR... can you give us a compiles binary please?

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Hex
                                      last edited by 1 Jul 2017, 17:12

                                      @cyperghost I shall provide binaries for Pi 1/Zero only. Pi3 is fast enough to compile in 10 mins and I dont have an sdcard for it :(

                                      There is no configuration needed. Plays audio from all files including videos downloaded from youtube. It can be controlled from android app too if needed (needs extended version).
                                      On the backend it uses Aplay and avconv which are both available on the raspbian/retropie

                                      Sent from 20,000 leagues under the sea.

                                      Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                      ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Hex
                                        last edited by 2 Jul 2017, 04:17

                                        Pi zero/1 binary is now available. It has two modifications done to the main branch.

                                        • Power saver mod
                                        • Wide menu mod (for my 3.5inch display)

                                        The wide menu mod should not interfere with any other functionality.

                                        Sent from 20,000 leagues under the sea.

                                        Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                        ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                        1 Reply Last reply Reply Quote 1
                                        • C
                                          cyperghost
                                          last edited by cyperghost 7 Feb 2017, 10:55 2 Jul 2017, 09:47

                                          That was quick my results are following.
                                          0. I used top

                                          1. The mod seems to work
                                          2. I tested on a fresh 4.2 RPi0/1 image
                                          3. Non overclocked RPi0 attached with 1 WLAN Stick LogiLink, 1 Controller
                                          4. HDMI output

                                          My outfindings:

                                          Action                  ES branch       CPU usage
                                          --------------------------------------------------
                                          Reboot                  2.1.5RP         30-35%
                                          Select NES 12 Roms      2.1.5RP         65%
                                          Start Rom, back to ES   2.1.5RP         65%
                                          Screensaver DIM 1min    2.1.5RP         10-15%
                                          
                                          Reboot                  2.3.2RP PS off  40%
                                          Select NES 12 Roms      2.3.2RP PS off  67%
                                          
                                          Reboot                  2.3.2RP PS on   5-10%
                                          Select NES 12 Roms      2.3.2RP PS on   45%
                                          Select NES 12 Roms 5sec 2.3.2RP PS on   5-10%
                                          Start Rom, back to ES   2.3.2RP PS on   65%
                                          Start Rom, back ES 5sec 2.3.2RP PS on   5-10%
                                          

                                          Bugs

                                          Screensaver seem to be disabled in this mod ... but this is already told in "Info note"

                                          M 1 Reply Last reply 2 Jul 2017, 09:53 Reply Quote 1
                                          5 out of 164
                                          • First post
                                            5/164
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received