Add feels-like temperature display

master
RKBoss6 2025-06-28 14:24:40 -04:00 committed by GitHub
parent 7ace5bd00d
commit ea88529858
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 6 deletions

View File

@ -11,7 +11,7 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
{type: "h", filly: 0, c: [
{type: "v", width: g.getWidth()/2, c: [ // Vertical container for icon + UV
{type: "custom", fillx: 1, height: g.getHeight()/2 - 30, valign: -1, txt: "unknown", id: "icon",
render: l => weather.drawIcon(l, l.x+l.w/2, l.y+l.h/2, l.w/2-10)},
render: l => weather.drawIcon(l, l.x+l.w/2, l.y+l.h/2.1, l.w/2.1-10)},
{type: "custom", fillx: 1, height: 20, id: "uvDisplay",
render: l => {
if (!current || current.uv === undefined) return;
@ -29,7 +29,7 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
// Calculate centered position (4px block + 1px spacing) * blocks - last spacing
const totalW = labelW + uv * 5 - (uv > 0 ? 1 : 0);
const x = l.x + (l.w - totalW) / 2;
const y = l.y + l.h;
const y = l.y + l.h+6;
// Draw label
g.setColor(g.theme.fg).drawString(label, x, y);
@ -43,13 +43,22 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
},
]},
{type: "v", fillx: 1, c: [
{pad:5},
{type: "h", pad: 2, c: [
{type: "txt", font: "18%", id: "temp", label: "000"},
{type: "txt", font: "12%", valign: -1, id: "tempUnit", label: "°C"},
]},
{filly: 1},
{type: "txt", font: "6x8", pad: 2, halign: 1, label: /*LANG*/"Humidity"},
{type: "h", pad: 1, c: [
{type: "txt", font: "6x8", pad: 2, halign: 1, label: /*LANG*/"Feels:"},
{type: "txt", font: "9%", pad: 2, halign: 1, id: "feelslike", label: "35°F"},
]},
{filly: 1},
{type: "h", pad: 2, c: [
{type: "txt", font: "6x8", pad: 2, halign: 1, label: /*LANG*/"Hum:"},
{type: "txt", font: "9%", pad: 2, halign: 1, id: "hum", label: "000%"},
]},
{filly: 1},
{type: "txt", font: "6x8", pad: 2, halign: -1, label: /*LANG*/"Wind"},
{type: "h", halign: -1, c: [
@ -81,8 +90,15 @@ function draw() {
layout.icon.txt = current.txt;
layout.icon.code = current.code;
const temp = locale.temp(current.temp-273.15).match(/^(\D*\d*)(.*)$/);
const feelsLikeTemp=locale.temp(current.feels-273.15).match(/^(\D*\d*)(.*)$/);
layout.temp.label = temp[1];
layout.tempUnit.label = temp[2];
if (!current || current.feels === undefined){
layout.feelslike.label = "N/A";
}else{
layout.feelslike.label = feelsLikeTemp[1]+feelsLikeTemp[2];
}
layout.hum.label = current.hum+"%";
const wind = locale.speed(current.wind).match(/^(\D*\d*)(.*)$/);
layout.wind.label = wind[1];