From 1cdbc5c9cf8117d08a312144245b685059c8b427 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 19 Jun 2025 16:10:04 +0100 Subject: [PATCH] recorder: Ensure Battery voltage is only stored to 0.01v + Add graphs for Steps+Battery --- apps/recorder/ChangeLog | 4 +++- apps/recorder/app.js | 43 +++++++++++++++++++++++++++++++++-------- apps/recorder/lib.js | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/apps/recorder/ChangeLog b/apps/recorder/ChangeLog index 4e39cef42..f5c0803bb 100644 --- a/apps/recorder/ChangeLog +++ b/apps/recorder/ChangeLog @@ -58,4 +58,6 @@ Improve recorder ClockInfo icons 0.46: Ensure altitude graph draws properly (or any graph using the last column of CSV data) Lower accuracy of barometer data to ~1cm (saves about 15b/record) -0.47: Fix 'blip' on speed map on some recordings \ No newline at end of file +0.47: Fix 'blip' on speed map on some recordings + Ensure Battery voltage is only stored to 0.01v + Add graphs for Steps+Battery \ No newline at end of file diff --git a/apps/recorder/app.js b/apps/recorder/app.js index 463d08004..37fa5cb3b 100644 --- a/apps/recorder/app.js +++ b/apps/recorder/app.js @@ -197,6 +197,14 @@ function viewTrack(filename, info) { menu[/*LANG*/'Plot HRM'] = function() { plotGraph(info, "Heartrate"); }; + if (info.fields.includes("Steps")) + menu[/*LANG*/'Plot Steps'] = function() { + plotGraph(info, "Steps"); + }; + if (info.fields.includes("Battery Percentage")) + menu[/*LANG*/'Plot Battery'] = function() { + plotGraph(info, "Battery"); + }; // TODO: steps, heart rate? menu[/*LANG*/'Erase'] = function() { E.showPrompt(/*LANG*/"Delete Track?").then(function(v) { @@ -358,12 +366,34 @@ function plotGraph(info, style) { "ram" infn[i]+=+c[altIdx]; infc[i]++; } + } else if (style=="Steps") { + title = /*LANG*/"Steps/min"; + var stpIdx = info.fields.indexOf("Steps"); + var t,lt = c[timeIdx]; + while(l!==undefined) { + c=l.trim().split(",");l = f.readLine(f); + if (c[stpIdx]=="") continue; + t = c[timeIdx]; + i = Math.round(80*(t - strt)/dur); + infn[i]+=60*c[stpIdx]; + infc[i]+=t-lt; + lt = t; + } + } else if (style=="Battery") { + title = /*LANG*/"Battery %"; + var batIdx = info.fields.indexOf("Battery Percentage"); + while(l!==undefined) { + c=l.trim().split(",");l = f.readLine(f); + if (c[batIdx]=="") continue; + i = Math.round(80*(c[timeIdx] - strt)/dur); + infn[i]+=+c[batIdx]; + infc[i]++; + } } else if (style=="Speed") { // use locate to work out units var localeStr = require("locale").speed(1,5); // get what 1kph equates to let units = localeStr.replace(/[0-9.]*/,""); factor = parseFloat(localeStr)*3.6; // m/sec to whatever out units are - // title title = /*LANG*/"Speed"+` (${units})`; var latIdx = info.fields.indexOf("Latitude"); var lonIdx = info.fields.indexOf("Longitude"); @@ -378,19 +408,15 @@ function plotGraph(info, style) { "ram" while(l!==undefined) { c=l.trim().split(","); l = f.readLine(f); - if (c[latIdx] == "") { - continue; - } + if (c[latIdx] == "") continue; t = c[timeIdx]; i = Math.round(80*(t - strt)/dur); p = Bangle.project({lat:c[latIdx],lon:c[lonIdx]}); dx = p.x-lp.x; dy = p.y-lp.y; d = Math.sqrt(dx*dx+dy*dy); - if (t!=lt) { - infn[i]+=d / (t-lt); // speed - infc[i]++; - } + infn[i]+=d; // speed + infc[i]+=t-lt; lp = p; lt = t; } @@ -406,6 +432,7 @@ function plotGraph(info, style) { "ram" if (n>max) max=n; if (n { - return [E.getBattery(), NRF.getBattery(), Bangle.isCharging()]; + return [E.getBattery(), NRF.getBattery().toFixed(2), Bangle.isCharging()]; }, start : () => { },