smart-mirror icon indicating copy to clipboard operation
smart-mirror copied to clipboard

Make the screen actually turn off via annyang.

Open SenadM opened this issue 10 years ago • 10 comments

Saving a lot of electricity!

SenadM avatar Jan 29 '16 21:01 SenadM

Best case scenario here we stop outputting video signal out of HDMI. Depending on the monitor this may trigger a power saving "standby" mode, some models even have a configurable "standby" mode - you can never actually turn the monitor without the addition of some hardware.

I haven't been able to test this yet, but theoretically you can do this with

/opt/vc/bin/tvservice -p && /opt/vc/bin/tvservice -o

and wake it up with

/opt/vc/bin/tvservice -p && chvt 1 && chvt 7

evancohen avatar Jan 30 '16 00:01 evancohen

I've tested this and it works. My monitor is going into power saving mode.

I put this code in header of index.html (there might be a better place for this?)

<script>
// http://nodejs.org/api.html#_child_processes
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
</script>

and in controller.js I add the following to go to sleep command exec("/opt/vc/bin/tvservice -p && /opt/vc/bin/tvservice -o", puts); and the following to wake up command exec("/opt/vc/bin/tvservice -p && chvt 1 && chvt 7", puts);

mrtruebeliever avatar Feb 16 '16 20:02 mrtruebeliever

@mrtruebeliever, looks good. I have tried this as well and seems to be working quite nicely. I wrapped that code in a try catch so during development on my main machine it would be handled nicely when exec() doesn't exist.

      try
      {
        // http://nodejs.org/api.html#_child_processes
        var sys = require('sys')
        var exec = require('child_process').exec;
        function puts(error, stdout, stderr) { sys.puts(stdout) }
      }
      catch(err) {
        function puts(error, stdout, stderr){}
        function exec(arg1, arg2){}
      }

therealgambo avatar Mar 03 '16 06:03 therealgambo

Can someone make a pull request if it is done?

SenadM avatar Mar 03 '16 15:03 SenadM

I'm happy to add it in my PR (https://github.com/evancohen/smart-mirror/pull/121), as I already have it working on my local branch. If no body objects to this, I will update that in roughly 6-7hrs.

therealgambo avatar Mar 03 '16 23:03 therealgambo

@missionrulz please add it to a new PR. It will make it easier to review.

evancohen avatar Mar 04 '16 00:03 evancohen

Is this actually implemented? I downloaded the version from about a week ago, but I don't have the above references in controller.js nor index.html.

gnurph69 avatar Jul 04 '16 02:07 gnurph69

@gnurph69 you need to be using the dev branch.

evancohen avatar Jul 04 '16 02:07 evancohen

When will this be merged with master?

SenadM avatar Sep 27 '16 21:09 SenadM

@SenadM #128 is already in master, I think I just forgot to close this issue. For reference, the file that does the legwork here is autosleep.js

evancohen avatar Sep 28 '16 01:09 evancohen