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.jsThis library is used in MMM-Assistant2Display
single node routine for managing your screen
Installation
npm install @bugsounet/screenSample 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: returntrueifscreenmain script with count down is runninglocked: returntrueifscreenfunction is lockedpower: returntrueif your display is On
{ running: true, locked: false, power: true }detectorControl [optional]
require @bugsounet/snowboy or compatible
requiredetectorSleepingand only work withactivate()orstart()functionSNOWBOY_START- return notification for start your detectorSNOWBOY_STOP- return notification for stop your detector
governorControl [optional]
require @bugsounet/governor
requiregovernorSleepingand 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
trueFunctions
activate(): activate mainscreenscript with count down (use it with first use)
it force turn on display when escape the script (ctl + c)start(): startscreenscript with count downstop(): stopscreenscriptreset(): 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.
wantedvalue is boolean:true: turn on screenfalse: turn off screen
setPowerDisplay(set): likewantedPowerDisplay()but you force to apply it
setvalue is boolean:true: force turn on screenfalse: force turn off screen
state(): return state ofscreenin object
Notes
turnOffDisplaywork only withactivate()orstart()function- you can use only
wantedPowerDisplay()orsetPowerDisplay()without main script !
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login