code cleanup

This commit is contained in:
Matt Walsh 2022-03-01 16:19:08 -06:00
parent 89d722d313
commit 650ace0edb
4 changed files with 31 additions and 26 deletions

View file

@ -22,6 +22,12 @@ module.exports = {
'no-tabs': 0, 'no-tabs': 0,
'no-console': 0, 'no-console': 0,
'max-len': 0, 'max-len': 0,
'no-use-before-define': [
'error',
{
variables: false,
},
],
'no-mixed-operators': [ 'no-mixed-operators': [
'error', 'error',
{ {

View file

@ -247,6 +247,27 @@ class Almanac extends WeatherDisplay {
const [FullMoonImage, LastMoonImage, NewMoonImage, FirstMoonImage] = await Promise.all(this.moonImages); const [FullMoonImage, LastMoonImage, NewMoonImage, FirstMoonImage] = await Promise.all(this.moonImages);
switch (this.screenIndex) { switch (this.screenIndex) {
case 1: {
this.context.drawImage(await this.backgroundImage1, 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);
draw.horizontalGradientSingle(this.context, 0, 90, 52, 399, draw.sideColor1, draw.sideColor2);
draw.horizontalGradientSingle(this.context, 584, 90, 640, 399, draw.sideColor1, draw.sideColor2);
draw.titleText(this.context, 'Almanac', 'Outlook');
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 180, '30 Day Outlook', 2, 'center');
const DateRange = `MID-${info.outlook.thisMonth.toUpperCase()} TO MID-${info.outlook.nextMonth.toUpperCase()}`;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 220, DateRange, 2, 'center');
const Temperature = info.outlook.temperature;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 300, `Temperatures: ${Temperature}`, 2);
const Precipitation = info.outlook.precipitation;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 380, `Precipitation: ${Precipitation}`, 2);
break;
}
case 0: case 0:
default: default:
// sun and moon data // sun and moon data
@ -292,27 +313,6 @@ class Almanac extends WeatherDisplay {
this.context.drawImage(image, 75 + Index * 130, 270); this.context.drawImage(image, 75 + Index * 130, 270);
}); });
break; break;
case 1: {
this.context.drawImage(await this.backgroundImage1, 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);
draw.horizontalGradientSingle(this.context, 0, 90, 52, 399, draw.sideColor1, draw.sideColor2);
draw.horizontalGradientSingle(this.context, 584, 90, 640, 399, draw.sideColor1, draw.sideColor2);
draw.titleText(this.context, 'Almanac', 'Outlook');
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 180, '30 Day Outlook', 2, 'center');
const DateRange = `MID-${info.outlook.thisMonth.toUpperCase()} TO MID-${info.outlook.nextMonth.toUpperCase()}`;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 220, DateRange, 2, 'center');
const Temperature = info.outlook.temperature;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 300, `Temperatures: ${Temperature}`, 2);
const Precipitation = info.outlook.precipitation;
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 380, `Precipitation: ${Precipitation}`, 2);
}
} }
this.finishDraw(); this.finishDraw();

View file

@ -74,7 +74,6 @@ const draw = (() => {
context.strokeRect(x, y, width, height); context.strokeRect(x, y, width, height);
}; };
// TODO: implement full themes support
const theme = 1; // classic const theme = 1; // classic
const topColor1 = 'rgb(192, 91, 2)'; const topColor1 = 'rgb(192, 91, 2)';
const topColor2 = 'rgb(72, 34, 64)'; const topColor2 = 'rgb(72, 34, 64)';

View file

@ -36,9 +36,9 @@ class Radar extends WeatherDisplay {
this.backgroundImage = utils.image.load('images/BackGround4_1.png'); this.backgroundImage = utils.image.load('images/BackGround4_1.png');
} }
async getData(weatherParameters) { async getData(_weatherParameters) {
super.getData(weatherParameters); super.getData(_weatherParameters);
if (!weatherParameters) weatherParameters = this.weatherParameters; const weatherParameters = _weatherParameters ?? this.weatherParameters;
// ALASKA AND HAWAII AREN'T SUPPORTED! // ALASKA AND HAWAII AREN'T SUPPORTED!
if (weatherParameters.state === 'AK' || weatherParameters.state === 'HI') { if (weatherParameters.state === 'AK' || weatherParameters.state === 'HI') {
@ -154,7 +154,7 @@ class Radar extends WeatherDisplay {
minute, minute,
}, { }, {
zone: 'UTC', zone: 'UTC',
}); }).setZone();
} else { } else {
time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone(); time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone();
} }