recorder: Ensure Battery voltage is only stored to 0.01v
+ Add graphs for Steps+Batterymaster
parent
782c71e85e
commit
1cdbc5c9cf
|
|
@ -59,3 +59,5 @@
|
||||||
0.46: Ensure altitude graph draws properly (or any graph using the last column of CSV data)
|
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)
|
Lower accuracy of barometer data to ~1cm (saves about 15b/record)
|
||||||
0.47: Fix 'blip' on speed map on some recordings
|
0.47: Fix 'blip' on speed map on some recordings
|
||||||
|
Ensure Battery voltage is only stored to 0.01v
|
||||||
|
Add graphs for Steps+Battery
|
||||||
|
|
@ -197,6 +197,14 @@ function viewTrack(filename, info) {
|
||||||
menu[/*LANG*/'Plot HRM'] = function() {
|
menu[/*LANG*/'Plot HRM'] = function() {
|
||||||
plotGraph(info, "Heartrate");
|
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?
|
// TODO: steps, heart rate?
|
||||||
menu[/*LANG*/'Erase'] = function() {
|
menu[/*LANG*/'Erase'] = function() {
|
||||||
E.showPrompt(/*LANG*/"Delete Track?").then(function(v) {
|
E.showPrompt(/*LANG*/"Delete Track?").then(function(v) {
|
||||||
|
|
@ -358,12 +366,34 @@ function plotGraph(info, style) { "ram"
|
||||||
infn[i]+=+c[altIdx];
|
infn[i]+=+c[altIdx];
|
||||||
infc[i]++;
|
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") {
|
} else if (style=="Speed") {
|
||||||
// use locate to work out units
|
// use locate to work out units
|
||||||
var localeStr = require("locale").speed(1,5); // get what 1kph equates to
|
var localeStr = require("locale").speed(1,5); // get what 1kph equates to
|
||||||
let units = localeStr.replace(/[0-9.]*/,"");
|
let units = localeStr.replace(/[0-9.]*/,"");
|
||||||
factor = parseFloat(localeStr)*3.6; // m/sec to whatever out units are
|
factor = parseFloat(localeStr)*3.6; // m/sec to whatever out units are
|
||||||
// title
|
|
||||||
title = /*LANG*/"Speed"+` (${units})`;
|
title = /*LANG*/"Speed"+` (${units})`;
|
||||||
var latIdx = info.fields.indexOf("Latitude");
|
var latIdx = info.fields.indexOf("Latitude");
|
||||||
var lonIdx = info.fields.indexOf("Longitude");
|
var lonIdx = info.fields.indexOf("Longitude");
|
||||||
|
|
@ -378,19 +408,15 @@ function plotGraph(info, style) { "ram"
|
||||||
while(l!==undefined) {
|
while(l!==undefined) {
|
||||||
c=l.trim().split(",");
|
c=l.trim().split(",");
|
||||||
l = f.readLine(f);
|
l = f.readLine(f);
|
||||||
if (c[latIdx] == "") {
|
if (c[latIdx] == "") continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
t = c[timeIdx];
|
t = c[timeIdx];
|
||||||
i = Math.round(80*(t - strt)/dur);
|
i = Math.round(80*(t - strt)/dur);
|
||||||
p = Bangle.project({lat:c[latIdx],lon:c[lonIdx]});
|
p = Bangle.project({lat:c[latIdx],lon:c[lonIdx]});
|
||||||
dx = p.x-lp.x;
|
dx = p.x-lp.x;
|
||||||
dy = p.y-lp.y;
|
dy = p.y-lp.y;
|
||||||
d = Math.sqrt(dx*dx+dy*dy);
|
d = Math.sqrt(dx*dx+dy*dy);
|
||||||
if (t!=lt) {
|
infn[i]+=d; // speed
|
||||||
infn[i]+=d / (t-lt); // speed
|
infc[i]+=t-lt;
|
||||||
infc[i]++;
|
|
||||||
}
|
|
||||||
lp = p;
|
lp = p;
|
||||||
lt = t;
|
lt = t;
|
||||||
}
|
}
|
||||||
|
|
@ -406,6 +432,7 @@ function plotGraph(info, style) { "ram"
|
||||||
if (n>max) max=n;
|
if (n>max) max=n;
|
||||||
if (n<min) min=n;
|
if (n<min) min=n;
|
||||||
}
|
}
|
||||||
|
if (style=="Battery") {min=0;max=100;}
|
||||||
// work out a nice grid value
|
// work out a nice grid value
|
||||||
var heightDiff = max-min;
|
var heightDiff = max-min;
|
||||||
var grid = 1;
|
var grid = 1;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ exports.getRecorders = function() {
|
||||||
name : "BAT",
|
name : "BAT",
|
||||||
fields : ["Battery Percentage", "Battery Voltage", "Charging"],
|
fields : ["Battery Percentage", "Battery Voltage", "Charging"],
|
||||||
getValues : () => {
|
getValues : () => {
|
||||||
return [E.getBattery(), NRF.getBattery(), Bangle.isCharging()];
|
return [E.getBattery(), NRF.getBattery().toFixed(2), Bangle.isCharging()];
|
||||||
},
|
},
|
||||||
start : () => {
|
start : () => {
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue