From 6a079a5076e5f5f75b571e1dd46744d2e02736f9 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Fri, 4 Sep 2020 13:38:58 -0500 Subject: [PATCH] fix current conditions close #3 --- server/scripts/modules/currentweather.js | 23 ++++++++++++----------- server/scripts/modules/weatherdisplay.js | 10 +++++++--- ws4kp.code-workspace | 3 ++- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/server/scripts/modules/currentweather.js b/server/scripts/modules/currentweather.js index a9e2edd..7a6ef31 100644 --- a/server/scripts/modules/currentweather.js +++ b/server/scripts/modules/currentweather.js @@ -91,17 +91,6 @@ class CurrentWeather extends WeatherDisplay { WindGust = utils.units.kphToMph(WindGust); } - // get main icon - this.gifs.push(await utils.image.superGifAsync({ - src: Icon, - loop_delay: 100, - auto_play: true, - canvas: this.canvas, - x: 140, - y: 175, - max_width: 126, - })); - this.context.drawImage(await this.backgroundImage, 0, 0); draw.horizontalGradientSingle(this.context, 0, 30, 500, 90, draw.topColor1, draw.topColor2); draw.triangle(this.context, 'rgb(28, 10, 87)', 500, 30, 450, 90, 500, 90); @@ -177,6 +166,18 @@ class CurrentWeather extends WeatherDisplay { draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 365, 'Wind Chill:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 365, WindChill + String.fromCharCode(176), 2, 'right'); } + + // get main icon + this.gifs.push(await utils.image.superGifAsync({ + src: Icon, + loop_delay: 100, + auto_play: true, + canvas: this.canvas, + x: 140, + y: 175, + max_width: 126, + })); + this.finishDraw(); this.setStatus(STATUS.loaded); } diff --git a/server/scripts/modules/weatherdisplay.js b/server/scripts/modules/weatherdisplay.js index b68a0a6..822a7b5 100644 --- a/server/scripts/modules/weatherdisplay.js +++ b/server/scripts/modules/weatherdisplay.js @@ -91,7 +91,7 @@ class WeatherDisplay { if (this.elemId === 'almanacTides') OkToDrawNoaaImage = false; if (this.elemId === 'outlook') OkToDrawNoaaImage = false; if (this.elemId === 'marineForecast')OkToDrawNoaaImage = false; - if (this.elemId === 'airQuailty') OkToDrawNoaaImage = false; + if (this.elemId === 'airQuality') OkToDrawNoaaImage = false; if (this.elemId === 'travelForecast') OkToDrawNoaaImage = false; if (this.elemId === 'regionalForecast1')OkToDrawNoaaImage = false; if (this.elemId === 'regionalForecast2') OkToDrawNoaaImage = false; @@ -135,7 +135,11 @@ class WeatherDisplay { // on the first pass store the background for the date and time if (!this.dateTimeBackground) { - this.dateTimeBackground = this.context.getImageData(410, 30, 175, 60); + const bg = this.context.getImageData(410, 30, 175, 60); + // test background draw complete and skip drawing if there is no background yet + if (bg.data[0] === 0) return; + // store the background + this.dateTimeBackground = bg; } // Clear the date and time area. @@ -212,7 +216,7 @@ class WeatherDisplay { // reset timing this.startNavCount(navigation.isPlaying()); - // refresh the canvas (incase the screen index chagned) + // refresh the canvas (incase the screen index changed) if (navCmd) this.drawCanvas(); } hideCanvas() { diff --git a/ws4kp.code-workspace b/ws4kp.code-workspace index dffd883..7319de0 100644 --- a/ws4kp.code-workspace +++ b/ws4kp.code-workspace @@ -7,7 +7,8 @@ "settings": { "cSpell.enabled": true, "cSpell.words": [ - "Battaglia" + "Battaglia", + "Noaa" ], } } \ No newline at end of file