A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
[npm library] @bugsounet/screen
-
@bugsounet/screen
I created this library if you want to manage for screen in your module.
This library is very simplified and ready for use in yournode_helper.js
This library is used in MMM-Assistant2Display
single node routine for managing your screen
Installation
npm install @bugsounet/screen
Sample with screen contructor
const Screen = require("@bugsounet/screen") this.config = { delay: 10 * 1000, turnOffDisplay: true, ecoMode: true, displayCounter: true, detectorSleeping: true, governorSleeping: true, rpi4: false, linux: false } var debug = true this.screen = new Screen(this.config, callback, debug, detectorControl, governorControl) this.screen.start() setTimeout(() => { this.screen.state() } , 5 * 1000) setTimeout(() => { this.screen.stop() } , 15 * 1000) function callback(noti, value) { if (noti == "SCREEN_TIMER") console.log ("Turn off in", value) else console.log("Screen Notification:", noti) } function detectorControl(noti) { console.log("detectorControl Notification:", noti) } function governorControl(noti) { console.log("governorControl Notification:", noti) }
constructor of screen
Screen(screenConfig, callback, debug, detectorControl, governorControl)
screenConfig {}
delay
- Time before turns off the display. (in ms).turnOffDisplay
- Should the display turn off after timeout?ecoMode
- send a notification to hide all module after timeout?displayCounter
- send a notification with count-down before sleepingdetectorSleeping
- send a notification to manage detector when screen is offgovernorSleeping
- send a notification to manage governor when screen is offrpi4
- rpi4 support (use dpms)linux
- linux support (use dpms)
callback (notification,value)
SCREEN_TIMER
- Display the count down before sleeping mode (requiredisplayCounter
)SCREEN_SHOWING
- return notification for showing modules or other (requireecoMode
)SCREEN_HIDING
- return notification for hiding modules or other (requireecoMode
)SCREEN_STATE
- return object with actual screen state
object value:running
: returntrue
ifscreen
main script with count down is runninglocked
: returntrue
ifscreen
function is lockedpower
: returntrue
if your display is On
{ running: true, locked: false, power: true }
detectorControl [optional]
require @bugsounet/snowboy or compatible
requiredetectorSleeping
and only work withactivate()
orstart()
functionSNOWBOY_START
- return notification for start your detectorSNOWBOY_STOP
- return notification for stop your detector
governorControl [optional]
require @bugsounet/governor
requiregovernorSleeping
and only work withactivate()
orstart()
functionGOVERNOR_WORKING
- return notification to change your governor to working configurationGOVERNOR_SLEEPING
- return notification to change your governor to sleeping configuration
debug
if you want debuging information, just set to
true
Functions
activate()
: activate mainscreen
script with count down (use it with first use)
it force turn on display when escape the script (ctl + c)start()
: startscreen
script with count downstop()
: stopscreen
scriptreset()
: reset count downwakeup()
: wake up the screenlock()
: lock the screen (start/stop/reset/wakeup will be ignored)unlock()
: unlock the screenwantedPowerDisplay(wanted)
: comparate actual screen state and apply it if not set.
wanted
value is boolean:true
: turn on screenfalse
: turn off screen
setPowerDisplay(set)
: likewantedPowerDisplay()
but you force to apply it
set
value is boolean:true
: force turn on screenfalse
: force turn off screen
state()
: return state ofscreen
in object
Notes
turnOffDisplay
work only withactivate()
orstart()
function- you can use only
wantedPowerDisplay()
orsetPowerDisplay()
without main script !