Reset count more reliable and also shows additional info
parent
616277fe5d
commit
9a153d9376
|
|
@ -4,4 +4,5 @@
|
||||||
0.04: Shows day of week
|
0.04: Shows day of week
|
||||||
0.05: Shows day of month
|
0.05: Shows day of month
|
||||||
0.06: Updates every 5 minutes when locked, or when unlock occurs. Also shows nr of steps.
|
0.06: Updates every 5 minutes when locked, or when unlock occurs. Also shows nr of steps.
|
||||||
0.07: Step count resets at midnight
|
0.07: Step count resets at midnight
|
||||||
|
0.08: Step count stored in memory to survive reloads. Now shows step count daily and since last reboot.
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ let rightBarsStartX = midBarOffsetX + checkBarWidth;
|
||||||
let rightBarsStartY = upperTextBarRightOffsetY + textBarHeight;
|
let rightBarsStartY = upperTextBarRightOffsetY + textBarHeight;
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
let stepCount = 0;
|
let stepCount = require("Storage").readJSON("stepCount",1);
|
||||||
|
if(stepCount === undefined) stepCount = 0;
|
||||||
let intCaster = num => Number(num);
|
let intCaster = num => Number(num);
|
||||||
|
|
||||||
var drawTimeout;
|
var drawTimeout;
|
||||||
|
|
@ -78,6 +79,7 @@ function renderWatch(l) {
|
||||||
drawRDigit(chars[6], 2, rightBarsStartY);
|
drawRDigit(chars[6], 2, rightBarsStartY);
|
||||||
drawRDigit(checkSum, 3, rightBarsStartY);
|
drawRDigit(checkSum, 3, rightBarsStartY);
|
||||||
|
|
||||||
|
g.drawString(Bangle.getStepCount(), midBarOffsetX + checkBarWidth + 3, startOffsetY + 4);
|
||||||
g.drawString(concatTime.substring(4), midBarOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
|
g.drawString(concatTime.substring(4), midBarOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
|
||||||
|
|
||||||
drawCheckBar(endBarOffsetX, endBarOffsetY);
|
drawCheckBar(endBarOffsetX, endBarOffsetY);
|
||||||
|
|
@ -375,6 +377,7 @@ function calculateChecksum(digits) {
|
||||||
|
|
||||||
function storeStepCount() {
|
function storeStepCount() {
|
||||||
stepCount = Bangle.getStepCount();
|
stepCount = Bangle.getStepCount();
|
||||||
|
require("Storage").writeJSON("stepCount",stepCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStepCount() {
|
function getStepCount() {
|
||||||
|
|
@ -386,14 +389,14 @@ function getStepCount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetAtMidnight() {
|
function resetAtMidnight() {
|
||||||
var now = new Date();
|
let now = new Date();
|
||||||
var night = new Date(
|
let night = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
now.getMonth(),
|
now.getMonth(),
|
||||||
now.getDate() + 1, // the next day, ...
|
now.getDate() + 1, // the next day, ...
|
||||||
23, 58, 0 // ...at 00:00:00 hours
|
23, 58, 0 // ...at 00:00:00 hours
|
||||||
);
|
);
|
||||||
var msToMidnight = night.getTime() - now.getTime();
|
let msToMidnight = night.getTime() - now.getTime();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
storeStepCount(); // <-- This is the function being called at midnight.
|
storeStepCount(); // <-- This is the function being called at midnight.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "Barcode clock",
|
"name": "Barcode clock",
|
||||||
"shortName":"Barcode clock",
|
"shortName":"Barcode clock",
|
||||||
"icon": "barcode.icon.png",
|
"icon": "barcode.icon.png",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"description": "EAN-8 compatible barcode clock.",
|
"description": "EAN-8 compatible barcode clock.",
|
||||||
"tags": "barcode,ean,ean-8,watchface,clock,clockface",
|
"tags": "barcode,ean,ean-8,watchface,clock,clockface",
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue