edgeclk: fix bar reset and 100k+ steps

master
Tim Kuhlmann 2023-08-12 10:34:47 +02:00
parent 53aaffab0b
commit bb68b7e9d1
3 changed files with 17 additions and 10 deletions

View File

@ -1 +1,2 @@
0.01: Initial release. 0.01: Initial release.
0.02: Fix reset of progress bars on midnight. Fix display of 100k+ steps.

View File

@ -135,7 +135,8 @@
g.setFontAlign(-1, 1); // left bottom g.setFontAlign(-1, 1); // left bottom
const steps = Bangle.getHealthStatus('day').steps; const steps = Bangle.getHealthStatus('day').steps;
g.drawString(steps.toString().padEnd(5, '_'), iconSize[0] + 6, g.getHeight() - 1, true); g.drawString((steps < 100000 ? steps.toString() : ((steps / 1000).toFixed(0) + 'K')).padEnd(5, '_'),
iconSize[0] + 6, g.getHeight() - 1, true);
if (onlyCount === true) { if (onlyCount === true) {
return; return;
@ -169,11 +170,16 @@
}; };
const drawBar = function (top, progress) { const drawBar = function (top, progress) {
// draw frame
g.drawRect(0, top, g.getWidth() - 1, top + 5); g.drawRect(0, top, g.getWidth() - 1, top + 5);
g.drawRect(1, top + 1, g.getWidth() - 2, top + 4); g.drawRect(1, top + 1, g.getWidth() - 2, top + 4);
const barLen = progress > 1 ? g.getWidth() : g.getWidth() * progress; // clear bar area
g.drawLine(2, top+2, barLen, top + 2); g.clearRect(2, top + 2, g.getWidth() - 3, top + 3);
g.drawLine(2, top+3, barLen, top + 3); // draw bar
const barLen = progress >= 1 ? g.getWidth() : (g.getWidth() - 4) * progress;
if (barLen < 1) return;
g.drawLine(2, top + 2, barLen + 2, top + 2);
g.drawLine(2, top + 3, barLen + 2, top + 3);
}; };
const drawLine = function (top) { const drawLine = function (top) {
@ -251,7 +257,7 @@
// This is for original Bangle.js; version two has always-on display: // This is for original Bangle.js; version two has always-on display:
Bangle.on('lcdPower', onLcdPower); Bangle.on('lcdPower', onLcdPower);
// Midnight event is triggered qhen health data is reset and a new day begins: // Midnight event is triggered when health data is reset and a new day begins:
Bangle.on('midnight', onMidnight); Bangle.on('midnight', onMidnight);
// Health data is published via 10 mins interval: // Health data is published via 10 mins interval:

View File

@ -2,7 +2,7 @@
"id": "edgeclk", "id": "edgeclk",
"name": "Edge Clock", "name": "Edge Clock",
"shortName": "Edge Clock", "shortName": "Edge Clock",
"version": "0.01", "version": "0.02",
"description": "Crisp clock with perfect readability.", "description": "Crisp clock with perfect readability.",
"readme": "README.md", "readme": "README.md",
"icon": "app.png", "icon": "app.png",