Skip to content

Commit 29a3614

Browse files
author
thyttan
committed
Merge remote-tracking branch 'stweedo/weather-ios' into app-loader
2 parents 4123049 + ed989ee commit 29a3614

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

apps/weather/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
0.23: Update clock_info to avoid a redraw
2323
0.24: Redraw clock_info on update and provide color field for condition
2424
0.25: Added monochrome parameter to drawIcon in lib
25-
0.26: Expose update function (for use by iOS integration)
25+
0.26: Expose update function (for use by iOS integration)
26+
0.27: Add UV index display

apps/weather/app.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,43 @@ let current = weather.get();
55

66
Bangle.loadWidgets();
77

8+
89
var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
910
{filly: 1},
1011
{type: "h", filly: 0, c: [
11-
{type: "custom", width: g.getWidth()/2, height: g.getWidth()/2, valign: -1, txt: "unknown", id: "icon",
12-
render: l => weather.drawIcon(l, l.x+l.w/2, l.y+l.h/2, l.w/2-5)},
12+
{type: "v", width: g.getWidth()/2, c: [ // Vertical container for icon + UV
13+
{type: "custom", fillx: 1, height: g.getHeight()/2 - 30, valign: -1, txt: "unknown", id: "icon",
14+
render: l => weather.drawIcon(l, l.x+l.w/2, l.y+l.h/2, l.w/2-10)},
15+
{type: "custom", fillx: 1, height: 20, id: "uvDisplay",
16+
render: l => {
17+
if (!current || current.uv === undefined) return;
18+
const uv = Math.min(parseInt(current.uv), 11); // Cap at 11
19+
20+
// UV color thresholds: [max_value, color] based on WHO standards
21+
const colors = [[2,"#0F0"], [5,"#FF0"], [7,"#F80"], [10,"#F00"], [11,"#F0F"]];
22+
const color = colors.find(c => uv <= c[0])[1];
23+
24+
// Setup and measure label
25+
g.setFont("6x8").setFontAlign(-1, 0);
26+
const label = "UV: ";
27+
const labelW = g.stringWidth(label);
28+
29+
// Calculate centered position (4px block + 1px spacing) * blocks - last spacing
30+
const totalW = labelW + uv * 5 - (uv > 0 ? 1 : 0);
31+
const x = l.x + (l.w - totalW) / 2;
32+
const y = l.y + l.h;
33+
34+
// Draw label
35+
g.setColor(g.theme.fg).drawString(label, x, y);
36+
37+
// Draw UV blocks
38+
g.setColor(color);
39+
for (let i = 0; i < uv; i++) {
40+
g.fillRect(x + labelW + i * 5, y - 3, x + labelW + i * 5 + 3, y + 3);
41+
}
42+
}
43+
},
44+
]},
1345
{type: "v", fillx: 1, c: [
1446
{type: "h", pad: 2, c: [
1547
{type: "txt", font: "18%", id: "temp", label: "000"},
@@ -108,4 +140,4 @@ Bangle.setUI("clock");
108140
// This matters for widgets that hide themselves for clocks, like widclk or widclose
109141
delete Bangle.CLOCK;
110142

111-
Bangle.drawWidgets();
143+
Bangle.drawWidgets();

apps/weather/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "weather",
33
"name": "Weather",
4-
"version": "0.26",
4+
"version": "0.27",
55
"description": "Show Gadgetbridge/iOS weather report",
66
"icon": "icon.png",
77
"screenshots": [{"url":"screenshot.png"}],

0 commit comments

Comments
 (0)