diff --git a/apps.json b/apps.json
index 018f9a34d..7131c213a 100644
--- a/apps.json
+++ b/apps.json
@@ -845,7 +845,7 @@
{
"id": "weather",
"name": "Weather",
- "version": "0.13",
+ "version": "0.14",
"description": "Show Gadgetbridge weather report",
"icon": "icon.png",
"screenshots": [{"url":"screenshot.png"}],
diff --git a/apps/banglerun/interface.html b/apps/banglerun/interface.html
index 403f28258..6388d3b65 100644
--- a/apps/banglerun/interface.html
+++ b/apps/banglerun/interface.html
@@ -68,7 +68,7 @@ ${track.map(pt=>` ${pt.distance}\n`).join("")}
function saveGPX(track, title) {
var gpx = `
-
+
diff --git a/apps/recorder/interface.html b/apps/recorder/interface.html
index 42aa4e16d..0535b2d51 100644
--- a/apps/recorder/interface.html
+++ b/apps/recorder/interface.html
@@ -16,7 +16,7 @@ function saveKML(track,title) {
${track[0].Heartrate!==undefined ? `
Heart Rate
- `:``}
+ `:``}
${track[0].Steps!==undefined ? `
Step Count
`:``}
@@ -25,7 +25,7 @@ ${track[0].Core!==undefined ? `
`:``}
${track[0].Skin!==undefined ? `
Skin Temp
- `:``}
+ `:``}
@@ -49,7 +49,7 @@ ${track.map(pt=>` ${0|pt.Core}\n`).join("")}
`:``}
${track[0].Skin!==undefined ? `
${track.map(pt=>` ${0|pt.Skin}\n`).join("")}
- `:``}
+ `:``}
@@ -72,8 +72,7 @@ ${track.map(pt=>` ${0|pt.Skin}\n`).join("")}
function saveGPX(track, title) {
var gpx = `
-
-
+
diff --git a/apps/weather/ChangeLog b/apps/weather/ChangeLog
index fb6b28bf6..910cd4658 100644
--- a/apps/weather/ChangeLog
+++ b/apps/weather/ChangeLog
@@ -10,3 +10,4 @@
0.11: Bangle.js 2 support
0.12: Allow hiding the widget
0.13: Tweak Bangle.js 2 light theme colors
+0.14: Use weather condition code for icon selection
diff --git a/apps/weather/app.js b/apps/weather/app.js
index 8c8526fbd..efd9b0209 100644
--- a/apps/weather/app.js
+++ b/apps/weather/app.js
@@ -9,7 +9,7 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
{filly: 1},
{type: "h", filly: 0, c: [
{type: "custom", width: g.getWidth()/2, height: g.getWidth()/2, valign: -1, txt: "unknown", id: "icon",
- render: l => weather.drawIcon(l.txt, l.x+l.w/2, l.y+l.h/2, l.w/2-5)},
+ render: l => weather.drawIcon(l, l.x+l.w/2, l.y+l.h/2, l.w/2-5)},
{type: "v", fillx: 1, c: [
{type: "h", pad: 2, c: [
{type: "txt", font: "18%", id: "temp", label: "000"},
@@ -47,6 +47,7 @@ function formatDuration(millis) {
function draw() {
layout.icon.txt = current.txt;
+ layout.icon.code = current.code;
const temp = locale.temp(current.temp-273.15).match(/^(\D*\d*)(.*)$/);
layout.temp.label = temp[1];
layout.tempUnit.label = temp[2];
diff --git a/apps/weather/lib.js b/apps/weather/lib.js
index 7cb9a9f9b..8afdfe6df 100644
--- a/apps/weather/lib.js
+++ b/apps/weather/lib.js
@@ -16,7 +16,7 @@ function scheduleExpiry(json) {
function update(weatherEvent) {
let json = storage.readJSON('weather.json')||{};
-
+
if (weatherEvent) {
let weather = weatherEvent.clone();
delete weather.t;
@@ -55,7 +55,7 @@ scheduleExpiry(storage.readJSON('weather.json')||{});
exports.drawIcon = function(cond, x, y, r) {
var palette;
-
+
if (B2) {
if (g.theme.dark) {
palette = {
@@ -101,7 +101,7 @@ exports.drawIcon = function(cond, x, y, r) {
};
}
}
-
+
function drawSun(x, y, r) {
g.setColor(palette.sun);
g.fillCircle(x, y, r);
@@ -280,5 +280,44 @@ exports.drawIcon = function(cond, x, y, r) {
return drawUnknown;
}
- chooseIcon(cond)(x, y, r);
+ /*
+ * Choose weather icon to display based on weather conditition code
+ * https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
+ */
+ function chooseIconByCode(code) {
+ const codeGroup = Math.round(code / 100);
+ switch (codeGroup) {
+ case 2: return drawThunderstorm;
+ case 3: return drawRain;
+ case 5:
+ switch (code) {
+ case 511: return drawSnow;
+ case 520: return drawShowerRain;
+ case 521: return drawShowerRain;
+ case 522: return drawShowerRain;
+ case 531: return drawShowerRain;
+ default: return drawRain;
+ }
+ break;
+ case 6: return drawSnow;
+ case 7: return drawMist;
+ case 8:
+ switch (code) {
+ case 800: return drawSun;
+ case 801: return drawFewClouds;
+ case 802: return drawCloud;
+ default: return drawBrokenClouds;
+ }
+ break;
+ default: return drawUnknown;
+ }
+ }
+
+ if (cond.code && cond.code > 0) {
+ chooseIconByCode(cond.code)(x, y, r);
+ } else {
+ chooseIcon(cond.txt)(x, y, r);
+ }
+
+
};