From 7feaff48f18cb70fc64d8ad698ab74f2ae02eefe Mon Sep 17 00:00:00 2001 From: hughbarney Date: Mon, 17 Jan 2022 22:49:51 +0000 Subject: [PATCH] Run: added settings menu, set pace and time format to mm:ss, h:mm:ss --- apps/run/app.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/apps/run/app.js b/apps/run/app.js index 277d1b323..1b2cd27c5 100644 --- a/apps/run/app.js +++ b/apps/run/app.js @@ -21,11 +21,11 @@ Bangle.drawWidgets(); // --------------------------- function formatTime(ms) { - let hrs = Math.floor(ms/3600000); - let mins = Math.floor(ms/60000)%60; - let secs = Math.floor(ms/1000)%60; + let hrs = Math.floor(ms/3600000).toString(); + let mins = (Math.floor(ms/60000)%60).toString(); + let secs = (Math.floor(ms/1000)%60).toString(); - if (hrs === 0) + if (hrs === '0') return mins.padStart(2,0)+":"+secs.padStart(2,0); else return hrs+":"+mins.padStart(2,0)+":"+secs.padStart(2,0); // dont pad hours @@ -153,15 +153,10 @@ Bangle.on("step", function(steps) { lastStepCount = steps; }); -function loadSettings() { - settings = require("Storage").readJSON('run.json',1)||{}; - settings.use_gps = settings.use_gps||true; - settings.use_hrm = settings.use_hrm||true; -} +let settings = require("Storage").readJSON('run.json',1)||{"use_gps":true,"use_hrm":true}; // We always call ourselves once a second, if only to update the time setInterval(onTimer, 1000); -loadSettings(); /* Turn GPS and HRM on right at the start to ensure we get the highest chance of a lock. */