Add feels-like temperature display
parent
7ace5bd00d
commit
ea88529858
|
|
@ -11,7 +11,7 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
|
||||||
{type: "h", filly: 0, c: [
|
{type: "h", filly: 0, c: [
|
||||||
{type: "v", width: g.getWidth()/2, c: [ // Vertical container for icon + UV
|
{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",
|
{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",
|
{type: "custom", fillx: 1, height: 20, id: "uvDisplay",
|
||||||
render: l => {
|
render: l => {
|
||||||
if (!current || current.uv === undefined) return;
|
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
|
// Calculate centered position (4px block + 1px spacing) * blocks - last spacing
|
||||||
const totalW = labelW + uv * 5 - (uv > 0 ? 1 : 0);
|
const totalW = labelW + uv * 5 - (uv > 0 ? 1 : 0);
|
||||||
const x = l.x + (l.w - totalW) / 2;
|
const x = l.x + (l.w - totalW) / 2;
|
||||||
const y = l.y + l.h;
|
const y = l.y + l.h+6;
|
||||||
|
|
||||||
// Draw label
|
// Draw label
|
||||||
g.setColor(g.theme.fg).drawString(label, x, y);
|
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: [
|
{type: "v", fillx: 1, c: [
|
||||||
|
{pad:5},
|
||||||
{type: "h", pad: 2, c: [
|
{type: "h", pad: 2, c: [
|
||||||
{type: "txt", font: "18%", id: "temp", label: "000"},
|
{type: "txt", font: "18%", id: "temp", label: "000"},
|
||||||
{type: "txt", font: "12%", valign: -1, id: "tempUnit", label: "°C"},
|
{type: "txt", font: "12%", valign: -1, id: "tempUnit", label: "°C"},
|
||||||
]},
|
]},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "txt", font: "6x8", pad: 2, halign: 1, label: /*LANG*/"Humidity"},
|
{type: "h", pad: 1, c: [
|
||||||
{type: "txt", font: "9%", pad: 2, halign: 1, id: "hum", label: "000%"},
|
{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},
|
{filly: 1},
|
||||||
{type: "txt", font: "6x8", pad: 2, halign: -1, label: /*LANG*/"Wind"},
|
{type: "txt", font: "6x8", pad: 2, halign: -1, label: /*LANG*/"Wind"},
|
||||||
{type: "h", halign: -1, c: [
|
{type: "h", halign: -1, c: [
|
||||||
|
|
@ -59,7 +68,7 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
|
||||||
]},
|
]},
|
||||||
]},
|
]},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "txt", font: "9%", wrap: true, height: g.getHeight()*0.18, fillx: 1, id: "cond", label: /*LANG*/"Weather condition"},
|
{type: "txt", font: "9%",wrap: true, height: g.getHeight()*0.18, fillx: 1, id: "cond", label: /*LANG*/"Weather condition"},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "h", c: [
|
{type: "h", c: [
|
||||||
{type: "txt", font: "6x8", pad: 4, id: "loc", label: "Toronto"},
|
{type: "txt", font: "6x8", pad: 4, id: "loc", label: "Toronto"},
|
||||||
|
|
@ -81,8 +90,15 @@ function draw() {
|
||||||
layout.icon.txt = current.txt;
|
layout.icon.txt = current.txt;
|
||||||
layout.icon.code = current.code;
|
layout.icon.code = current.code;
|
||||||
const temp = locale.temp(current.temp-273.15).match(/^(\D*\d*)(.*)$/);
|
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.temp.label = temp[1];
|
||||||
layout.tempUnit.label = temp[2];
|
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+"%";
|
layout.hum.label = current.hum+"%";
|
||||||
const wind = locale.speed(current.wind).match(/^(\D*\d*)(.*)$/);
|
const wind = locale.speed(current.wind).match(/^(\D*\d*)(.*)$/);
|
||||||
layout.wind.label = wind[1];
|
layout.wind.label = wind[1];
|
||||||
|
|
@ -140,4 +156,4 @@ Bangle.setUI("clock");
|
||||||
// This matters for widgets that hide themselves for clocks, like widclk or widclose
|
// This matters for widgets that hide themselves for clocks, like widclk or widclose
|
||||||
delete Bangle.CLOCK;
|
delete Bangle.CLOCK;
|
||||||
|
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue