From 6b5ac04498830b74c59bdc7b6420182eeab55d39 Mon Sep 17 00:00:00 2001 From: Mike McGann Date: Tue, 27 Jun 2023 16:06:45 -0400 Subject: [PATCH] fix time flickering when frame is first displayed --- server/scripts/modules/weatherdisplay.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/scripts/modules/weatherdisplay.mjs b/server/scripts/modules/weatherdisplay.mjs index 543d675..aeb6d80 100644 --- a/server/scripts/modules/weatherdisplay.mjs +++ b/server/scripts/modules/weatherdisplay.mjs @@ -151,6 +151,7 @@ class WeatherDisplay { drawCanvas() { // clean up the first-run flag in screen index if (this.screenIndex < 0) this.screenIndex = 0; + if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime(); } finishDraw() { @@ -159,14 +160,13 @@ class WeatherDisplay { this.drawCurrentDateTime(); // auto clock refresh if (!this.dateTimeInterval) { - setInterval(() => this.drawCurrentDateTime(), 100); + // only draw if canvas is active to conserve battery + setInterval(() => this.active && this.drawCurrentDateTime(), 100); } } } drawCurrentDateTime() { - // only draw if canvas is active to conserve battery - if (!this.active) return; // Get the current date and time. const now = DateTime.local().setZone(timeZone());