Cleanup icon preload

This commit is contained in:
Matt Walsh 2020-09-23 14:10:25 -05:00
parent 77c0744cb3
commit 37eb88a90d
5 changed files with 35 additions and 11 deletions

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -21,9 +21,37 @@ class Almanac extends WeatherDisplay {
this.backgroundImage = utils.image.load('images/BackGround3_1.png');
}
getData(weatherParameters) {
async getData(weatherParameters) {
super.getData();
// get images for outlook
const imagePromises = [
utils.image.load('https://www.cpc.ncep.noaa.gov/products/predictions/30day/off14_temp.gif'),
utils.image.load('https://www.cpc.ncep.noaa.gov/products/predictions/30day/off14_prcp.gif'),
];
// get sun/moon data
const {sun, moon} = this.calcSunMoonData(weatherParameters);
// process images for outlook
const [outlookTemp, outlookPrecip] = await Promise.all(imagePromises);
console.log(outlookTemp,outlookPrecip);
const outlook = 1;
// store the data
this.data = {
sun,
moon,
outlook,
};
// draw the canvas
this.drawCanvas();
}
calcSunMoonData(weatherParameters) {
const {DateTime} = luxon;
const sun = [
@ -53,14 +81,10 @@ class Almanac extends WeatherDisplay {
iterations++;
} while (iterations <= 30 && moon.length < 4);
// store the data
this.data = {
return {
sun,
moon,
};
// draw the canvas
this.drawCanvas();
}
// get moon transition from one phase to the next by drilling down by hours, minutes and seconds

View file

@ -43,7 +43,7 @@ class CurrentWeather extends WeatherDisplay {
return;
}
// preload the icon
utils.image.preload(icons.getWeatherIconFromIconLink(observations.iconPath));
utils.image.preload(icons.getWeatherIconFromIconLink(observations.features[0].properties.icon));
// we only get here if there was no error above
this.data = Object.assign({}, observations, {station: station});
@ -67,7 +67,7 @@ class CurrentWeather extends WeatherDisplay {
let WindChill = Math.round(observations.windChill.value);
let WindGust = Math.round(observations.windGust.value);
let Humidity = Math.round(observations.relativeHumidity.value);
const Icon = icons.getWeatherIconFromIconLink(observations.iconPath);
const Icon = icons.getWeatherIconFromIconLink(observations.icon);
let PressureDirection = '';
const TextConditions = observations.textDescription;

View file

@ -1 +1 @@
module.exports = '3.1.2';
module.exports = '3.1.3';