fix time flickering when frame is first displayed

This commit is contained in:
Mike McGann 2023-06-27 16:06:45 -04:00
parent 465fa5a99b
commit 6b5ac04498

View file

@ -151,6 +151,7 @@ class WeatherDisplay {
drawCanvas() { drawCanvas() {
// clean up the first-run flag in screen index // clean up the first-run flag in screen index
if (this.screenIndex < 0) this.screenIndex = 0; if (this.screenIndex < 0) this.screenIndex = 0;
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
} }
finishDraw() { finishDraw() {
@ -159,14 +160,13 @@ class WeatherDisplay {
this.drawCurrentDateTime(); this.drawCurrentDateTime();
// auto clock refresh // auto clock refresh
if (!this.dateTimeInterval) { if (!this.dateTimeInterval) {
setInterval(() => this.drawCurrentDateTime(), 100); // only draw if canvas is active to conserve battery
setInterval(() => this.active && this.drawCurrentDateTime(), 100);
} }
} }
} }
drawCurrentDateTime() { drawCurrentDateTime() {
// only draw if canvas is active to conserve battery
if (!this.active) return;
// Get the current date and time. // Get the current date and time.
const now = DateTime.local().setZone(timeZone()); const now = DateTime.local().setZone(timeZone());