Skip to content

Commit

Permalink
Merge pull request espruino#3582 from thyttan/edgeclk
Browse files Browse the repository at this point in the history
edgeclk: live updates of step count
  • Loading branch information
bobrippling authored Sep 23, 2024
2 parents cc79ecc + e8e2457 commit 4eb59fe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/edgeclk/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions apps/edgeclk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


8 changes: 8 additions & 0 deletions apps/edgeclk/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
weekBar: true,
mondayFirst: true,
dayBar: true,
liveSteps: false,
}, require('Storage').readJSON('edgeclk.settings.json', true) || {});

/* Runtime Variables
Expand Down Expand Up @@ -279,6 +280,9 @@
drawLower();
};

const onStep = function () {
drawSteps();
}

/* Lifecycle Functions
------------------------------------------------------------------------------*/
Expand All @@ -298,6 +302,9 @@

// Charging event signals when charging status changes:
Bangle.on('charging', onCharging);

// Continously update step count when they happen:
if (settings.redrawOnStep) Bangle.on('step', onStep);
};

const deregisterEvents = function () {
Expand All @@ -306,6 +313,7 @@
Bangle.removeListener('health', onHealth);
Bangle.removeListener('lock', onLock);
Bangle.removeListener('charging', onCharging);
if (settings.redrawOnStep) Bangle.removeListener('step', onStep);
};

const startTimers = function () {
Expand Down
2 changes: 1 addition & 1 deletion apps/edgeclk/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions apps/edgeclk/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
weekBar: true,
mondayFirst: true,
dayBar: true,
redrawOnStep: false,
};

const saved_settings = storage.readJSON(SETTINGS_FILE, true);
Expand Down Expand Up @@ -121,5 +122,12 @@
save();
},
},
'Live steps': {
value: settings.redrawOnStep,
onchange: () => {
settings.redrawOnStep = !settings.redrawOnStep;
save();
},
},
});
})

0 comments on commit 4eb59fe

Please sign in to comment.