Reset count more reliable and also shows additional info
parent
616277fe5d
commit
9a153d9376
|
|
@ -4,4 +4,5 @@
|
|||
0.04: Shows day of week
|
||||
0.05: Shows day of month
|
||||
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;
|
||||
|
||||
/* Utilities */
|
||||
let stepCount = 0;
|
||||
let stepCount = require("Storage").readJSON("stepCount",1);
|
||||
if(stepCount === undefined) stepCount = 0;
|
||||
let intCaster = num => Number(num);
|
||||
|
||||
var drawTimeout;
|
||||
|
|
@ -78,6 +79,7 @@ function renderWatch(l) {
|
|||
drawRDigit(chars[6], 2, 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);
|
||||
|
||||
drawCheckBar(endBarOffsetX, endBarOffsetY);
|
||||
|
|
@ -375,6 +377,7 @@ function calculateChecksum(digits) {
|
|||
|
||||
function storeStepCount() {
|
||||
stepCount = Bangle.getStepCount();
|
||||
require("Storage").writeJSON("stepCount",stepCount);
|
||||
}
|
||||
|
||||
function getStepCount() {
|
||||
|
|
@ -386,14 +389,14 @@ function getStepCount() {
|
|||
}
|
||||
|
||||
function resetAtMidnight() {
|
||||
var now = new Date();
|
||||
var night = new Date(
|
||||
let now = new Date();
|
||||
let night = new Date(
|
||||
now.getFullYear(),
|
||||
now.getMonth(),
|
||||
now.getDate() + 1, // the next day, ...
|
||||
23, 58, 0 // ...at 00:00:00 hours
|
||||
);
|
||||
var msToMidnight = night.getTime() - now.getTime();
|
||||
);
|
||||
let msToMidnight = night.getTime() - now.getTime();
|
||||
|
||||
setTimeout(function() {
|
||||
storeStepCount(); // <-- This is the function being called at midnight.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Barcode clock",
|
||||
"shortName":"Barcode clock",
|
||||
"icon": "barcode.icon.png",
|
||||
"version":"0.07",
|
||||
"version":"0.08",
|
||||
"description": "EAN-8 compatible barcode clock.",
|
||||
"tags": "barcode,ean,ean-8,watchface,clock,clockface",
|
||||
"type": "clock",
|
||||
|
|
|
|||
Loading…
Reference in New Issue