From 7a47e33441cd07cfdc487a71192b028aca73302f Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Sat, 21 Sep 2024 23:18:04 +0200 Subject: [PATCH] edgeclk: live updates of step count --- apps/edgeclk/ChangeLog | 1 + apps/edgeclk/README.md | 5 +++-- apps/edgeclk/app.js | 9 +++++++++ apps/edgeclk/metadata.json | 2 +- apps/edgeclk/settings.js | 8 ++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/edgeclk/ChangeLog b/apps/edgeclk/ChangeLog index b96d7207d..72bb39ab1 100644 --- a/apps/edgeclk/ChangeLog +++ b/apps/edgeclk/ChangeLog @@ -1,3 +1,4 @@ 0.01: Initial release. 0.02: Fix reset of progress bars on midnight. Fix display of 100k+ steps. 0.03: Added option to display weather. +0.04: Added option to display live updates of step count. diff --git a/apps/edgeclk/README.md b/apps/edgeclk/README.md index 90f6443fc..51747780f 100644 --- a/apps/edgeclk/README.md +++ b/apps/edgeclk/README.md @@ -20,12 +20,13 @@ The appearance is highly configurable. In the settings menu you can: - Set the daily step goal. - En- or disable the individual progress bars. - Set if your week should start with Monday or Sunday (for week progress bar). +- Toggle live step count updates.* -*) Hiding seconds should further reduce power consumption as the draw interval is prolonged as well. +*) Hiding seconds and leaving live steps off should further reduce power consumption as the draw interval is prolonged as well. The clock implements Fast Loading for faster switching to and fro. ## Contributors - [tinxx](https://github.com/tinxx) - [peerdavid](https://github.com/peerdavid) - \ No newline at end of file + diff --git a/apps/edgeclk/app.js b/apps/edgeclk/app.js index f9d5f803b..085291bf8 100644 --- a/apps/edgeclk/app.js +++ b/apps/edgeclk/app.js @@ -14,6 +14,7 @@ weekBar: true, mondayFirst: true, dayBar: true, + liveSteps: false, }, require('Storage').readJSON('edgeclk.settings.json', true) || {}); /* Runtime Variables @@ -279,6 +280,10 @@ drawLower(); }; + const onStep = function () { + if (settings.redrawOnStep) drawSteps(); + } + /* Lifecycle Functions ------------------------------------------------------------------------------*/ @@ -298,6 +303,9 @@ // Charging event signals when charging status changes: Bangle.on('charging', onCharging); + + // Continously update step count when they happen: + Bangle.on('step', onStep); }; const deregisterEvents = function () { @@ -306,6 +314,7 @@ Bangle.removeListener('health', onHealth); Bangle.removeListener('lock', onLock); Bangle.removeListener('charging', onCharging); + Bangle.removeListener('step', onStep); }; const startTimers = function () { diff --git a/apps/edgeclk/metadata.json b/apps/edgeclk/metadata.json index 0d53cd008..ef97b314b 100644 --- a/apps/edgeclk/metadata.json +++ b/apps/edgeclk/metadata.json @@ -2,7 +2,7 @@ "id": "edgeclk", "name": "Edge Clock", "shortName": "Edge Clock", - "version": "0.03", + "version": "0.04", "description": "Crisp clock with perfect readability.", "readme": "README.md", "icon": "app.png", diff --git a/apps/edgeclk/settings.js b/apps/edgeclk/settings.js index 6f38e774c..81a7acc5b 100644 --- a/apps/edgeclk/settings.js +++ b/apps/edgeclk/settings.js @@ -14,6 +14,7 @@ weekBar: true, mondayFirst: true, dayBar: true, + redrawOnStep: false, }; const saved_settings = storage.readJSON(SETTINGS_FILE, true); @@ -121,5 +122,12 @@ save(); }, }, + 'Live steps': { + value: settings.redrawOnStep, + onchange: () => { + settings.redrawOnStep = !settings.redrawOnStep; + save(); + }, + }, }); })