From 6653ffa76259f869c53eb3e3e616b5e700420b9d Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 5 Feb 2023 10:32:33 +0100 Subject: [PATCH 01/58] powermanager - Allow recording timeouts and power changes for later analysis --- apps/powermanager/boot.js | 86 +++++++++- apps/powermanager/default.json | 3 +- apps/powermanager/interface.html | 273 +++++++++++++++++++++++++++++++ apps/powermanager/metadata.json | 1 + apps/powermanager/settings.js | 6 + 5 files changed, 364 insertions(+), 5 deletions(-) create mode 100644 apps/powermanager/interface.html diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index 2bc2aaa35..801c1f48a 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -3,11 +3,89 @@ require('Storage').readJSON("powermanager.default.json", true) || {}, require('Storage').readJSON("powermanager.json", true) || {} ); - + + if (settings.log) { + let logFile = require('Storage').open("powermanager.log","a"); + let def = require('Storage').readJSON("powermanager.def.json", true) || {}; + if (!def.start) def.start = Date.now(); + if (!def.deferred) def.deferred = {}; + let sen = require('Storage').readJSON("powermanager.sen.json", true) || {}; + if (!sen.start) sen.start = Date.now(); + if (!sen.power) sen.power = {}; + + E.on("kill", ()=>{ + let defExists = require("Storage").read("powermanager.def.json")!==undefined; + if (!(!defExists && def.saved)){ + def.saved = Date.now(); + require('Storage').writeJSON("powermanager.def.json", def); + } + let senExists = require("Storage").read("powermanager.sen.json")!==undefined; + if (!(!senExists && sen.saved)){ + sen.saved = Date.now(); + require('Storage').writeJSON("powermanager.sen.json", sen); + } + }); + + + let logPower = (type, oldstate, state, app) => { + logFile.write("p," + type + ',' + (oldstate?1:0) + ',' + (state?1:0) + ',' + app + "\n"); + }; + let logDeferred = (type, duration, source) => { + logFile.write(type + ',' + duration + ',' + source + "\n"); + }; + + let lastPowerOn = {}; + + const TO_WRAP = ["GPS","Compass","Barometer","HRM","LCD"]; + for (let c of TO_WRAP){ + let functionName = "set" + c + "Power"; + let checkName = "is" + c + "On"; + let type = c + ""; + if (!sen.power[type]) sen.power[type] = 0; + + lastPowerOn[type] = Date.now(); + + Bangle[functionName] = ((o) => (a,b) => { + let oldstate = Bangle[checkName](); + let result = o(a,b); + if (!(oldstate && result)) { + if (result) { + //switched on, store time + lastPowerOn[type] = Date.now(); + } else { + //switched off + sen.power[type] += Date.now() - lastPowerOn[type]; + } + } + if (settings.logDetails) logPower(type, oldstate, result, b); + return result; + })(Bangle[functionName]); + } + + let functions = {}; + + let wrapDeferred = ((o,t) => (a,b,c,d) => { + let wrapped = (q,w,e,r)=>{ + let start = Date.now(); + let result = a(q,w,e,r); + let end = Date.now()-start; + let f = a.toString().substring(0,100); + if (settings.logDetails) logDeferred(t, end, f); + if (!def.deferred[f]) def.deferred[f] = 0; + def.deferred[f] += end; + return result; + }; + return o(wrapped,b,c,d); + }); + + global.setTimeout = wrapDeferred(global.setTimeout, "t"); + global.setInterval = wrapDeferred(global.setInterval, "i"); + } + if (settings.warnEnabled){ var chargingInterval; - function handleCharging(charging){ + let handleCharging = (charging) => { if (charging){ if (chargingInterval) clearInterval(chargingInterval); chargingInterval = setInterval(()=>{ @@ -20,12 +98,12 @@ clearInterval(chargingInterval); chargingInterval = undefined; } - } + }; Bangle.on("charging",handleCharging); handleCharging(Bangle.isCharging()); } - + if (settings.forceMonoPercentage){ var p = (E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery())/4; var op = E.getBattery; diff --git a/apps/powermanager/default.json b/apps/powermanager/default.json index 6c929dc38..457f79610 100644 --- a/apps/powermanager/default.json +++ b/apps/powermanager/default.json @@ -2,5 +2,6 @@ "warnEnabled": false, "warn": 96, "forceMonoVoltage": false, - "forceMonoPercentage": false + "forceMonoPercentage": false, + "log": false } diff --git a/apps/powermanager/interface.html b/apps/powermanager/interface.html new file mode 100644 index 000000000..9434ac16f --- /dev/null +++ b/apps/powermanager/interface.html @@ -0,0 +1,273 @@ + + + + + +
+ + + + + diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index 456831aa9..3bfa47d88 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -9,6 +9,7 @@ "tags": "tool", "supports": ["BANGLEJS2"], "readme": "README.md", + "interface": "interface.html", "storage": [ {"name":"powermanager.boot.js","url":"boot.js"}, {"name":"powermanager.settings.js","url":"settings.js"}, diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index fe4719275..9df8b3534 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -36,6 +36,12 @@ writeSettings("forceMonoVoltage", v); } }, + 'Log': { + value: !!settings.log, + onchange: v => { + writeSettings("log", v); + } + }, 'Charge warning': function() { E.showMenu(submenu_chargewarn); }, From 4a3e3dd8257c2dd6c364ec3217505eb7ca94b9fc Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 5 Feb 2023 21:06:32 +0100 Subject: [PATCH 02/58] powermanager - Add data files to metadata --- apps/powermanager/metadata.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index 3bfa47d88..834f5f0af 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -15,5 +15,10 @@ {"name":"powermanager.settings.js","url":"settings.js"}, {"name":"powermanager","url":"lib.js"}, {"name":"powermanager.default.json","url":"default.json"} + ], + "data": [ + {"name":"powermanager.sen.json"}, + {"name":"powermanager.def.json"}, + {"name":"powermanager.log"} ] } From 72be2a72dbc3d11003a528daf8ca2b7839a1a45f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 5 Feb 2023 21:07:50 +0100 Subject: [PATCH 03/58] powermanager - Bump version --- apps/powermanager/ChangeLog | 1 + apps/powermanager/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog index 06f38d399..00784aa5d 100644 --- a/apps/powermanager/ChangeLog +++ b/apps/powermanager/ChangeLog @@ -4,3 +4,4 @@ 0.04: Remove calibration with current voltage (Calibrate->Auto) as it is now handled by settings app Allow automatic calibration on every charge longer than 3 hours 0.05: Add back button to settings menu. +0.06: Allow logging of some things using power \ No newline at end of file diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index 834f5f0af..509dff040 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -2,7 +2,7 @@ "id": "powermanager", "name": "Power Manager", "shortName": "Power Manager", - "version": "0.05", + "version": "0.06", "description": "Allow configuration of warnings and thresholds for battery charging and display.", "icon": "app.png", "type": "bootloader", From ab445bcbbd696591234d74509705dcdc474be3c8 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 5 Feb 2023 21:44:28 +0100 Subject: [PATCH 04/58] powermanager - Add detail setting --- apps/powermanager/settings.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index 9df8b3534..41f5aa471 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -36,17 +36,23 @@ writeSettings("forceMonoVoltage", v); } }, - 'Log': { - value: !!settings.log, - onchange: v => { - writeSettings("log", v); - } - }, 'Charge warning': function() { E.showMenu(submenu_chargewarn); }, 'Calibrate': function() { E.showMenu(submenu_calibrate); + }, + 'Logging': { + value: !!settings.log, + onchange: v => { + writeSettings("log", v); + } + }, + 'Detail logging': { + value: !!settings.logDetails, + onchange: v => { + writeSettings("logDetails", v); + } } }; From cf60428a11a2fafbb8e2db882582278e2aeba50b Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 6 Feb 2023 21:18:44 +0100 Subject: [PATCH 05/58] powermanager - Move settings to Logging submenu --- apps/powermanager/settings.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index 41f5aa471..b0d8ac8b5 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -42,17 +42,8 @@ 'Calibrate': function() { E.showMenu(submenu_calibrate); }, - 'Logging': { - value: !!settings.log, - onchange: v => { - writeSettings("log", v); - } - }, - 'Detail logging': { - value: !!settings.logDetails, - onchange: v => { - writeSettings("logDetails", v); - } + 'Logging': function() { + E.showMenu(submenu_logging); } }; @@ -129,5 +120,26 @@ } }; + var submenu_logging = { + '': { + title: "Logging", + back: function() { + E.showMenu(mainmenu); + }, + }, + 'Enabled': { + value: !!settings.log, + onchange: v => { + writeSettings("log", v); + } + }, + 'Trace': { + value: !!settings.logDetails, + onchange: v => { + writeSettings("logDetails", v); + } + } + } + E.showMenu(mainmenu); }) From bb9d9a7b5156913189e3f3594594a5aacc5aae03 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 6 Feb 2023 22:40:58 +0100 Subject: [PATCH 06/58] powermanager - Try to preserve this during wrapping and do not wrap eval --- apps/powermanager/boot.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index 801c1f48a..a01750029 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -64,18 +64,27 @@ let functions = {}; - let wrapDeferred = ((o,t) => (a,b,c,d) => { - let wrapped = (q,w,e,r)=>{ - let start = Date.now(); - let result = a(q,w,e,r); - let end = Date.now()-start; - let f = a.toString().substring(0,100); - if (settings.logDetails) logDeferred(t, end, f); - if (!def.deferred[f]) def.deferred[f] = 0; - def.deferred[f] += end; - return result; - }; - return o(wrapped,b,c,d); + let wrapDeferred = ((o,t) => (a) => { + if (a == eval){ + return o.apply(this, arguments); + } else { + let wrapped = ()=>{ + let start = Date.now(); + let result = a.apply(undefined, arguments.slice(1)); + let end = Date.now()-start; + let f = a.toString().substring(0,100); + if (settings.logDetails) logDeferred(t, end, f); + if (!def.deferred[f]) def.deferred[f] = 0; + def.deferred[f] += end; + return result; + }; + for (let p in a){ + wrapped[p] = a[p]; + } + let newArgs = arguments.slice(); + newArgs[0] = wrapped; + return o.apply(this, newArgs); + } }); global.setTimeout = wrapDeferred(global.setTimeout, "t"); From 920919cf45b5c245728d24224b3241104be53068 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 7 Feb 2023 19:27:41 +0100 Subject: [PATCH 07/58] powermanager - Save state every 5 minutes --- apps/powermanager/boot.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index a01750029..9cf54110d 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -13,7 +13,9 @@ if (!sen.start) sen.start = Date.now(); if (!sen.power) sen.power = {}; - E.on("kill", ()=>{ + const saveEvery = 1000 * 60 * 5; + + let save = ()=>{ let defExists = require("Storage").read("powermanager.def.json")!==undefined; if (!(!defExists && def.saved)){ def.saved = Date.now(); @@ -24,7 +26,11 @@ sen.saved = Date.now(); require('Storage').writeJSON("powermanager.sen.json", sen); } - }); + } + + setInterval(save, saveEvery); + + E.on("kill", save); let logPower = (type, oldstate, state, app) => { From e4fd6d4a88602064e99300a3fda8b09514db7262 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 7 Feb 2023 19:29:22 +0100 Subject: [PATCH 08/58] powermanager - Fix recording of sensor state --- apps/powermanager/boot.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index 9cf54110d..abc45c21b 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -14,6 +14,7 @@ if (!sen.power) sen.power = {}; const saveEvery = 1000 * 60 * 5; + const TO_WRAP = ["GPS","Compass","Barometer","HRM","LCD"]; let save = ()=>{ let defExists = require("Storage").read("powermanager.def.json")!==undefined; @@ -30,7 +31,14 @@ setInterval(save, saveEvery); - E.on("kill", save); + E.on("kill", ()=>{ + for (let c of TO_WRAP){ + if (lastPowerOn[c] && Bangle["is"+c+"On"]()){ + sen.power[c] += Date.now() - lastPowerOn[c]; + } + } + save(); + }); let logPower = (type, oldstate, state, app) => { @@ -42,27 +50,26 @@ let lastPowerOn = {}; - const TO_WRAP = ["GPS","Compass","Barometer","HRM","LCD"]; for (let c of TO_WRAP){ let functionName = "set" + c + "Power"; let checkName = "is" + c + "On"; let type = c + ""; - if (!sen.power[type]) sen.power[type] = 0; + lastPowerOn[type] = (!lastPowerOn[type] && Bangle[checkName]()) ? Date.now() : undefined; lastPowerOn[type] = Date.now(); Bangle[functionName] = ((o) => (a,b) => { let oldstate = Bangle[checkName](); let result = o(a,b); - if (!(oldstate && result)) { - if (result) { - //switched on, store time - lastPowerOn[type] = Date.now(); - } else { - //switched off - sen.power[type] += Date.now() - lastPowerOn[type]; - } + if (!lastPowerOn[type] && result) { + //switched on, store time + lastPowerOn[type] = Date.now(); + } else if (lastPowerOn[type] && !result){ + //switched off + sen.power[type] += Date.now() - lastPowerOn[type]; + lastPowerOn[type] = undefined; } + if (settings.logDetails) logPower(type, oldstate, result, b); return result; })(Bangle[functionName]); From 666ae825cf485f9ecbe03411f8586f59824262ce Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 15 Feb 2023 14:43:05 -0500 Subject: [PATCH 09/58] [messageicons] Add Jira to icon list + color --- apps/messageicons/lib.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/messageicons/lib.js b/apps/messageicons/lib.js index 314840c13..281d3a201 100644 --- a/apps/messageicons/lib.js +++ b/apps/messageicons/lib.js @@ -33,6 +33,7 @@ exports.getColor = function(msg,options) { "google home": "#fbbc05", // "home assistant": "#41bdf5", // ha-blue is #41bdf5, but that's the background "instagram": "#ff0069", // https://about.instagram.com/brand/gradient + "jira": :"#0052cc", //https://atlassian.design/resources/logo-library "lieferando": "#ff8000", "linkedin": "#0a66c2", // https://brand.linkedin.com/ "messenger": "#0078ff", @@ -65,4 +66,4 @@ exports.getColor = function(msg,options) { "youtube": "#f00", // https://www.youtube.com/howyoutubeworks/resources/brand-resources/#logos-icons-and-colors }[s]||options.default; }; - \ No newline at end of file + From 0611aa94c9d38fab4c70ff65726e1de25fe8bde5 Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 15 Feb 2023 14:45:26 -0500 Subject: [PATCH 10/58] Add jira.png to /apps/messageicons/icons --- apps/messageicons/icons/jira.png | Bin 0 -> 224 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/messageicons/icons/jira.png diff --git a/apps/messageicons/icons/jira.png b/apps/messageicons/icons/jira.png new file mode 100644 index 0000000000000000000000000000000000000000..fe3d83b6a71907f7dd44793d6b5929d70861c4dc GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl{i3-AeX1=2vUG=1lJAjMP? Date: Wed, 15 Feb 2023 14:46:18 -0500 Subject: [PATCH 11/58] Bump version to 0.05 --- apps/messageicons/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/messageicons/metadata.json b/apps/messageicons/metadata.json index 0d1db227b..13f218508 100644 --- a/apps/messageicons/metadata.json +++ b/apps/messageicons/metadata.json @@ -1,7 +1,7 @@ { "id": "messageicons", "name": "Message Icons", - "version": "0.04", + "version": "0.05", "description": "Library containing a list of icons and colors for apps", "icon": "app.png", "type": "module", From e1bfebfdc30ca3f7fc1a9ded0619dfb5bcbc704b Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 15 Feb 2023 14:47:15 -0500 Subject: [PATCH 12/58] Update ChangeLog for v0.05 --- apps/messageicons/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/messageicons/ChangeLog b/apps/messageicons/ChangeLog index 1dd1f3d9e..f420615cb 100644 --- a/apps/messageicons/ChangeLog +++ b/apps/messageicons/ChangeLog @@ -3,3 +3,4 @@ 0.03: Fix icons broken in 0v02 (#2386) Store all icons in a separate binary file (much faster lookup) 0.04: Add message icon for 'clock' +0.05: Add message icon for 'jira' From 5a2597ae5c03a34f50b344dad7dcd4d9944e2169 Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 15 Feb 2023 14:52:07 -0500 Subject: [PATCH 13/58] Fixed typo --- apps/messageicons/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/messageicons/lib.js b/apps/messageicons/lib.js index 281d3a201..9b293e608 100644 --- a/apps/messageicons/lib.js +++ b/apps/messageicons/lib.js @@ -33,7 +33,7 @@ exports.getColor = function(msg,options) { "google home": "#fbbc05", // "home assistant": "#41bdf5", // ha-blue is #41bdf5, but that's the background "instagram": "#ff0069", // https://about.instagram.com/brand/gradient - "jira": :"#0052cc", //https://atlassian.design/resources/logo-library + "jira": "#0052cc", //https://atlassian.design/resources/logo-library "lieferando": "#ff8000", "linkedin": "#0a66c2", // https://brand.linkedin.com/ "messenger": "#0078ff", From b778d476b7b4ea4e2db61d334a7b2ea367ca6cc1 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 19 Feb 2023 21:48:35 +0100 Subject: [PATCH 14/58] powermanager - Initial implementation of widget showing approximate power use --- apps/powermanager/metadata.json | 1 + apps/powermanager/widget.js | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 apps/powermanager/widget.js diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index 509dff040..de65aa4d6 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -13,6 +13,7 @@ "storage": [ {"name":"powermanager.boot.js","url":"boot.js"}, {"name":"powermanager.settings.js","url":"settings.js"}, + {"name":"powermanager.wid.js","url":"settings.js"}, {"name":"powermanager","url":"lib.js"}, {"name":"powermanager.default.json","url":"default.json"} ], diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js new file mode 100644 index 000000000..2f60892b4 --- /dev/null +++ b/apps/powermanager/widget.js @@ -0,0 +1,48 @@ +/* run widgets in their own function scope so they don't interfere with +currently-running apps */ +(() => { + + const APPROX_IDLE = 0.3; + const APPROX_HIGH_BW_BLE = 0.5; + const APPROX_COMPASS = process.HWVERSION == 2 ? 5.5 : 2; + const APPROX_HRM = process.HWVERSION == 2 ? 1 : 2.5; + const APPROX_CPU = 3; + const APPROX_GPS = process.HWVERSION == 2 ? 25 : 30; + const APPROX_TOUCH = 2.5; + const APPROX_BACKLIGHT = process.HWVERSION == 2 ? 16 : 40; + const MAX = APPROX_IDLE + APPROX_HIGH_BW_BLE + APPROX_COMPASS + APPROX_HRM + APPROX_CPU + APPROX_GPS + APPROX_TOUCH + APPROX_BACKLIGHT; + + function draw() { + g.reset(); // reset the graphics context to defaults (color/font/etc) + // add your code + + let current = APPROX_IDLE; + if (Bangle.isGPSOn()) current += APPROX_GPS; + if (Bangle.isHRMOn()) current += APPROX_HRM; + if (Bangle.isLocked()) current += APPROX_TOUCH + APPROX_BACKLIGHT; + if (Bangle.isCompassOn()) current += APPROX_COMPASS; + g.setColor(g.theme.fg); + g.setFont6x15(); + g.setFontAlign(1,-1); + g.drawString("mA", this.x + 14, this.y+13); + g.setFont6x15(); + g.setFontAlign(1,-1); + g.drawString(current.toFixed(0), this.x + 14, this.y); + + timeout = 5000; + if (this.timeoutId !== undefined) { + clearTimeout(this.timeoutId); + } + this.timeoutId = setTimeout(()=>{ + this.timeoutId = undefined; + this.draw(); + }, timeout); + } + + // add your widget + WIDGETS.powermanager={ + area:"tl", + width: 14, + draw:draw + }; +})() From 999bef9f5dbdf81f66afb294fa811679cb094cfe Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 19:14:02 +0100 Subject: [PATCH 15/58] powermanager - Exchange power use number with colored arc --- apps/powermanager/metadata.json | 2 +- apps/powermanager/widget.js | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index de65aa4d6..ff2ea9670 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -13,7 +13,7 @@ "storage": [ {"name":"powermanager.boot.js","url":"boot.js"}, {"name":"powermanager.settings.js","url":"settings.js"}, - {"name":"powermanager.wid.js","url":"settings.js"}, + {"name":"powermanager.wid.js","url":"widget.js"}, {"name":"powermanager","url":"lib.js"}, {"name":"powermanager.default.json","url":"default.json"} ], diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 2f60892b4..1f9e0de49 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -1,7 +1,7 @@ /* run widgets in their own function scope so they don't interfere with currently-running apps */ (() => { - + const GU = require("graphics_utils"); const APPROX_IDLE = 0.3; const APPROX_HIGH_BW_BLE = 0.5; const APPROX_COMPASS = process.HWVERSION == 2 ? 5.5 : 2; @@ -13,36 +13,40 @@ currently-running apps */ const MAX = APPROX_IDLE + APPROX_HIGH_BW_BLE + APPROX_COMPASS + APPROX_HRM + APPROX_CPU + APPROX_GPS + APPROX_TOUCH + APPROX_BACKLIGHT; function draw() { - g.reset(); // reset the graphics context to defaults (color/font/etc) - // add your code + g.reset(); + g.clearRect(this.x, this.y, this.x+24, this.y+24); let current = APPROX_IDLE; if (Bangle.isGPSOn()) current += APPROX_GPS; if (Bangle.isHRMOn()) current += APPROX_HRM; - if (Bangle.isLocked()) current += APPROX_TOUCH + APPROX_BACKLIGHT; + if (!Bangle.isLocked()) current += APPROX_TOUCH + APPROX_BACKLIGHT; if (Bangle.isCompassOn()) current += APPROX_COMPASS; - g.setColor(g.theme.fg); - g.setFont6x15(); - g.setFontAlign(1,-1); - g.drawString("mA", this.x + 14, this.y+13); - g.setFont6x15(); - g.setFontAlign(1,-1); - g.drawString(current.toFixed(0), this.x + 14, this.y); - timeout = 5000; + current = current/MAX; + + g.setColor(g.theme.fg); + + g.setFont6x15(); + g.setFontAlign(0,0); + g.drawString("P", this.x + 12, this.y+15); + + let end = 135 + (current*(405-135)); + g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); + GU.fillArc(g, this.x + 12, this.y + 12, 8, 12, GU.degreesToRadians(135), GU.degreesToRadians(end)); + if (this.timeoutId !== undefined) { clearTimeout(this.timeoutId); } this.timeoutId = setTimeout(()=>{ this.timeoutId = undefined; this.draw(); - }, timeout); + }, Bangle.isLocked() ? 60000 : 5000); } // add your widget WIDGETS.powermanager={ area:"tl", - width: 14, + width: 24, draw:draw }; })() From ae81d93666a9d6a9e385ad8710ae5ed538920ea1 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 19:39:31 +0100 Subject: [PATCH 16/58] powermanager - Approximate LCD power use based on brightness --- apps/powermanager/widget.js | 40 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 1f9e0de49..56867c13d 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -12,41 +12,57 @@ currently-running apps */ const APPROX_BACKLIGHT = process.HWVERSION == 2 ? 16 : 40; const MAX = APPROX_IDLE + APPROX_HIGH_BW_BLE + APPROX_COMPASS + APPROX_HRM + APPROX_CPU + APPROX_GPS + APPROX_TOUCH + APPROX_BACKLIGHT; + let settings = require("Storage").readJSON("setting.json") || {}; + + let brightnessSetting = settings.brightness || 1; + Bangle.setLCDBrightness = ((o) => (a) => { + brightnessSetting = a; + draw(); + return o(a); + })(Bangle.setLCDBrightness); + + let brightness = () => { + return process.HWVERSION == 2 ? (brightnessSetting * APPROX_BACKLIGHT) : (brightnessSetting * 0.9 * 33 + 7); + }; + function draw() { g.reset(); - g.clearRect(this.x, this.y, this.x+24, this.y+24); + g.clearRect(this.x, this.y, this.x + 24, this.y + 24); let current = APPROX_IDLE; if (Bangle.isGPSOn()) current += APPROX_GPS; if (Bangle.isHRMOn()) current += APPROX_HRM; - if (!Bangle.isLocked()) current += APPROX_TOUCH + APPROX_BACKLIGHT; + if (!Bangle.isLocked()) current += APPROX_TOUCH + brightness(); if (Bangle.isCompassOn()) current += APPROX_COMPASS; - current = current/MAX; - + current = current / MAX; + g.setColor(g.theme.fg); g.setFont6x15(); - g.setFontAlign(0,0); - g.drawString("P", this.x + 12, this.y+15); + g.setFontAlign(0, 0); + g.drawString("P", this.x + 12, this.y + 15); - let end = 135 + (current*(405-135)); + let end = 135 + (current * (405 - 135)); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); GU.fillArc(g, this.x + 12, this.y + 12, 8, 12, GU.degreesToRadians(135), GU.degreesToRadians(end)); if (this.timeoutId !== undefined) { clearTimeout(this.timeoutId); } - this.timeoutId = setTimeout(()=>{ + this.timeoutId = setTimeout(() => { this.timeoutId = undefined; this.draw(); }, Bangle.isLocked() ? 60000 : 5000); } // add your widget - WIDGETS.powermanager={ - area:"tl", + WIDGETS.powermanager = { + area: "tl", width: 24, - draw:draw + draw: draw }; -})() + + // conserve memory + delete settings; +})(); \ No newline at end of file From b8792ade175d90d76a26f3a962b5f2d392a7543e Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 20:05:28 +0100 Subject: [PATCH 17/58] powermanager - Let letter in widget denote most expensive active sensor --- apps/powermanager/widget.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 56867c13d..cec710b59 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -30,10 +30,21 @@ currently-running apps */ g.clearRect(this.x, this.y, this.x + 24, this.y + 24); let current = APPROX_IDLE; - if (Bangle.isGPSOn()) current += APPROX_GPS; - if (Bangle.isHRMOn()) current += APPROX_HRM; + let mostExpensive = "P"; + if (!Bangle.isLocked()) current += APPROX_TOUCH + brightness(); - if (Bangle.isCompassOn()) current += APPROX_COMPASS; + if (Bangle.isCompassOn()) { + current += APPROX_COMPASS; + mostExpensive = "C"; + } + if (Bangle.isHRMOn()) { + current += APPROX_HRM; + mostExpensive = "H"; + } + if (Bangle.isGPSOn()) { + current += APPROX_GPS; + mostExpensive = "G"; + } current = current / MAX; @@ -41,7 +52,7 @@ currently-running apps */ g.setFont6x15(); g.setFontAlign(0, 0); - g.drawString("P", this.x + 12, this.y + 15); + g.drawString(mostExpensive, this.x + 12, this.y + 15); let end = 135 + (current * (405 - 135)); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); @@ -63,6 +74,8 @@ currently-running apps */ draw: draw }; + Bangle.on("lock", draw); + // conserve memory delete settings; })(); \ No newline at end of file From bef8013342e6af8216ecf8674353ec73a695ffcd Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 20:07:55 +0100 Subject: [PATCH 18/58] powermanager - Fix clearing area for widget --- apps/powermanager/widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index cec710b59..a60c79941 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -27,7 +27,7 @@ currently-running apps */ function draw() { g.reset(); - g.clearRect(this.x, this.y, this.x + 24, this.y + 24); + g.clearRect(this.x, this.y, this.x + 23, this.y + 23); let current = APPROX_IDLE; let mostExpensive = "P"; From b334b14f402b05cf6413ee36e359056dfb1eab74 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 20:55:33 +0100 Subject: [PATCH 19/58] powermanager - Fix drawing in timeout --- apps/powermanager/widget.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index a60c79941..7ed9159fe 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -17,7 +17,7 @@ currently-running apps */ let brightnessSetting = settings.brightness || 1; Bangle.setLCDBrightness = ((o) => (a) => { brightnessSetting = a; - draw(); + draw(WIDGETS.powermanager); return o(a); })(Bangle.setLCDBrightness); @@ -25,7 +25,7 @@ currently-running apps */ return process.HWVERSION == 2 ? (brightnessSetting * APPROX_BACKLIGHT) : (brightnessSetting * 0.9 * 33 + 7); }; - function draw() { + function draw(w) { g.reset(); g.clearRect(this.x, this.y, this.x + 23, this.y + 23); @@ -63,7 +63,7 @@ currently-running apps */ } this.timeoutId = setTimeout(() => { this.timeoutId = undefined; - this.draw(); + w.draw(w); }, Bangle.isLocked() ? 60000 : 5000); } From ce46760922c85b51cc88f6a4c951f7bc8a8060c7 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 20:56:12 +0100 Subject: [PATCH 20/58] powermanager - Adds setting for widget --- apps/powermanager/settings.js | 6 ++++++ apps/powermanager/widget.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index b0d8ac8b5..41833f3a6 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -24,6 +24,12 @@ 'title': 'Power Manager' }, "< Back" : back, + 'Show widget': { + value: !!settings.widget, + onchange: v => { + writeSettings("widget", v); + } + }, 'Monotonic percentage': { value: !!settings.forceMonoPercentage, onchange: v => { diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 7ed9159fe..b59108f01 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -1,6 +1,10 @@ /* run widgets in their own function scope so they don't interfere with currently-running apps */ (() => { + const s = require("Storage").readJSON("powermanager.json") || {}; + + if (!s.widget) return; + const GU = require("graphics_utils"); const APPROX_IDLE = 0.3; const APPROX_HIGH_BW_BLE = 0.5; From 8e91bb35c45ffef33c8f754ce7c8104a5bdadcf2 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 20 Feb 2023 20:56:52 +0100 Subject: [PATCH 21/58] powermanager - Add a bit of readme describing the widget --- apps/powermanager/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/powermanager/README.md b/apps/powermanager/README.md index 88b3c370a..7a0c110a6 100644 --- a/apps/powermanager/README.md +++ b/apps/powermanager/README.md @@ -7,6 +7,11 @@ Features: * Force monotonic battery percentage or voltage * Automatic calibration on charging uninterrupted longer than 3 hours (reloads of the watch reset the timer). + +## Widget +The widget shows an approximate current power use. There is a power gauge showing the estimation of the currently used power and the currently active sensor with the biggest power draw. +G for GPS, H for pulse sensor and C for compass. + ## Internals Battery calibration offset is set by writing `batFullVoltage` in setting.json From fa3b20bdf6e26878a555cfc230b9c654b2a57098 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 21 Feb 2023 00:00:43 +0100 Subject: [PATCH 22/58] powermanager - Add CPU indicator to widget --- apps/powermanager/widget.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index b59108f01..0eb352ea1 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -5,6 +5,17 @@ currently-running apps */ if (!s.widget) return; + const systickMax = peek32(0xE000E014); + let t, systickNow, tLater, systickLater, systickDiff; + setInterval(() => { + tLater = Date.now(); + systickLater = peek32(0xE000E018); + systickDiff = systickLater - systickNow; + if (systickDiff < 0) systickDiff += systickMax; + t = Date.now(); + systickNow = peek32(0xE000E018); + }, 250); + const GU = require("graphics_utils"); const APPROX_IDLE = 0.3; const APPROX_HIGH_BW_BLE = 0.5; @@ -31,9 +42,9 @@ currently-running apps */ function draw(w) { g.reset(); - g.clearRect(this.x, this.y, this.x + 23, this.y + 23); - let current = APPROX_IDLE; + let cpu = 1 - systickDiff/systickMax; + let current = APPROX_IDLE + cpu * APPROX_CPU; let mostExpensive = "P"; if (!Bangle.isLocked()) current += APPROX_TOUCH + brightness(); @@ -52,6 +63,8 @@ currently-running apps */ current = current / MAX; + g.clearRect(this.x, this.y, this.x + 23, this.y + 23); + g.setColor(g.theme.fg); g.setFont6x15(); @@ -60,7 +73,11 @@ currently-running apps */ let end = 135 + (current * (405 - 135)); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); - GU.fillArc(g, this.x + 12, this.y + 12, 8, 12, GU.degreesToRadians(135), GU.degreesToRadians(end)); + GU.fillArc(g, this.x + 12, this.y + 12, 9, 12, GU.degreesToRadians(135), GU.degreesToRadians(end)); + + g.setColor(g.theme.fg); + let endCpu = 135 + (cpu * (405 - 135)); + GU.fillArc(g, this.x + 12, this.y + 12, 6, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu)); if (this.timeoutId !== undefined) { clearTimeout(this.timeoutId); @@ -68,7 +85,7 @@ currently-running apps */ this.timeoutId = setTimeout(() => { this.timeoutId = undefined; w.draw(w); - }, Bangle.isLocked() ? 60000 : 5000); + }, Bangle.isLocked() ? 60000 : 2000); } // add your widget From fd3deae93e0589d9fcf3f2f4e17f2f751a551456 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 21 Feb 2023 00:02:42 +0100 Subject: [PATCH 23/58] powermanager - Fix calling draw without parameter on lock events --- apps/powermanager/widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 0eb352ea1..8de7a47a3 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -95,7 +95,7 @@ currently-running apps */ draw: draw }; - Bangle.on("lock", draw); + Bangle.on("lock", ()=>{draw(WIDGETS.powermanager);}); // conserve memory delete settings; From 02f8284771bf3a80814ad6ecfd18e46f1ff09e36 Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 22 Feb 2023 12:27:17 -0500 Subject: [PATCH 24/58] Update icon_names.json Added jira --- apps/messageicons/icons/icon_names.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/messageicons/icons/icon_names.json b/apps/messageicons/icons/icon_names.json index f7a743e85..7c09cd397 100644 --- a/apps/messageicons/icons/icon_names.json +++ b/apps/messageicons/icons/icon_names.json @@ -42,6 +42,7 @@ { "app":"google play store", "icon":"google play store.png" }, { "app":"home assistant", "icon":"home assistant.png" }, { "app":"instagram", "icon":"instagram.png" }, + { "app":"jira", "icon":"jira.png" }, { "app":"kalender", "icon":"kalender.png" }, { "app":"keep notes", "icon":"google keep.png" }, { "app":"lieferando", "icon":"lieferando.png" }, From 79f391d84dc6754423a22550af35533434313d5e Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 22 Feb 2023 13:06:43 -0500 Subject: [PATCH 25/58] Add Jira color to generate.js --- apps/messageicons/icons/generate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/messageicons/icons/generate.js b/apps/messageicons/icons/generate.js index e857032af..f4fec1c4a 100755 --- a/apps/messageicons/icons/generate.js +++ b/apps/messageicons/icons/generate.js @@ -107,6 +107,7 @@ exports.getColor = function(msg,options) { "google home": "#fbbc05", // "home assistant": "#41bdf5", // ha-blue is #41bdf5, but that's the background "instagram": "#ff0069", // https://about.instagram.com/brand/gradient + "jira": "#0052cc", //https://atlassian.design/resources/logo-library "lieferando": "#ff8000", "linkedin": "#0a66c2", // https://brand.linkedin.com/ "messenger": "#0078ff", From 8a5450370fdbc4a2ecb9a81dc0ad8d9766213a0f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 17:55:18 +0100 Subject: [PATCH 26/58] powermanager - Use less vertices to draw widget --- apps/powermanager/widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 8de7a47a3..45e7a9645 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -73,11 +73,11 @@ currently-running apps */ let end = 135 + (current * (405 - 135)); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); - GU.fillArc(g, this.x + 12, this.y + 12, 9, 12, GU.degreesToRadians(135), GU.degreesToRadians(end)); + GU.fillArc(g, this.x + 12, this.y + 12, 9, 12, GU.degreesToRadians(135), GU.degreesToRadians(end), GU.degreesToRadians(30)); g.setColor(g.theme.fg); let endCpu = 135 + (cpu * (405 - 135)); - GU.fillArc(g, this.x + 12, this.y + 12, 6, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu)); + GU.fillArc(g, this.x + 12, this.y + 12, 6, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu), GU.degreesToRadians(30)); if (this.timeoutId !== undefined) { clearTimeout(this.timeoutId); From 35ddc58b1f5d77270ff29ac6e800dbd3ed9dfe11 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 18:44:49 +0100 Subject: [PATCH 27/58] powermanager - Only sample cpu use on drawing --- apps/powermanager/widget.js | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 45e7a9645..774726838 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -5,16 +5,8 @@ currently-running apps */ if (!s.widget) return; - const systickMax = peek32(0xE000E014); - let t, systickNow, tLater, systickLater, systickDiff; - setInterval(() => { - tLater = Date.now(); - systickLater = peek32(0xE000E018); - systickDiff = systickLater - systickNow; - if (systickDiff < 0) systickDiff += systickMax; - t = Date.now(); - systickNow = peek32(0xE000E018); - }, 250); + const SYSTICKMAX = peek32(0xE000E014); + const SYSTICKWAIT = SYSTICKMAX/64000; // 64 MHz clock rate, Systick counting down on every non idle clock const GU = require("graphics_utils"); const APPROX_IDLE = 0.3; @@ -40,10 +32,9 @@ currently-running apps */ return process.HWVERSION == 2 ? (brightnessSetting * APPROX_BACKLIGHT) : (brightnessSetting * 0.9 * 33 + 7); }; - function draw(w) { + function doDraw(w, cpu){ g.reset(); - let cpu = 1 - systickDiff/systickMax; let current = APPROX_IDLE + cpu * APPROX_CPU; let mostExpensive = "P"; @@ -63,29 +54,38 @@ currently-running apps */ current = current / MAX; - g.clearRect(this.x, this.y, this.x + 23, this.y + 23); + g.clearRect(w.x, w.y, w.x + 23, w.y + 23); g.setColor(g.theme.fg); g.setFont6x15(); g.setFontAlign(0, 0); - g.drawString(mostExpensive, this.x + 12, this.y + 15); - + g.drawString(mostExpensive, w.x + 12, w.y + 15); let end = 135 + (current * (405 - 135)); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); - GU.fillArc(g, this.x + 12, this.y + 12, 9, 12, GU.degreesToRadians(135), GU.degreesToRadians(end), GU.degreesToRadians(30)); + GU.fillArc(g, w.x + 12, w.y + 12, 9, 12, GU.degreesToRadians(135), GU.degreesToRadians(end), GU.degreesToRadians(30)); g.setColor(g.theme.fg); let endCpu = 135 + (cpu * (405 - 135)); - GU.fillArc(g, this.x + 12, this.y + 12, 6, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu), GU.degreesToRadians(30)); + GU.fillArc(g, w.x + 12, w.y + 12, 5.5, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu), GU.degreesToRadians(30)); + } - if (this.timeoutId !== undefined) { - clearTimeout(this.timeoutId); - } - this.timeoutId = setTimeout(() => { - this.timeoutId = undefined; - w.draw(w); - }, Bangle.isLocked() ? 60000 : 2000); + function draw(w) { + setTimeout((t, systickNow) => { + let tLater = Date.now(); + let systickLater = peek32(0xE000E018); + let systickDiff = systickLater - systickNow; + if (systickDiff < 0) systickDiff += SYSTICKMAX; + doDraw(w, 1 - systickDiff/SYSTICKMAX); + + if (w.timeoutId !== undefined) { + clearTimeout(w.timeoutId); + } + w.timeoutId = setTimeout(() => { + w.timeoutId = undefined; + w.draw(w); + }, Bangle.isLocked() ? 60000 : (s.unlockedRefresh || 1000) - SYSTICKWAIT); + }, SYSTICKWAIT, Date.now(), peek32(0xE000E018)); } // add your widget From 4caaebf450568e99ecac113c58ee2bee3d1b9025 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 18:59:34 +0100 Subject: [PATCH 28/58] powermanager - Adds settings for widget in own menu --- apps/powermanager/settings.js | 42 ++++++++++++++++++++++++++++++----- apps/powermanager/widget.js | 2 +- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index 41833f3a6..1e6c073be 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -24,11 +24,8 @@ 'title': 'Power Manager' }, "< Back" : back, - 'Show widget': { - value: !!settings.widget, - onchange: v => { - writeSettings("widget", v); - } + 'Widget': function() { + E.showMenu(submenu_widget); }, 'Monotonic percentage': { value: !!settings.forceMonoPercentage, @@ -147,5 +144,40 @@ } } + var submenu_widget = { + '': { + title: "Widget", + back: function() { + E.showMenu(mainmenu); + }, + }, + 'Enabled': { + value: !!settings.widget, + onchange: v => { + writeSettings("widget", v); + } + }, + 'Refresh': { + min: 0.5, + max: 60, + step: 0.5, + value: settings.refreshUnlocked || 1, + format: v => v + "s", + onchange: v => { + writeSettings("refreshUnlocked", v); + } + }, + 'Refresh locked': { + min: 5, + max: 120, + step: 5, + value: settings.refreshLocked || 60, + format: v => v + "s", + onchange: v => { + writeSettings("refreshLocked", v); + } + } + } + E.showMenu(mainmenu); }) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 774726838..ec4f4b55d 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -84,7 +84,7 @@ currently-running apps */ w.timeoutId = setTimeout(() => { w.timeoutId = undefined; w.draw(w); - }, Bangle.isLocked() ? 60000 : (s.unlockedRefresh || 1000) - SYSTICKWAIT); + }, Bangle.isLocked() ? (s.refreshLocked || 60) * 1000 : (s.refreshUnlocked || 1) * 1000 - SYSTICKWAIT); }, SYSTICKWAIT, Date.now(), peek32(0xE000E018)); } From 8b51c3102747bd840e73a6bf020ece6759921600 Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 22 Feb 2023 13:40:57 -0500 Subject: [PATCH 29/58] Add generate.js -> lib.js note Left a comment, to make it clearer that you should not modify "lib.js" directly, but to modify "generate.js" instead. --- apps/messageicons/icons/generate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/messageicons/icons/generate.js b/apps/messageicons/icons/generate.js index f4fec1c4a..0070c66a4 100755 --- a/apps/messageicons/icons/generate.js +++ b/apps/messageicons/icons/generate.js @@ -1,6 +1,7 @@ #!/usr/bin/node // Creates lib.js from icons +// This file is generated by /icons/generate.js, so if you need to modify its content, you should do it there, not directly in lib.js // npm install png-js // default icon must come first in icon_names From 5993d24cc3026c62d57eaa361e86d5884d51e037 Mon Sep 17 00:00:00 2001 From: m-p-3 Date: Wed, 22 Feb 2023 13:42:31 -0500 Subject: [PATCH 30/58] oopsie, moved comment to proper location --- apps/messageicons/icons/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/messageicons/icons/generate.js b/apps/messageicons/icons/generate.js index 0070c66a4..b77cfc26e 100755 --- a/apps/messageicons/icons/generate.js +++ b/apps/messageicons/icons/generate.js @@ -1,7 +1,6 @@ #!/usr/bin/node // Creates lib.js from icons -// This file is generated by /icons/generate.js, so if you need to modify its content, you should do it there, not directly in lib.js // npm install png-js // default icon must come first in icon_names @@ -88,6 +87,7 @@ exports.getColor = function(msg,options) { if (st.iconColorMode == 'mono') return options.default; const s = (("string"=== typeof msg) ? msg : (msg.src || "")).toLowerCase(); return { + // This file is generated by /icons/generate.js. If you need to modify its content, you should do it there instead. // generic colors, using B2-safe colors // DO NOT USE BLACK OR WHITE HERE, just leave the declaration out and then the theme's fg color will be used "airbnb": "#ff385c", // https://news.airbnb.com/media-assets/category/brand/ From 6104946a0882ea305b8ca8d765bfbce5f2473f48 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 22:00:31 +0100 Subject: [PATCH 31/58] powermanager - Refactor cpu use sampling code --- apps/powermanager/widget.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index ec4f4b55d..7a5714fad 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -69,23 +69,26 @@ currently-running apps */ let endCpu = 135 + (cpu * (405 - 135)); GU.fillArc(g, w.x + 12, w.y + 12, 5.5, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu), GU.degreesToRadians(30)); } - + let sTimeout; function draw(w) { - setTimeout((t, systickNow) => { + if (sTimeout) clearTimeout(sTimeout); + let systickNow = peek32(0xE000E018); + let t = Date.now(); + sTimeout = setTimeout(() => { let tLater = Date.now(); let systickLater = peek32(0xE000E018); let systickDiff = systickLater - systickNow; if (systickDiff < 0) systickDiff += SYSTICKMAX; doDraw(w, 1 - systickDiff/SYSTICKMAX); + }, SYSTICKWAIT); - if (w.timeoutId !== undefined) { - clearTimeout(w.timeoutId); - } - w.timeoutId = setTimeout(() => { - w.timeoutId = undefined; - w.draw(w); - }, Bangle.isLocked() ? (s.refreshLocked || 60) * 1000 : (s.refreshUnlocked || 1) * 1000 - SYSTICKWAIT); - }, SYSTICKWAIT, Date.now(), peek32(0xE000E018)); + if (w.timeoutId !== undefined) { + clearTimeout(w.timeoutId); + } + w.timeoutId = setTimeout(() => { + w.timeoutId = undefined; + w.draw(w); + }, Bangle.isLocked() ? ((s.refreshLocked || 60) * 1000 ): ((s.refreshUnlocked || 1) * 1000)); } // add your widget From 48ac083189c2528a8027dfeb9e10c567c2249b5f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 22:01:34 +0100 Subject: [PATCH 32/58] powermanager - Cleanup interface UI --- apps/powermanager/boot.js | 53 +++++++++++++++++--------------- apps/powermanager/interface.html | 41 +++++++++++------------- apps/powermanager/metadata.json | 2 +- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index abc45c21b..c931a243b 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -9,9 +9,9 @@ let def = require('Storage').readJSON("powermanager.def.json", true) || {}; if (!def.start) def.start = Date.now(); if (!def.deferred) def.deferred = {}; - let sen = require('Storage').readJSON("powermanager.sen.json", true) || {}; - if (!sen.start) sen.start = Date.now(); - if (!sen.power) sen.power = {}; + let hw = require('Storage').readJSON("powermanager.hw.json", true) || {}; + if (!hw.start) hw.start = Date.now(); + if (!hw.power) hw.power = {}; const saveEvery = 1000 * 60 * 5; const TO_WRAP = ["GPS","Compass","Barometer","HRM","LCD"]; @@ -22,10 +22,10 @@ def.saved = Date.now(); require('Storage').writeJSON("powermanager.def.json", def); } - let senExists = require("Storage").read("powermanager.sen.json")!==undefined; - if (!(!senExists && sen.saved)){ - sen.saved = Date.now(); - require('Storage').writeJSON("powermanager.sen.json", sen); + let hwExists = require("Storage").read("powermanager.hw.json")!==undefined; + if (!(!hwExists && hw.saved)){ + hw.saved = Date.now(); + require('Storage').writeJSON("powermanager.hw.json", hw); } } @@ -34,7 +34,7 @@ E.on("kill", ()=>{ for (let c of TO_WRAP){ if (lastPowerOn[c] && Bangle["is"+c+"On"]()){ - sen.power[c] += Date.now() - lastPowerOn[c]; + hw.power[c] += Date.now() - lastPowerOn[c]; } } save(); @@ -45,7 +45,7 @@ logFile.write("p," + type + ',' + (oldstate?1:0) + ',' + (state?1:0) + ',' + app + "\n"); }; let logDeferred = (type, duration, source) => { - logFile.write(type + ',' + duration + ',' + source + "\n"); + logFile.write(type + ',' + duration + ',' + source.replace(/\n/g, " ").replace(/,/g,"") + "\n"); }; let lastPowerOn = {}; @@ -66,7 +66,7 @@ lastPowerOn[type] = Date.now(); } else if (lastPowerOn[type] && !result){ //switched off - sen.power[type] += Date.now() - lastPowerOn[type]; + hw.power[type] += Date.now() - lastPowerOn[type]; lastPowerOn[type] = undefined; } @@ -76,23 +76,28 @@ } let functions = {}; - let wrapDeferred = ((o,t) => (a) => { if (a == eval){ return o.apply(this, arguments); } else { - let wrapped = ()=>{ - let start = Date.now(); - let result = a.apply(undefined, arguments.slice(1)); - let end = Date.now()-start; - let f = a.toString().substring(0,100); - if (settings.logDetails) logDeferred(t, end, f); - if (!def.deferred[f]) def.deferred[f] = 0; - def.deferred[f] += end; - return result; - }; - for (let p in a){ - wrapped[p] = a[p]; + let wrapped = a; + if (!a.__wrapped){ + wrapped = ()=>{ + let start = Date.now(); + let result = a.apply(undefined, arguments.slice(1)); + let end = Date.now()-start; + let f = a.toString().substring(0,100); + if (settings.logDetails) logDeferred(t, end, f); + if (!def.deferred[f]) def.deferred[f] = 0; + def.deferred[f] += end; + return result; + }; + //copy over properties of functions + for (let p in a){ + wrapped[p] = a[p]; + } + //mark function as wrapped + wrapped.__wrapped = true; } let newArgs = arguments.slice(); newArgs[0] = wrapped; @@ -156,4 +161,4 @@ if (!charging) chargeStart = undefined; }); } -})(); +})(); \ No newline at end of file diff --git a/apps/powermanager/interface.html b/apps/powermanager/interface.html index 9434ac16f..7a00af993 100644 --- a/apps/powermanager/interface.html +++ b/apps/powermanager/interface.html @@ -21,7 +21,7 @@ function show() { Util.showModal("Loading..."); domContent.innerHTML = ""; var htmlOverview = ` -
This needs "Log" to be enabled in power manager settings. The deferred function calls table is only updated on the bangle on reloads.
+
This needs "Logging" to be enabled in power manager settings. The deferred function calls table is only updated on the bangle on reloads.
@@ -37,14 +37,14 @@ function show() { - + - + - ` + ` } let duration = parsed.saved - parsed.start; @@ -165,15 +165,15 @@ function viewDeferredTable(filename) { } -function viewSensorsTable(filename) { - Puck.eval(`require("Storage").list("powermanager.sen.json").length > 0`, (f)=>{ +function viewHardwareTable(filename) { + Puck.eval(`require("Storage").list("powermanager.hw.json").length > 0`, (f)=>{ if (f) { - Util.showModal("Reading sensor info..."); + Util.showModal("Reading hardware info..."); Util.readStorage( filename, data => { Util.hideModal(); let parsed = JSON.parse(data); - console.log("Sensors", parsed); + console.log("Hardware", parsed); let duration = parsed.saved - parsed.start; let rows = []; @@ -191,7 +191,7 @@ function viewSensorsTable(filename) { } - var htmlOverview = `

Sensor power

+ var htmlOverview = `

Hardware power

Recorded in a time span of ${Math.round(duration/1000)}s. Percentages are calculated from recording time. @@ -201,7 +201,7 @@ function viewSensorsTable(filename) {
- + \n`; @@ -213,7 +213,7 @@ function viewSensorsTable(filename) { }); }); } else { - var htmlOverview = `

Sensor power

+ var htmlOverview = `

Hardware power

No data available. @@ -234,16 +234,11 @@ function viewDetailsTable(filename) { Util.hideModal(); var htmlOverview = `

Detailed logging

+ + This is a trace log of all logged power entries, first column denotes the type. p for power, i for interval and t for timeout. Power is logged with old state, new state and calling app if available. Functions are logged with execution duraion and source if available. +
Type
SensorsHardware - - + +
DetailsDetails (Trace) @@ -78,8 +78,8 @@ function show() { if (task=="deftable") { viewDeferredTable(filename); } - if (task=="sensorstable") { - viewSensorsTable(filename); + if (task=="hardwaretable") { + viewHardwareTable(filename); } if (task=="detailstable") { viewDetailsTable(filename); @@ -110,7 +110,7 @@ function viewDeferredTable(filename) { tableRows += `
${(c.time/1000).toFixed(2)}s ${(c.time/sum*100).toFixed(2)}%${c.func}
${c.func}
Time PercentageSensorDevice
- - - - - - - - \n`; let rows = data.trim().split("\n"); for (var row of rows) { diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index ff2ea9670..efb290892 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -18,7 +18,7 @@ {"name":"powermanager.default.json","url":"default.json"} ], "data": [ - {"name":"powermanager.sen.json"}, + {"name":"powermanager.hw.json"}, {"name":"powermanager.def.json"}, {"name":"powermanager.log"} ] From 8b7a63b718c8199ca0ac5d6f5d0adda9ca72fb0a Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 22:19:25 +0100 Subject: [PATCH 33/58] powermanager - Update readme --- apps/powermanager/ChangeLog | 3 ++- apps/powermanager/README.md | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog index 00784aa5d..fd8ce0679 100644 --- a/apps/powermanager/ChangeLog +++ b/apps/powermanager/ChangeLog @@ -4,4 +4,5 @@ 0.04: Remove calibration with current voltage (Calibrate->Auto) as it is now handled by settings app Allow automatic calibration on every charge longer than 3 hours 0.05: Add back button to settings menu. -0.06: Allow logging of some things using power \ No newline at end of file +0.06: Allow logging of some things using power + Add widget for live monitoring of power use diff --git a/apps/powermanager/README.md b/apps/powermanager/README.md index 7a0c110a6..043b5ca8c 100644 --- a/apps/powermanager/README.md +++ b/apps/powermanager/README.md @@ -9,9 +9,16 @@ Features: ## Widget + The widget shows an approximate current power use. There is a power gauge showing the estimation of the currently used power and the currently active sensor with the biggest power draw. G for GPS, H for pulse sensor and C for compass. +## Logging + +You can switch on logging in the options to diagnose unexpected power use. Currently the logging can capture the code running from timeouts and intervals and the power up and down of some devices. The captured times are probably not perfect but should be good enough to indicate problems. + +Do not use trace logging for extended time, it uses a lot of storage and can fill up the flash quite quick. + ## Internals Battery calibration offset is set by writing `batFullVoltage` in setting.json @@ -19,6 +26,10 @@ Battery calibration offset is set by writing `batFullVoltage` in setting.json ## TODO * Optionally keep battery history and show as graph +* Capture some more stuff in logging + * Event driven code execution + * Buzzer + * Better tracking of display on time ## Creator From b58b0133aa7d81d2b05bb6576ece42258f459959 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Wed, 22 Feb 2023 22:57:49 +0100 Subject: [PATCH 34/58] powermanager - Fix widget drawing over other things if widgets hidden --- apps/powermanager/widget.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 7a5714fad..116f1703e 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -70,17 +70,28 @@ currently-running apps */ GU.fillArc(g, w.x + 12, w.y + 12, 5.5, 8, GU.degreesToRadians(135), GU.degreesToRadians(endCpu), GU.degreesToRadians(30)); } let sTimeout; + let s2Timeout; + let systickDiff; function draw(w) { + let nextRefresh = Bangle.isLocked() ? ((s.refreshLocked || 60) * 1000 ): ((s.refreshUnlocked || 1) * 1000) + + if (s2Timeout) clearTimeout(s2Timeout); if (sTimeout) clearTimeout(sTimeout); - let systickNow = peek32(0xE000E018); - let t = Date.now(); - sTimeout = setTimeout(() => { + + let t,systickNow; + sTimeout = setTimeout(()=>{ + systickNow = peek32(0xE000E018); + t = Date.now(); + }, nextRefresh - SYSTICKWAIT - 100); + + s2Timeout = setTimeout(() => { let tLater = Date.now(); let systickLater = peek32(0xE000E018); - let systickDiff = systickLater - systickNow; + systickDiff = systickLater - systickNow; if (systickDiff < 0) systickDiff += SYSTICKMAX; - doDraw(w, 1 - systickDiff/SYSTICKMAX); - }, SYSTICKWAIT); + }, nextRefresh - 100); + + doDraw(w, systickDiff ? (1 - systickDiff/SYSTICKMAX) : 0); if (w.timeoutId !== undefined) { clearTimeout(w.timeoutId); @@ -88,7 +99,7 @@ currently-running apps */ w.timeoutId = setTimeout(() => { w.timeoutId = undefined; w.draw(w); - }, Bangle.isLocked() ? ((s.refreshLocked || 60) * 1000 ): ((s.refreshUnlocked || 1) * 1000)); + }, nextRefresh); } // add your widget @@ -98,7 +109,7 @@ currently-running apps */ draw: draw }; - Bangle.on("lock", ()=>{draw(WIDGETS.powermanager);}); + Bangle.on("lock", ()=>{WIDGETS.powermanager.draw(WIDGETS.powermanager);}); // conserve memory delete settings; From 87a448f76c425d4d8854e5719a347c14320a8381 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 22 Feb 2023 22:02:54 +0000 Subject: [PATCH 35/58] Add TypeScript details to READMEs And in some cases, add READMEs (this is a follow-up to #2589) --- apps/btadv/README.md | 16 ++++++++++++++++ apps/clkinfostopw/README.md | 4 ++++ apps/widChargingStatus/README.md | 8 ++++++++ 3 files changed, 28 insertions(+) create mode 100644 apps/btadv/README.md create mode 100644 apps/widChargingStatus/README.md diff --git a/apps/btadv/README.md b/apps/btadv/README.md new file mode 100644 index 000000000..7b1afcefe --- /dev/null +++ b/apps/btadv/README.md @@ -0,0 +1,16 @@ +# Bluetooth Advert + +This app advertises and exports (over Bluetooth) live data from the bangle's sensors: + +- Heart Rate +- Accelerometer readings +- Pressure +- GPS information +- Magnetic flux + +Swipe in any direction to access settings, and tap a setting to toggle it. +Hit back to return to the details screen, which shows sensor data being exported. + +# TypeScript + +This app is written in TypeScript, see [typescript/README.md](/typescript/README.md) for more info diff --git a/apps/clkinfostopw/README.md b/apps/clkinfostopw/README.md index bfac58dab..e92eee3ef 100644 --- a/apps/clkinfostopw/README.md +++ b/apps/clkinfostopw/README.md @@ -9,3 +9,7 @@ Tap to start, tap again to pause. Tap again to restart ## Requests [Contact Rob](https://www.github.com/bobrippling) for features/bugs + +# TypeScript + +This app is written in TypeScript, see [typescript/README.md](/typescript/README.md) for more info diff --git a/apps/widChargingStatus/README.md b/apps/widChargingStatus/README.md new file mode 100644 index 000000000..a5ac62811 --- /dev/null +++ b/apps/widChargingStatus/README.md @@ -0,0 +1,8 @@ +# Charging Status + +This widget shows a yellow lightning icon to indicate that the watch is charging. A short buzz is also emitted on initial charging connection. +Nothing is shown when not charging. + +# TypeScript + +This app is written in TypeScript, see [typescript/README.md](/typescript/README.md) for more info From 2b39b1e2855f94aebb894581f16fadf9006d69bd Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 22 Feb 2023 22:19:20 +0000 Subject: [PATCH 36/58] btadv: manually setup TS helpers - use Object.assign() Currently we have `tsc` [generate code for es5], because we don't yet have es6 destructuring support in JSV (used [here], for example). As a follow on from #2587, this disables the TS poiyfill and points it at our `Object.assign`, so we benefit from these new features, while still keeping the target at es5. [generate code for es5]: https://github.com/espruino/BangleApps/blob/380af9c600121f50b940b83cdb83a5f83914b8a6/tsconfig.json#L4-L4 [here]: https://github.com/espruino/BangleApps/blob/380af9c600121f50b940b83cdb83a5f83914b8a6/apps/btadv/app.ts#L235 --- apps/btadv/app.js | 12 +----------- apps/btadv/app.ts | 3 +++ tsconfig.json | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/apps/btadv/app.js b/apps/btadv/app.js index 7f9300923..ced701d79 100644 --- a/apps/btadv/app.js +++ b/apps/btadv/app.js @@ -1,15 +1,5 @@ "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +var __assign = Object.assign; var Layout = require("Layout"); Bangle.loadWidgets(); Bangle.drawWidgets(); diff --git a/apps/btadv/app.ts b/apps/btadv/app.ts index b3a25305c..15128e484 100644 --- a/apps/btadv/app.ts +++ b/apps/btadv/app.ts @@ -1,3 +1,6 @@ +// ts helpers: +const __assign = Object.assign; + const Layout = require("Layout") as Layout_.Layout; Bangle.loadWidgets(); diff --git a/tsconfig.json b/tsconfig.json index 3bfd79e41..7f6a96fef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "removeComments": true, "newLine": "lf", - "noEmitHelpers": false, + "noEmitHelpers": true, // we link to specific banglejs implementations "noEmitOnError": false, "preserveConstEnums": false, "importsNotUsedAsValues": "error", From 540b85fba51b2793f83a869dd79a53134494b483 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Feb 2023 10:04:14 +0000 Subject: [PATCH 37/58] Update after #2578 --- apps/messageicons/icons.img | Bin 5168 -> 5244 bytes apps/messageicons/lib.js | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/messageicons/icons.img b/apps/messageicons/icons.img index 104168357f754ea3bd419eb544afd41ea7d297f9..66ecb53f8eec12eb8eb1859d9c7bb41ee5f77e16 100644 GIT binary patch delta 82 zcmdm>@ke9B9(Gp-2;l$207UG67#ROBFxW8u-vdMp|K~8+&tYKivH#uxMDm{-_&+x= Xd~9I&zyL)B3=9S!{hPP4SMvY>niCt} delta 12 TcmeyPu|Z?Q9`?-~93?yeB~=8o diff --git a/apps/messageicons/lib.js b/apps/messageicons/lib.js index 9b293e608..f7efa2d16 100644 --- a/apps/messageicons/lib.js +++ b/apps/messageicons/lib.js @@ -2,7 +2,7 @@ exports.getImage = function(msg) { if (msg.img) return atob(msg.img); let s = (("string"=== typeof msg) ? msg : (msg.src || "")).toLowerCase(); if (msg.id=="music") s="music"; - let match = ",default|0,airbnb|1,alarm|2,alarmclockreceiver|2,amazon shopping|3,bibel|4,bitwarden|5,1password|5,lastpass|5,dashlane|5,bring|6,calendar|7,etar|7,chat|8,chrome|9,clock|2,corona-warn|10,bmo|11,desjardins|11,rbc mobile|11,nbc|11,rabobank|11,scotiabank|11,td (canada)|11,discord|12,drive|13,element|14,facebook|15,messenger|16,firefox|17,firefox beta|17,firefox nightly|17,f-droid|5,neo store|5,aurora droid|5,github|18,gitlab|19,gmx|20,google|21,google home|22,google play store|23,home assistant|24,instagram|25,kalender|26,keep notes|27,lieferando|28,linkedin|29,maps|30,organic maps|30,osmand|30,mastodon|31,fedilab|31,tooot|31,tusky|31,mattermost|32,n26|33,netflix|34,news|35,cbc news|35,rc info|35,reuters|35,ap news|35,la presse|35,nbc news|35,nextbike|36,nina|37,outlook mail|38,paypal|39,phone|40,plex|41,pocket|42,post & dhl|43,proton mail|44,reddit|45,sync pro|45,sync dev|45,boost|45,infinity|45,slide|45,signal|46,skype|47,slack|48,snapchat|49,starbucks|50,steam|51,teams|52,telegram|53,telegram foss|53,threema|54,tiktok|55,to do|56,opentasks|56,tasks|56,transit|57,twitch|58,twitter|59,uber|60,lyft|60,vlc|61,warnapp|62,whatsapp|63,wordfeud|64,youtube|65,newpipe|65,zoom|66,meet|66,music|67,sms message|0,mail|0,gmail|0,".match(new RegExp(`,${s}\\|(\\d+)`)) + let match = ",default|0,airbnb|1,alarm|2,alarmclockreceiver|2,amazon shopping|3,bibel|4,bitwarden|5,1password|5,lastpass|5,dashlane|5,bring|6,calendar|7,etar|7,chat|8,chrome|9,clock|2,corona-warn|10,bmo|11,desjardins|11,rbc mobile|11,nbc|11,rabobank|11,scotiabank|11,td (canada)|11,discord|12,drive|13,element|14,facebook|15,messenger|16,firefox|17,firefox beta|17,firefox nightly|17,f-droid|5,neo store|5,aurora droid|5,github|18,gitlab|19,gmx|20,google|21,google home|22,google play store|23,home assistant|24,instagram|25,jira|26,kalender|27,keep notes|28,lieferando|29,linkedin|30,maps|31,organic maps|31,osmand|31,mastodon|32,fedilab|32,tooot|32,tusky|32,mattermost|33,n26|34,netflix|35,news|36,cbc news|36,rc info|36,reuters|36,ap news|36,la presse|36,nbc news|36,nextbike|37,nina|38,outlook mail|39,paypal|40,phone|41,plex|42,pocket|43,post & dhl|44,proton mail|45,reddit|46,sync pro|46,sync dev|46,boost|46,infinity|46,slide|46,signal|47,skype|48,slack|49,snapchat|50,starbucks|51,steam|52,teams|53,telegram|54,telegram foss|54,threema|55,tiktok|56,to do|57,opentasks|57,tasks|57,transit|58,twitch|59,twitter|60,uber|61,lyft|61,vlc|62,warnapp|63,whatsapp|64,wordfeud|65,youtube|66,newpipe|66,zoom|67,meet|67,music|68,sms message|0,mail|0,gmail|0,".match(new RegExp(`,${s}\\|(\\d+)`)) return require("Storage").read("messageicons.img", (match===null)?0:match[1]*76, 76); }; @@ -13,6 +13,7 @@ exports.getColor = function(msg,options) { if (st.iconColorMode == 'mono') return options.default; const s = (("string"=== typeof msg) ? msg : (msg.src || "")).toLowerCase(); return { + // This file is generated by /icons/generate.js. If you need to modify its content, you should do it there instead. // generic colors, using B2-safe colors // DO NOT USE BLACK OR WHITE HERE, just leave the declaration out and then the theme's fg color will be used "airbnb": "#ff385c", // https://news.airbnb.com/media-assets/category/brand/ @@ -66,4 +67,4 @@ exports.getColor = function(msg,options) { "youtube": "#f00", // https://www.youtube.com/howyoutubeworks/resources/brand-resources/#logos-icons-and-colors }[s]||options.default; }; - + \ No newline at end of file From 5ebb56e95028ffb41dc65a281e6d65a2948e3809 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Feb 2023 11:00:06 +0000 Subject: [PATCH 38/58] run: Keep run state between runs (allowing you to exit and restart the app) --- apps/run/ChangeLog | 1 + apps/run/app.js | 17 +++++++++++------ apps/run/metadata.json | 2 +- apps/runplus/ChangeLog | 1 + apps/runplus/app.js | 17 +++++++++++------ modules/exstats.js | 15 +++++++++++++-- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/apps/run/ChangeLog b/apps/run/ChangeLog index 95945be78..3638407ef 100644 --- a/apps/run/ChangeLog +++ b/apps/run/ChangeLog @@ -13,3 +13,4 @@ 0.12: Fix for recorder not stopping at end of run. Bug introduced in 0.11 0.13: Revert #1578 (stop duplicate entries) as with 2v12 menus it causes other boxes to be wiped (fix #1643) 0.14: Fix Bangle.js 1 issue where after the 'overwrite track' menu, the start/stop button stopped working +0.15: Keep run state between runs (allowing you to exit and restart the app) diff --git a/apps/run/app.js b/apps/run/app.js index 4038b8c1a..a56fce31c 100644 --- a/apps/run/app.js +++ b/apps/run/app.js @@ -41,6 +41,13 @@ var statIDs = [settings.B1,settings.B2,settings.B3,settings.B4,settings.B5,setti var exs = ExStats.getStats(statIDs, settings); // --------------------------- +function setStatus(running) { + layout.button.label = running ? "STOP" : "START"; + layout.status.label = running ? "RUN" : "STOP"; + layout.status.bgCol = running ? "#0f0" : "#f00"; + layout.render(); +} + // Called to start/stop running function onStartStop() { var running = !exs.state.active; @@ -77,12 +84,9 @@ function onStartStop() { } else { exs.stop(); } - layout.button.label = running ? "STOP" : "START"; - layout.status.label = running ? "RUN" : "STOP"; - layout.status.bgCol = running ? "#0f0" : "#f00"; // if stopping running, don't clear state // so we can at least refer to what we've done - layout.render(); + setStatus(running); }); } @@ -105,13 +109,14 @@ for (var i=0;i{if (karvonnenActive) {stopKarvonnenUI();run();} onStartStop();}, id:"button"}]}); +},{lazy:true, btns:[{ label:"---", cb: ()=>{if (karvonnenActive) {stopKarvonnenUI();run();} onStartStop();}, id:"button"}]}); delete lc; +setStatus(exs.state.active); layout.render(); function configureNotification(stat) { diff --git a/modules/exstats.js b/modules/exstats.js index 461ae727f..1d3e27d0a 100644 --- a/modules/exstats.js +++ b/modules/exstats.js @@ -93,6 +93,16 @@ var state = { // list of active stats (indexed by ID) var stats = {}; +const DATA_FILE = "exstats.json"; +// Load the state from a saved file if there was one +state = Object.assign(state, require("Storage").readJSON(DATA_FILE,1)||{}); +// force step history to a uint8array +state.stepHistory = new Uint8Array(state.stepHistory); +// when we exit, write the current state +E.on('kill', function() { + require("Storage").writeJSON(DATA_FILE, state); +}); + // distance between 2 lat and lons, in meters, Mean Earth Radius = 6371km // https://www.movable-type.co.uk/scripts/latlong.html // (Equirectangular approximation) @@ -359,9 +369,10 @@ exports.getStats = function(statIDs, options) { state.notify.time.next = state.startTime + options.notify.time.increment; } } - reset(); + if (!state.active) reset(); // we might already be active return { - stats : stats, state : state, + stats : stats, + state : state, start : function() { state.active = true; reset(); From 8bc9c5de2583505efaafea45f4883ead1ba50ba6 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Feb 2023 11:19:24 +0000 Subject: [PATCH 39/58] messagegui 0.65: Make sure messages are saved if not in the clock app (fix #2460) --- apps/messagegui/ChangeLog | 1 + apps/messagegui/lib.js | 2 +- apps/messagegui/metadata.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/messagegui/ChangeLog b/apps/messagegui/ChangeLog index d061e6642..f314c72d3 100644 --- a/apps/messagegui/ChangeLog +++ b/apps/messagegui/ChangeLog @@ -87,3 +87,4 @@ 0.62: Remove '.show' field, tidyup and fix .open if fast load not enabled 0.63: Fix messages app loading on clock without fast load 0.64: Ensure we don't get 'undefined' as the message body +0.65: Make sure messages are saved if not in the clock app (fix #2460) diff --git a/apps/messagegui/lib.js b/apps/messagegui/lib.js index a9436a77b..54d79866a 100644 --- a/apps/messagegui/lib.js +++ b/apps/messagegui/lib.js @@ -29,7 +29,7 @@ exports.listener = function(type, msg) { } const appSettings = require("Storage").readJSON("messages.settings.json", 1) || {}; - let loadMessages = (Bangle.CLOCK || event.important); // should we load the messages app? + let loadMessages = (Bangle.CLOCK || msg.important); // should we load the messages app? if (type==="music") { if (Bangle.CLOCK && msg.state && msg.title && appSettings.openMusic) loadMessages = true; else return; diff --git a/apps/messagegui/metadata.json b/apps/messagegui/metadata.json index 3504122f9..1e22f7304 100644 --- a/apps/messagegui/metadata.json +++ b/apps/messagegui/metadata.json @@ -2,7 +2,7 @@ "id": "messagegui", "name": "Message UI", "shortName": "Messages", - "version": "0.64", + "version": "0.65", "description": "Default app to display notifications from iOS and Gadgetbridge/Android", "icon": "app.png", "type": "app", From 0ba8cef33c1a313626e204cd811ed02a58381d11 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Feb 2023 11:46:49 +0000 Subject: [PATCH 40/58] Convert Yes/No On/Off in settings to checkboxes, add /*LANG*/ to some more text strings --- apps/accellog/ChangeLog | 1 + apps/accellog/app.js | 3 +-- apps/accellog/metadata.json | 2 +- apps/android/settings.js | 2 +- apps/bthrm/bthrm.js | 2 +- apps/clockcal/ChangeLog | 1 + apps/clockcal/metadata.json | 2 +- apps/clockcal/settings.js | 19 +++++----------- apps/cscsensor/ChangeLog | 1 + apps/cscsensor/metadata.json | 2 +- apps/cscsensor/settings.js | 8 +++---- apps/f9lander/ChangeLog | 1 + apps/f9lander/metadata.json | 2 +- apps/f9lander/settings.js | 4 +--- apps/fileman/fileman.app.js | 2 +- apps/gbridge/settings.js | 14 ++++++------ apps/gipy/ChangeLog | 2 ++ apps/gipy/metadata.json | 2 +- apps/gipy/settings.js | 3 +-- apps/homework/app.js | 4 ++-- apps/info/info.app.js | 10 ++++----- apps/kbtouch/ChangeLog | 1 + apps/kbtouch/metadata.json | 2 +- apps/kbtouch/settings.js | 28 +++++++++--------------- apps/marioclock/marioclock-app.js | 2 +- apps/neonx/ChangeLog | 3 ++- apps/neonx/metadata.json | 2 +- apps/neonx/neonx.settings.js | 26 +++++++++------------- apps/numerals/ChangeLog | 3 ++- apps/numerals/metadata.json | 2 +- apps/numerals/numerals.settings.js | 6 ++--- apps/powermanager/ChangeLog | 1 + apps/powermanager/metadata.json | 2 +- apps/powermanager/settings.js | 1 - apps/recorder/ChangeLog | 1 + apps/recorder/app.js | 1 - apps/recorder/metadata.json | 2 +- apps/setting/ChangeLog | 1 + apps/setting/metadata.json | 2 +- apps/setting/settings.js | 12 ---------- apps/sleepphasealarm/ChangeLog | 1 + apps/sleepphasealarm/metadata.json | 2 +- apps/sleepphasealarm/settings.js | 1 - apps/slidingtext/ChangeLog | 1 + apps/slidingtext/metadata.json | 2 +- apps/slidingtext/slidingtext.settings.js | 5 ++--- apps/slomoclock/settings.js | 14 ++++++------ apps/waypointer/ChangeLog | 1 + apps/waypointer/metadata.json | 2 +- apps/waypointer/settings.js | 1 - apps/widalarmeta/ChangeLog | 1 + apps/widalarmeta/metadata.json | 2 +- apps/widalarmeta/settings.js | 1 - apps/widdst/ChangeLog | 1 + apps/widdst/metadata.json | 2 +- apps/widdst/settings.js | 20 ++++++++--------- 56 files changed, 106 insertions(+), 136 deletions(-) diff --git a/apps/accellog/ChangeLog b/apps/accellog/ChangeLog index 94241c7a7..45469da5c 100644 --- a/apps/accellog/ChangeLog +++ b/apps/accellog/ChangeLog @@ -3,3 +3,4 @@ 0.03: Exit as first menu option, dont show decimal places for seconds 0.04: Localisation, change Exit->Back to allow back-arrow to appear on 2v13 firmware 0.05: Add max G values during recording, record actual G values and magnitude to CSV +0.06: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/accellog/app.js b/apps/accellog/app.js index 147f7503f..ee82f435f 100644 --- a/apps/accellog/app.js +++ b/apps/accellog/app.js @@ -26,8 +26,7 @@ function showMenu() { viewLogs(); }, /*LANG*/"Log raw data" : { - value : logRawData, - format : v => v?/*LANG*/"Yes":/*LANG*/"No", + value : !!logRawData, onchange : v => { logRawData=v; } }, }; diff --git a/apps/accellog/metadata.json b/apps/accellog/metadata.json index 903c57903..907828c7f 100644 --- a/apps/accellog/metadata.json +++ b/apps/accellog/metadata.json @@ -2,7 +2,7 @@ "id": "accellog", "name": "Acceleration Logger", "shortName": "Accel Log", - "version": "0.05", + "version": "0.06", "description": "Logs XYZ acceleration data to a CSV file that can be downloaded to your PC", "icon": "app.png", "tags": "outdoor", diff --git a/apps/android/settings.js b/apps/android/settings.js index 0abb32249..1cfc8927c 100644 --- a/apps/android/settings.js +++ b/apps/android/settings.js @@ -12,7 +12,7 @@ var mainmenu = { "" : { "title" : "Android" }, "< Back" : back, - /*LANG*/"Connected" : { value : NRF.getSecurityStatus().connected?"Yes":"No" }, + /*LANG*/"Connected" : { value : NRF.getSecurityStatus().connected?/*LANG*/"Yes":/*LANG*/"No" }, /*LANG*/"Find Phone" : () => E.showMenu({ "" : { "title" : /*LANG*/"Find Phone" }, "< Back" : ()=>E.showMenu(mainmenu), diff --git a/apps/bthrm/bthrm.js b/apps/bthrm/bthrm.js index b07e7bd37..246b539d4 100644 --- a/apps/bthrm/bthrm.js +++ b/apps/bthrm/bthrm.js @@ -96,7 +96,7 @@ function draw(){ if (!isNaN(bt.battery)) layout.btBattery.label = bt.battery + "%"; if (bt.rr) layout.btRR.label = bt.rr.join(","); if (!isNaN(bt.location)) layout.btLocation.label = BODY_LOCS[bt.location]; - if (bt.contact !== undefined) layout.btContact.label = bt.contact ? "Yes":"No"; + if (bt.contact !== undefined) layout.btContact.label = bt.contact ? /*LANG*/"Yes":/*LANG*/"No"; if (!isNaN(bt.energy)) layout.btEnergy.label = bt.energy.toFixed(0) + "kJ"; } else { layout.bt.label = "--"; diff --git a/apps/clockcal/ChangeLog b/apps/clockcal/ChangeLog index 27d4fc7f4..4c8c13366 100644 --- a/apps/clockcal/ChangeLog +++ b/apps/clockcal/ChangeLog @@ -4,3 +4,4 @@ 0.04: Use default Bangle formatter for booleans 0.05: Improved colors (connected vs disconnected) 0.06: Tell clock widgets to hide. +0.07: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/clockcal/metadata.json b/apps/clockcal/metadata.json index 872211495..03f5c3df2 100644 --- a/apps/clockcal/metadata.json +++ b/apps/clockcal/metadata.json @@ -1,7 +1,7 @@ { "id": "clockcal", "name": "Clock & Calendar", - "version": "0.06", + "version": "0.07", "description": "Clock with Calendar", "readme":"README.md", "icon": "app.png", diff --git a/apps/clockcal/settings.js b/apps/clockcal/settings.js index d4cc4df68..4d8be6fbd 100644 --- a/apps/clockcal/settings.js +++ b/apps/clockcal/settings.js @@ -16,7 +16,7 @@ actions = ["[ignore]","[calend.]","[AI:music]","[AI:messg]"]; require("Storage").list(RegExp(".app.js")).forEach(element => actions.push(element.replace(".app.js",""))); - + function writeSettings() { require('Storage').writeJSON(FILE, settings); } @@ -106,18 +106,11 @@ writeSettings(); } }, - 'Load deafauls?': { - value: 0, - min: 0, max: 1, - format: v => ["No", "Yes"][v], - onchange: v => { - if (v == 1) { - settings = defaults; - writeSettings(); - load(); - } - } - }, + 'Load defaults': () => { + settings = defaults; + writeSettings(); + load(); + } }; // Show the menu E.showMenu(menu); diff --git a/apps/cscsensor/ChangeLog b/apps/cscsensor/ChangeLog index a98be5c0f..5264e8d42 100644 --- a/apps/cscsensor/ChangeLog +++ b/apps/cscsensor/ChangeLog @@ -6,3 +6,4 @@ 0.06: Now read wheel rev as well as cadence sensor Improve connection code 0.07: Make Bangle.js 2 compatible +0.08: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/cscsensor/metadata.json b/apps/cscsensor/metadata.json index 4006789ef..ba250c914 100644 --- a/apps/cscsensor/metadata.json +++ b/apps/cscsensor/metadata.json @@ -2,7 +2,7 @@ "id": "cscsensor", "name": "Cycling speed sensor", "shortName": "CSCSensor", - "version": "0.07", + "version": "0.08", "description": "Read BLE enabled cycling speed and cadence sensor and display readings on watch", "icon": "icons8-cycling-48.png", "tags": "outdoors,exercise,ble,bluetooth", diff --git a/apps/cscsensor/settings.js b/apps/cscsensor/settings.js index d7a7d565d..4fac5d0c1 100644 --- a/apps/cscsensor/settings.js +++ b/apps/cscsensor/settings.js @@ -23,17 +23,17 @@ } } const menu = { - '': { 'title': 'Cycle speed sensor' }, + '': { 'title': /*LANG*/'Cycle speed sensor' }, '< Back': back, - 'Wheel circ.(mm)': { + /*LANG*/'Wheel circ.(mm)': { value: s.wheelcirc, min: 800, max: 2400, step: 5, onchange: save('wheelcirc'), }, - 'Reset total distance': function() { - E.showPrompt("Zero total distance?", {buttons: {"No":false, "Yes":true}}).then(function(v) { + /*LANG*/'Reset total distance': function() { + E.showPrompt(/*LANG*/"Zero total distance?", {buttons: {/*LANG*/"No":false, /*LANG*/"Yes":true}}).then(function(v) { if (v) { s['totaldist'] = 0; storage.write(SETTINGS_FILE, s); diff --git a/apps/f9lander/ChangeLog b/apps/f9lander/ChangeLog index a13f2a313..b5a33bd2e 100644 --- a/apps/f9lander/ChangeLog +++ b/apps/f9lander/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Add lightning +0.03: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/f9lander/metadata.json b/apps/f9lander/metadata.json index 1db777099..e53805ee0 100644 --- a/apps/f9lander/metadata.json +++ b/apps/f9lander/metadata.json @@ -1,7 +1,7 @@ { "id": "f9lander", "name": "Falcon9 Lander", "shortName":"F9lander", - "version":"0.02", + "version":"0.03", "description": "Land a rocket booster", "icon": "f9lander.png", "screenshots" : [ { "url":"f9lander_screenshot1.png" }, { "url":"f9lander_screenshot2.png" }, { "url":"f9lander_screenshot3.png" }], diff --git a/apps/f9lander/settings.js b/apps/f9lander/settings.js index 0f9fba302..9d85da394 100644 --- a/apps/f9lander/settings.js +++ b/apps/f9lander/settings.js @@ -2,7 +2,6 @@ /** * @param {function} back Use back() to return to settings menu */ -const boolFormat = v => v ? /*LANG*/"On" : /*LANG*/"Off"; (function(back) { const SETTINGS_FILE = 'f9settings.json' // initialize with default settings... @@ -27,8 +26,7 @@ const boolFormat = v => v ? /*LANG*/"On" : /*LANG*/"Off"; '': { 'title': 'OpenWind' }, '< Back': back, 'Lightning': { - value: settings.lightning, - format: boolFormat, + value: !!settings.lightning, onchange: save('lightning'), } } diff --git a/apps/fileman/fileman.app.js b/apps/fileman/fileman.app.js index 6a3c5598d..5baae298b 100644 --- a/apps/fileman/fileman.app.js +++ b/apps/fileman/fileman.app.js @@ -7,7 +7,7 @@ var m; var files; function delete_file(fn) { - E.showPrompt("Delete\n"+fn+"?", {buttons: {"No":false, "Yes":true}}).then(function(v) { + E.showPrompt(/*LANG*/"Delete\n"+fn+"?", {buttons: {/*LANG*/"No":false, /*LANG*/"Yes":true}}).then(function(v) { if (v) { if (fn.charCodeAt(fn.length-1)==1) { var fh = STOR.open(fn.substr(0, fn.length-1), "r"); diff --git a/apps/gbridge/settings.js b/apps/gbridge/settings.js index cf6c84c73..ae63bb0f9 100644 --- a/apps/gbridge/settings.js +++ b/apps/gbridge/settings.js @@ -24,22 +24,22 @@ var mainmenu = { "" : { "title" : "Gadgetbridge" }, "< Back" : back, - "Connected" : { value : NRF.getSecurityStatus().connected?"Yes":"No" }, - "Show Icon" : { + /*LANG*/"Connected" : { value : NRF.getSecurityStatus().connected?/*LANG*/"Yes":/*LANG*/"No" }, + /*LANG*/"Show Icon" : { value: settings().showIcon, onchange: setIcon }, - "Find Phone" : function() { E.showMenu(findPhone); }, - "Record HRM" : { + /*LANG*/"Find Phone" : function() { E.showMenu(findPhone); }, + /*LANG*/"Record HRM" : { value: !!settings().hrm, onchange: v => updateSetting('hrm', v) - } + } }; var findPhone = { "" : { "title" : "-- Find Phone --" }, - "On" : _=>gb({t:"findPhone",n:true}), - "Off" : _=>gb({t:"findPhone",n:false}), + /*LANG*/"On" : _=>gb({t:"findPhone",n:true}), + /*LANG*/"Off" : _=>gb({t:"findPhone",n:false}), "< Back" : function() { E.showMenu(mainmenu); }, }; diff --git a/apps/gipy/ChangeLog b/apps/gipy/ChangeLog index f913c9e58..bfb2f4282 100644 --- a/apps/gipy/ChangeLog +++ b/apps/gipy/ChangeLog @@ -73,3 +73,5 @@ * Display current and next segment in red so that you know where to go. * Avoid angles flickering at low speed at the cost of less refresh. * Splash screen while waiting for gps signal. + +0.17: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/gipy/metadata.json b/apps/gipy/metadata.json index 97d18f5fe..f0581d578 100644 --- a/apps/gipy/metadata.json +++ b/apps/gipy/metadata.json @@ -2,7 +2,7 @@ "id": "gipy", "name": "Gipy", "shortName": "Gipy", - "version": "0.16", + "version": "0.17", "description": "Follow gpx files using the gps. Don't get lost in your bike trips and hikes.", "allow_emulator":false, "icon": "gipy.png", diff --git a/apps/gipy/settings.js b/apps/gipy/settings.js index af9cbef22..d43a557f6 100644 --- a/apps/gipy/settings.js +++ b/apps/gipy/settings.js @@ -19,8 +19,7 @@ "< Back": () => back(), "keep gps alive": { value: !!settings.keep_gps_alive, // !! converts undefined to false - format: (v) => (v ? "Yes" : "No"), - onchange: (v) => { + onchange: v => { settings.keep_gps_alive = v; writeSettings(); }, diff --git a/apps/homework/app.js b/apps/homework/app.js index 3d9be31c9..a6ad331f0 100644 --- a/apps/homework/app.js +++ b/apps/homework/app.js @@ -46,8 +46,8 @@ var mainMenu = { "Reset Homework": function() { E.showPrompt("Are you sure you want to delete homework.txt?", { buttons: { - "No": false, - "Yes": true + /*LANG*/"No": false, + /*LANG*/"Yes": true } }).then(function(v) { if (v) { diff --git a/apps/info/info.app.js b/apps/info/info.app.js index ade3f3ebb..d97f780da 100644 --- a/apps/info/info.app.js +++ b/apps/info/info.app.js @@ -21,11 +21,11 @@ var screens = [ name: "Hardware", items: [ {name: "Battery", fun: () => E.getBattery() + "%"}, - {name: "Charge?", fun: () => Bangle.isCharging() ? "Yes" : "No"}, + {name: "Charge?", fun: () => Bangle.isCharging() ? /*LANG*/"Yes" : /*LANG*/"No"}, {name: "TempInt.", fun: () => locale.temp(parseInt(E.getTemperature()))}, - {name: "Bluetooth", fun: () => NRF.getSecurityStatus().connected ? "Conn" : "NoConn"}, - {name: "GPS", fun: () => Bangle.isGPSOn() ? "On" : "Off"}, - {name: "Compass", fun: () => Bangle.isCompassOn() ? "On" : "Off"}, + {name: "Bluetooth", fun: () => NRF.getSecurityStatus().connected ? /*LANG*/"Conn" : /*LANG*/"NoConn"}, + {name: "GPS", fun: () => Bangle.isGPSOn() ? /*LANG*/"On" : /*LANG*/"Off"}, + {name: "Compass", fun: () => Bangle.isCompassOn() ? /*LANG*/"On" : /*LANG*/"Off"}, ] }, { @@ -160,4 +160,4 @@ Bangle.on('lock', function(isLocked) { }); Bangle.loadWidgets(); -Bangle.drawWidgets(); \ No newline at end of file +Bangle.drawWidgets(); diff --git a/apps/kbtouch/ChangeLog b/apps/kbtouch/ChangeLog index 17e824c00..5bd2159e6 100644 --- a/apps/kbtouch/ChangeLog +++ b/apps/kbtouch/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Introduced settings to customize the layout and functionality of the keyboard. +0.03: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/kbtouch/metadata.json b/apps/kbtouch/metadata.json index 89d121d63..8d7434e44 100644 --- a/apps/kbtouch/metadata.json +++ b/apps/kbtouch/metadata.json @@ -1,6 +1,6 @@ { "id": "kbtouch", "name": "Touch keyboard", - "version":"0.02", + "version":"0.03", "description": "A library for text input via onscreen keyboard", "icon": "app.png", "type":"textinput", diff --git a/apps/kbtouch/settings.js b/apps/kbtouch/settings.js index 871cc5d32..227efaf2d 100644 --- a/apps/kbtouch/settings.js +++ b/apps/kbtouch/settings.js @@ -8,13 +8,13 @@ if (settings.speedScaling===undefined) settings.speedScaling=24; return settings; } - + function updateSetting(setting, value) { let settings = require('Storage').readJSON("kbtouch.settings.json", true) || {}; settings[setting] = value; require('Storage').writeJSON("kbtouch.settings.json", settings); } - + var mainmenu = { "" : { "title" : /*LANG*/"Touch Keyboard" }, "< Back" : back, @@ -25,22 +25,16 @@ onchange: v => updateSetting("textSize", v) }, /*LANG*/'Offset keyboard': { - value: settings().offsetKeyboard, - min: 0, max: 1, - format: v => [/*LANG*/"No",/*LANG*/"Yes"][v], - onchange: v => updateSetting("offsetKeyboard", v) + value: !!settings().offsetKeyboard, + onchange: v => updateSetting("offsetKeyboard", v?1:0) }, /*LANG*/'Loop around': { - value: settings().loopAround, - min: 0, max: 1, - format: v => [/*LANG*/"No",/*LANG*/"Yes"][v], - onchange: v => updateSetting("loopAround", v) + value: !!settings().loopAround, + onchange: v => updateSetting("loopAround", v?1:0) }, /*LANG*/'One-to-one input and release to select': { - value: settings().oneToOne, - min: 0, max: 1, - format: v => [/*LANG*/"No",/*LANG*/"Yes"][v], - onchange: v => updateSetting("oneToOne", v) + value: !!settings().oneToOne, + onchange: v => updateSetting("oneToOne", v?1:0) }, /*LANG*/'Speed scaling': { value: settings().speedScaling, @@ -49,10 +43,8 @@ onchange: v => updateSetting("speedScaling", v) } ///*LANG*/'Release to select': { - // value: 1|settings().fontSize, - // min: 0, max: 1, - // format: v => [/*LANG*/"No",/*LANG*/"Yes"][v], - // onchange: v => updateSetting("releaseToSelect", v) + // value: !!(1|settings().fontSize), + // onchange: v => updateSetting("releaseToSelect", v?1:0) //} }; E.showMenu(mainmenu); diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index 6289a2568..ee6371f4e 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -73,7 +73,7 @@ let lastTemp = 0; const phone = { get status() { - return NRF.getSecurityStatus().connected ? "Yes" : "No"; + return NRF.getSecurityStatus().connected ? /*LANG*/"Yes" : /*LANG*/"No"; }, message: null, messageTimeout: null, diff --git a/apps/neonx/ChangeLog b/apps/neonx/ChangeLog index e78686a00..b055d6a15 100644 --- a/apps/neonx/ChangeLog +++ b/apps/neonx/ChangeLog @@ -3,4 +3,5 @@ 0.03: Optional show lock status via color 0.04: Ensure that widgets are always hidden in fullscreen mode 0.05: Better lock/unlock animation -0.06: Use widget_utils. +0.06: Use widget_utils +0.07: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/neonx/metadata.json b/apps/neonx/metadata.json index c273cb05a..edd0e76b8 100644 --- a/apps/neonx/metadata.json +++ b/apps/neonx/metadata.json @@ -2,7 +2,7 @@ "id": "neonx", "name": "Neon X & IO X Clock", "shortName": "Neon X Clock", - "version": "0.06", + "version": "0.07", "description": "Pebble Neon X & Neon IO X for Bangle.js", "icon": "neonx.png", "type": "clock", diff --git a/apps/neonx/neonx.settings.js b/apps/neonx/neonx.settings.js index 68e156dae..8edaf5c50 100644 --- a/apps/neonx/neonx.settings.js +++ b/apps/neonx/neonx.settings.js @@ -25,11 +25,9 @@ "" : { "title":"Neon X & IO"}, "< Back": back, "Neon IO X": { - value: 0 | neonXSettings.io, - min: 0, max: 1, - format: v => v ? "On" : "Off", + value: !!neonXSettings.io, onchange: v => { - neonXSettings.io = v; + neonXSettings.io = v?1:0; updateSettings(); } }, @@ -43,27 +41,23 @@ } }, "Date on touch": { - value: 0 | neonXSettings.showDate, - min: 0, max: 1, - format: v => v ? "On" : "Off", + value: !!neonXSettings.showDate, onchange: v => { - neonXSettings.showDate = v; + neonXSettings.showDate = v?1:0; updateSettings(); } }, 'Fullscreen': { - value: false | neonXSettings.fullscreen, - format: () => (neonXSettings.fullscreen ? 'Yes' : 'No'), - onchange: () => { - neonXSettings.fullscreen = !neonXSettings.fullscreen; + value: !!neonXSettings.fullscreen, + onchange: v => { + neonXSettings.fullscreen = v; updateSettings(); }, }, 'Show lock': { - value: false | neonXSettings.showLock, - format: () => (neonXSettings.showLock ? 'Yes' : 'No'), - onchange: () => { - neonXSettings.showLock = !neonXSettings.showLock; + value: !!neonXSettings.showLock, + onchange: v => { + neonXSettings.showLock = v; updateSettings(); }, }, diff --git a/apps/numerals/ChangeLog b/apps/numerals/ChangeLog index 57818c180..d6703a96b 100644 --- a/apps/numerals/ChangeLog +++ b/apps/numerals/ChangeLog @@ -7,4 +7,5 @@ 0.07: Add date on touch and some improvements (see settings and readme) 0.08: Add new draw styles, tidy up draw functionality 0.09: Tweak for faster rendering -0.10: Enhance for use with Bangle2, insert new draw mode 'thickfill' \ No newline at end of file +0.10: Enhance for use with Bangle2, insert new draw mode 'thickfill' +0.11: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/numerals/metadata.json b/apps/numerals/metadata.json index 6ba850d86..6a1adc810 100644 --- a/apps/numerals/metadata.json +++ b/apps/numerals/metadata.json @@ -2,7 +2,7 @@ "id": "numerals", "name": "Numerals Clock", "shortName": "Numerals Clock", - "version": "0.10", + "version": "0.11", "description": "A simple big numerals clock", "icon": "numerals.png", "type": "clock", diff --git a/apps/numerals/numerals.settings.js b/apps/numerals/numerals.settings.js index ae321322a..b4d5d4286 100644 --- a/apps/numerals/numerals.settings.js +++ b/apps/numerals/numerals.settings.js @@ -30,10 +30,8 @@ onchange: v=> { numeralsSettings.drawMode=dm[v]; updateSettings();} }, "Date on touch": { - value: 0|numeralsSettings.showDate, - min:0,max:1, - format: v=>v?"On":"Off", - onchange: v=> { numeralsSettings.showDate=v; updateSettings();} + value: !!numeralsSettings.showDate, + onchange: v=> { numeralsSettings.showDate=v?1:0; updateSettings();} }, "< back": back }; diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog index fd8ce0679..a43558c3f 100644 --- a/apps/powermanager/ChangeLog +++ b/apps/powermanager/ChangeLog @@ -6,3 +6,4 @@ 0.05: Add back button to settings menu. 0.06: Allow logging of some things using power Add widget for live monitoring of power use +0.07: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index efb290892..ca5a9f00b 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -2,7 +2,7 @@ "id": "powermanager", "name": "Power Manager", "shortName": "Power Manager", - "version": "0.06", + "version": "0.07", "description": "Allow configuration of warnings and thresholds for battery charging and display.", "icon": "app.png", "type": "bootloader", diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js index 1e6c073be..fa186bfac 100644 --- a/apps/powermanager/settings.js +++ b/apps/powermanager/settings.js @@ -106,7 +106,6 @@ }, 'Enabled': { value: !!settings.warnEnabled, - format: v => settings.warnEnabled ? "On" : "Off", onchange: v => { writeSettings("warnEnabled", v); } diff --git a/apps/recorder/ChangeLog b/apps/recorder/ChangeLog index c4d1fa8c1..c3e20ed34 100644 --- a/apps/recorder/ChangeLog +++ b/apps/recorder/ChangeLog @@ -25,3 +25,4 @@ 0.19: Fix track plotting code 0.20: Automatic translation of some more strings. 0.21: Speed report now uses speed units from locale +0.22: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/recorder/app.js b/apps/recorder/app.js index 8ac3ff627..972a9580d 100644 --- a/apps/recorder/app.js +++ b/apps/recorder/app.js @@ -56,7 +56,6 @@ function showMainMenu() { '< Back': ()=>{load();}, /*LANG*/'RECORD': { value: !!settings.recording, - format: v=>v?/*LANG*/"On":/*LANG*/"Off", onchange: v => { setTimeout(function() { E.showMenu(); diff --git a/apps/recorder/metadata.json b/apps/recorder/metadata.json index 45d588d99..60abeadef 100644 --- a/apps/recorder/metadata.json +++ b/apps/recorder/metadata.json @@ -2,7 +2,7 @@ "id": "recorder", "name": "Recorder", "shortName": "Recorder", - "version": "0.21", + "version": "0.22", "description": "Record GPS position, heart rate and more in the background, then download to your PC.", "icon": "app.png", "tags": "tool,outdoors,gps,widget", diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index 9a5579f07..8f14d0419 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -63,3 +63,4 @@ 0.56: make System menu items shorter and more consistant, Eg 'Clock', intead of 'Select Clock' 0.57: Settings.log = 0,1,2,3 for off,display,log,both +0.58: On/Off settings items now use checkboxes diff --git a/apps/setting/metadata.json b/apps/setting/metadata.json index 6d5739d03..ab029f1e5 100644 --- a/apps/setting/metadata.json +++ b/apps/setting/metadata.json @@ -1,7 +1,7 @@ { "id": "setting", "name": "Settings", - "version": "0.57", + "version": "0.58", "description": "A menu for setting up Bangle.js", "icon": "settings.png", "tags": "tool,system", diff --git a/apps/setting/settings.js b/apps/setting/settings.js index bc5f2a74a..db3e476b7 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -64,8 +64,6 @@ if (("object" != typeof settings) || ("object" != typeof settings.options)) resetSettings(); -const boolFormat = v => v ? /*LANG*/"On" : /*LANG*/"Off"; - function showMainMenu() { const mainmenu = { @@ -102,7 +100,6 @@ function showAlertsMenu() { if (BANGLEJS2) { beepMenuItem = { value: settings.beep!=false, - format: boolFormat, onchange: v => { settings.beep = v; updateSettings(); @@ -134,7 +131,6 @@ function showAlertsMenu() { /*LANG*/'Beep': beepMenuItem, /*LANG*/'Vibration': { value: settings.vibrate, - format: boolFormat, onchange: () => { settings.vibrate = !settings.vibrate; updateSettings(); @@ -169,7 +165,6 @@ function showBLEMenu() { /*LANG*/'Make Connectable': ()=>makeConnectable(), /*LANG*/'BLE': { value: settings.ble, - format: boolFormat, onchange: () => { settings.ble = !settings.ble; updateSettings(); @@ -177,7 +172,6 @@ function showBLEMenu() { }, /*LANG*/'Programmable': { value: settings.blerepl, - format: boolFormat, onchange: () => { settings.blerepl = !settings.blerepl; updateSettings(); @@ -428,7 +422,6 @@ function showLCDMenu() { }, /*LANG*/'Wake on BTN1': { value: settings.options.wakeOnBTN1, - format: boolFormat, onchange: () => { settings.options.wakeOnBTN1 = !settings.options.wakeOnBTN1; updateOptions(); @@ -439,7 +432,6 @@ function showLCDMenu() { Object.assign(lcdMenu, { /*LANG*/'Wake on BTN2': { value: settings.options.wakeOnBTN2, - format: boolFormat, onchange: () => { settings.options.wakeOnBTN2 = !settings.options.wakeOnBTN2; updateOptions(); @@ -447,7 +439,6 @@ function showLCDMenu() { }, /*LANG*/'Wake on BTN3': { value: settings.options.wakeOnBTN3, - format: boolFormat, onchange: () => { settings.options.wakeOnBTN3 = !settings.options.wakeOnBTN3; updateOptions(); @@ -456,7 +447,6 @@ function showLCDMenu() { Object.assign(lcdMenu, { /*LANG*/'Wake on FaceUp': { value: settings.options.wakeOnFaceUp, - format: boolFormat, onchange: () => { settings.options.wakeOnFaceUp = !settings.options.wakeOnFaceUp; updateOptions(); @@ -464,7 +454,6 @@ function showLCDMenu() { }, /*LANG*/'Wake on Touch': { value: settings.options.wakeOnTouch, - format: boolFormat, onchange: () => { settings.options.wakeOnTouch = !settings.options.wakeOnTouch; updateOptions(); @@ -472,7 +461,6 @@ function showLCDMenu() { }, /*LANG*/'Wake on Twist': { value: settings.options.wakeOnTwist, - format: boolFormat, onchange: () => { settings.options.wakeOnTwist = !settings.options.wakeOnTwist; updateOptions(); diff --git a/apps/sleepphasealarm/ChangeLog b/apps/sleepphasealarm/ChangeLog index 4b119b571..b22db7170 100644 --- a/apps/sleepphasealarm/ChangeLog +++ b/apps/sleepphasealarm/ChangeLog @@ -17,3 +17,4 @@ 0.14: Reduce update interval of current time when seconds are not shown Limit logging on Bangle.js 1 to one day due to low memory Add plot logged data to settings +0.15: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/sleepphasealarm/metadata.json b/apps/sleepphasealarm/metadata.json index 147664728..4ad1588ea 100644 --- a/apps/sleepphasealarm/metadata.json +++ b/apps/sleepphasealarm/metadata.json @@ -2,7 +2,7 @@ "id": "sleepphasealarm", "name": "SleepPhaseAlarm", "shortName": "SleepPhaseAlarm", - "version": "0.14", + "version": "0.15", "description": "Uses the accelerometer to estimate sleep and wake states with the principle of Estimation of Stationary Sleep-segments (ESS, see https://ubicomp.eti.uni-siegen.de/home/datasets/ichi14/index.html.en). This app will read the next alarm from the alarm application and will wake you up to 30 minutes early at the best guessed time when you are almost already awake.", "icon": "app.png", "tags": "tool,alarm", diff --git a/apps/sleepphasealarm/settings.js b/apps/sleepphasealarm/settings.js index b6fbdf60b..626de6cd0 100644 --- a/apps/sleepphasealarm/settings.js +++ b/apps/sleepphasealarm/settings.js @@ -91,7 +91,6 @@ "" : { "title" : "SleepPhaseAlarm" }, 'Keep alarm enabled': { value: !!config.settings.disableAlarm, - format: v => v?"No":"Yes", onchange: v => { config.settings.disableAlarm = v; writeSettings(); diff --git a/apps/slidingtext/ChangeLog b/apps/slidingtext/ChangeLog index 5c4a9fa75..42d1b061c 100644 --- a/apps/slidingtext/ChangeLog +++ b/apps/slidingtext/ChangeLog @@ -9,3 +9,4 @@ 0.09: Added button control toggle and other live controls to new settings screen. 0.10: Tell clock widgets to hide. 0.11: Added new styling and watch faces +0.12: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/slidingtext/metadata.json b/apps/slidingtext/metadata.json index 098fdb747..4dc6f1f0c 100644 --- a/apps/slidingtext/metadata.json +++ b/apps/slidingtext/metadata.json @@ -1,7 +1,7 @@ { "id": "slidingtext", "name": "Sliding Clock", - "version": "0.11", + "version": "0.12", "description": "Inspired by the Pebble sliding clock, old times are scrolled off the screen and new times on. You are also able to change language on the fly so you can see the time written in other languages using button 1. Currently English, French, Japanese, Spanish and German are supported", "icon": "slidingtext.png", "screenshots": [{"url":"slidingtext-screenshot.english.png"},{"url":"slidingtext-screenshot.english2.png"},{"url":"slidingtext-screenshot.hybrid.png"}], diff --git a/apps/slidingtext/slidingtext.settings.js b/apps/slidingtext/slidingtext.settings.js index e13c857fd..1eee39bf0 100644 --- a/apps/slidingtext/slidingtext.settings.js +++ b/apps/slidingtext/slidingtext.settings.js @@ -173,12 +173,11 @@ "Colour": stringInSettings("color_scheme", ["black","white", "red","grey","purple","blue"]), "Style": stringInSettings("date_format", locales, (l)=>locale_mappings[l] ), "Live Control": { - value: (settings.enable_live_controls !== undefined ? settings.enable_live_controls : true), - format: v => v ? "On" : "Off", + value: (settings.enable_live_controls !== undefined ? !!settings.enable_live_controls : true), onchange: v => { settings.enable_live_controls = v; writeSettings(); } }, }); -}) \ No newline at end of file +}) diff --git a/apps/slomoclock/settings.js b/apps/slomoclock/settings.js index af67069dc..dcaf0aff6 100644 --- a/apps/slomoclock/settings.js +++ b/apps/slomoclock/settings.js @@ -1,24 +1,24 @@ (function(back) { let settings = require('Storage').readJSON('slomoclock.json',1)||{}; - + function writeSettings() { require('Storage').write('slomoclock.json',settings); } - + function setColour(c) { settings.colour = c; writeSettings(); } - + const appMenu = { '': {'title': 'SloMo Clock'}, '< Back': back, 'Colours' : function() { E.showMenu(colMenu); } - //,'Widget Space Top' : {value : settings.widTop, format : v => v?"On":"Off",onchange : () => { settings.widTop = !settings.widTop; writeSettings(); } - //,'Widget Space Bottom' : {value : settings.widBot, format : v => v?"On":"Off",onchange : () => { settings.widBot = !settings.widBot; writeSettings(); } + //,'Widget Space Top' : {value : settings.widTop, onchange : () => { settings.widTop = !settings.widTop; writeSettings(); } + //,'Widget Space Bottom' : {value : settings.widBot, onchange : () => { settings.widBot = !settings.widBot; writeSettings(); } }; - + const colMenu = { '': {'title': 'Colours'}, '< Back': function() { E.showMenu(appMenu); }, @@ -32,7 +32,7 @@ 'Violet' : function() { setColour(7); }, 'White' : function() { setColour(8); } }; - + E.showMenu(appMenu); }); diff --git a/apps/waypointer/ChangeLog b/apps/waypointer/ChangeLog index 60e8bfab0..8c8a323de 100644 --- a/apps/waypointer/ChangeLog +++ b/apps/waypointer/ChangeLog @@ -6,3 +6,4 @@ 0.06: Added adjustment for Bangle.js magnetometer heading fix 0.07: Add settings file with the option to disable the slow direction updates 0.08: Use tilt compensation from new magnav library +0.09: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/waypointer/metadata.json b/apps/waypointer/metadata.json index e21c5f10f..b8f28fbb9 100644 --- a/apps/waypointer/metadata.json +++ b/apps/waypointer/metadata.json @@ -1,7 +1,7 @@ { "id": "waypointer", "name": "Way Pointer", - "version": "0.08", + "version": "0.09", "description": "Navigate to a waypoint using the GPS for bearing and compass to point way, uses the same waypoint interface as GPS Navigation", "icon": "waypointer.png", "tags": "tool,outdoors,gps", diff --git a/apps/waypointer/settings.js b/apps/waypointer/settings.js index c8b06b9f9..cc521c637 100644 --- a/apps/waypointer/settings.js +++ b/apps/waypointer/settings.js @@ -15,7 +15,6 @@ "< Back" : () => back(), 'Smooth arrow rot': { value: !!settings.smoothDirection, - format: v => v?"Yes":"No", onchange: v => { settings.smoothDirection = v; writeSettings(); diff --git a/apps/widalarmeta/ChangeLog b/apps/widalarmeta/ChangeLog index 1012ee386..66b9a4b8e 100644 --- a/apps/widalarmeta/ChangeLog +++ b/apps/widalarmeta/ChangeLog @@ -5,3 +5,4 @@ 0.03: Fix Bell not appearing on alarms > 24h and redrawing interval Update to match the default alarm widget, and not show itself when an alarm is hidden. 0.04: Fix check for active alarm +0.05: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/widalarmeta/metadata.json b/apps/widalarmeta/metadata.json index aad3c4321..20b54d7c8 100644 --- a/apps/widalarmeta/metadata.json +++ b/apps/widalarmeta/metadata.json @@ -2,7 +2,7 @@ "id": "widalarmeta", "name": "Alarm & Timer ETA", "shortName": "Alarm ETA", - "version": "0.04", + "version": "0.05", "description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).", "icon": "widget.png", "type": "widget", diff --git a/apps/widalarmeta/settings.js b/apps/widalarmeta/settings.js index 5922d159d..db9243ae0 100644 --- a/apps/widalarmeta/settings.js +++ b/apps/widalarmeta/settings.js @@ -26,7 +26,6 @@ }, /*LANG*/'Draw bell': { value: !!settings.drawBell, - format: v => v?/*LANG*/"Yes":/*LANG*/"No", onchange: v => { settings.drawBell = v; writeSettings(); diff --git a/apps/widdst/ChangeLog b/apps/widdst/ChangeLog index e350137ee..7cb1016f5 100644 --- a/apps/widdst/ChangeLog +++ b/apps/widdst/ChangeLog @@ -1,2 +1,3 @@ 0.01: Initial version 0.02: Checks for correct firmware; E.setDST(...) moved to boot.js +0.03: Convert Yes/No On/Off in settings to checkboxes diff --git a/apps/widdst/metadata.json b/apps/widdst/metadata.json index 144c02998..b97b61369 100644 --- a/apps/widdst/metadata.json +++ b/apps/widdst/metadata.json @@ -1,6 +1,6 @@ { "id": "widdst", "name": "Daylight Saving", - "version":"0.02", + "version":"0.03", "description": "Widget to set daylight saving rules. Requires Espruino 2v14.49 or later - see the instructions below for more information.", "icon": "icon.png", "type": "widget", diff --git a/apps/widdst/settings.js b/apps/widdst/settings.js index 9a7e579b7..7363aa6bf 100644 --- a/apps/widdst/settings.js +++ b/apps/widdst/settings.js @@ -23,7 +23,7 @@ at: 2 } }, require("Storage").readJSON("widdst.json", true) || {}); - + var dst_start_end = { is_start: true, day_offset: 0, @@ -32,11 +32,11 @@ month: 0, at: 0 }; - + function writeSettings() { require('Storage').writeJSON("widdst.json", settings); } - + function writeSubMenuSettings() { if (dst_start_end.is_start) { settings.dst_start.day_offset = dst_start_end.day_offset; @@ -53,11 +53,11 @@ } writeSettings(); } - + function hoursToString(h) { return (h|0) + ':' + (((6*h)%6)|0) + (((60*h)%10)|0); } - + function getDSTStartEndMenu(start) { dst_start_end.is_start = start; if (start) { @@ -131,23 +131,21 @@ } } } - + var dstMenu = { "": { "Title": /*LANG*/"Daylight Saving" }, "< Back": () => back(), /*LANG*/"Enabled": { - value: settings.has_dst, - format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + value: !!settings.has_dst, onchange: v => { settings.has_dst = v; writeSettings(); } }, /*LANG*/"Icon": { - value: settings.show_icon, - format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + value: !!settings.show_icon, onchange: v => { settings.show_icon = v; writeSettings(); @@ -178,7 +176,7 @@ /*LANG*/"DST Start": () => E.showMenu(getDSTStartEndMenu(true)), /*LANG*/"DST End": () => E.showMenu(getDSTStartEndMenu(false)) }; - + E.showMenu(dstMenu); }); From f5d265387232138c43f46ea429859a117c675aac Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Feb 2023 11:47:02 +0000 Subject: [PATCH 41/58] More explicit notes on minification --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index cc69781ee..1ed95107e 100644 --- a/index.html +++ b/index.html @@ -148,7 +148,7 @@
Type