Skip to content

Commit 26f8ed4

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/master'
2 parents 910476e + 1cdbc5c commit 26f8ed4

File tree

5 files changed

+54
-21
lines changed

5 files changed

+54
-21
lines changed

apps/recorder/ChangeLog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@
5555
0.43: Fix interaction on clocks without widgets
5656
0.44: List tracks in reverse chronological order.
5757
0.45: Move recorder from widget into library
58-
Improve recorder ClockInfo icons
58+
Improve recorder ClockInfo icons
59+
0.46: Ensure altitude graph draws properly (or any graph using the last column of CSV data)
60+
Lower accuracy of barometer data to ~1cm (saves about 15b/record)
61+
0.47: Fix 'blip' on speed map on some recordings
62+
Ensure Battery voltage is only stored to 0.01v
63+
Add graphs for Steps+Battery

apps/recorder/app.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ function viewTrack(filename, info) {
197197
menu[/*LANG*/'Plot HRM'] = function() {
198198
plotGraph(info, "Heartrate");
199199
};
200+
if (info.fields.includes("Steps"))
201+
menu[/*LANG*/'Plot Steps'] = function() {
202+
plotGraph(info, "Steps");
203+
};
204+
if (info.fields.includes("Battery Percentage"))
205+
menu[/*LANG*/'Plot Battery'] = function() {
206+
plotGraph(info, "Battery");
207+
};
200208
// TODO: steps, heart rate?
201209
menu[/*LANG*/'Erase'] = function() {
202210
E.showPrompt(/*LANG*/"Delete Track?").then(function(v) {
@@ -325,6 +333,7 @@ function plotGraph(info, style) { "ram"
325333
var lt = 0; // last time
326334
//var tn = 0; // count for each time period
327335
var strt, dur = info.duration;
336+
if (dur<1) dur=1;
328337
var f = require("Storage").open(filename,"r");
329338
if (f===undefined) return;
330339
var l = f.readLine(f);
@@ -333,14 +342,14 @@ function plotGraph(info, style) { "ram"
333342
var factor = 1; // multiplier used for values when graphing
334343
var timeIdx = info.fields.indexOf("Time");
335344
if (l!==undefined) {
336-
c = l.split(",");
345+
c = l.trim().split(",");
337346
strt = c[timeIdx];
338347
}
339348
if (style=="Heartrate") {
340349
title = /*LANG*/"Heartrate (bpm)";
341350
var hrmIdx = info.fields.indexOf("Heartrate");
342351
while(l!==undefined) {
343-
c=l.split(",");l = f.readLine(f);
352+
c=l.trim().split(",");l = f.readLine(f);
344353
if (c[hrmIdx]=="") continue;
345354
i = Math.round(80*(c[timeIdx] - strt)/dur);
346355
infn[i]+=+c[hrmIdx];
@@ -351,45 +360,63 @@ function plotGraph(info, style) { "ram"
351360
var altIdx = info.fields.indexOf("Barometer Altitude");
352361
if (altIdx<0) altIdx = info.fields.indexOf("Altitude");
353362
while(l!==undefined) {
354-
c=l.split(",");l = f.readLine(f);
363+
c=l.trim().split(",");l = f.readLine(f);
355364
if (c[altIdx]=="") continue;
356365
i = Math.round(80*(c[timeIdx] - strt)/dur);
357366
infn[i]+=+c[altIdx];
358367
infc[i]++;
359368
}
369+
} else if (style=="Steps") {
370+
title = /*LANG*/"Steps/min";
371+
var stpIdx = info.fields.indexOf("Steps");
372+
var t,lt = c[timeIdx];
373+
while(l!==undefined) {
374+
c=l.trim().split(",");l = f.readLine(f);
375+
if (c[stpIdx]=="") continue;
376+
t = c[timeIdx];
377+
i = Math.round(80*(t - strt)/dur);
378+
infn[i]+=60*c[stpIdx];
379+
infc[i]+=t-lt;
380+
lt = t;
381+
}
382+
} else if (style=="Battery") {
383+
title = /*LANG*/"Battery %";
384+
var batIdx = info.fields.indexOf("Battery Percentage");
385+
while(l!==undefined) {
386+
c=l.trim().split(",");l = f.readLine(f);
387+
if (c[batIdx]=="") continue;
388+
i = Math.round(80*(c[timeIdx] - strt)/dur);
389+
infn[i]+=+c[batIdx];
390+
infc[i]++;
391+
}
360392
} else if (style=="Speed") {
361393
// use locate to work out units
362394
var localeStr = require("locale").speed(1,5); // get what 1kph equates to
363395
let units = localeStr.replace(/[0-9.]*/,"");
364396
factor = parseFloat(localeStr)*3.6; // m/sec to whatever out units are
365-
// title
366397
title = /*LANG*/"Speed"+` (${units})`;
367398
var latIdx = info.fields.indexOf("Latitude");
368399
var lonIdx = info.fields.indexOf("Longitude");
369400
// skip until we find our first data
370401
while(l!==undefined && c[latIdx]=="") {
371-
c = l.split(",");
402+
c = l.trim().split(",");
372403
l = f.readLine(f);
373404
}
374405
// now iterate
375-
var p,lp = Bangle.project({lat:c[1],lon:c[2]});
406+
var p,lp = Bangle.project({lat:c[latIdx],lon:c[lonIdx]});
376407
var t,dx,dy,d,lt = c[timeIdx];
377408
while(l!==undefined) {
378-
c=l.split(",");
409+
c=l.trim().split(",");
379410
l = f.readLine(f);
380-
if (c[latIdx] == "") {
381-
continue;
382-
}
411+
if (c[latIdx] == "") continue;
383412
t = c[timeIdx];
384413
i = Math.round(80*(t - strt)/dur);
385414
p = Bangle.project({lat:c[latIdx],lon:c[lonIdx]});
386415
dx = p.x-lp.x;
387416
dy = p.y-lp.y;
388417
d = Math.sqrt(dx*dx+dy*dy);
389-
if (t!=lt) {
390-
infn[i]+=d / (t-lt); // speed
391-
infc[i]++;
392-
}
418+
infn[i]+=d; // speed
419+
infc[i]+=t-lt;
393420
lp = p;
394421
lt = t;
395422
}
@@ -405,6 +432,7 @@ function plotGraph(info, style) { "ram"
405432
if (n>max) max=n;
406433
if (n<min) min=n;
407434
}
435+
if (style=="Battery") {min=0;max=100;}
408436
// work out a nice grid value
409437
var heightDiff = max-min;
410438
var grid = 1;

apps/recorder/lib.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ exports.getRecorders = function() {
9191
name : "BAT",
9292
fields : ["Battery Percentage", "Battery Voltage", "Charging"],
9393
getValues : () => {
94-
return [E.getBattery(), NRF.getBattery(), Bangle.isCharging()];
94+
return [E.getBattery(), NRF.getBattery().toFixed(2), Bangle.isCharging()];
9595
},
9696
start : () => {
9797
},
@@ -120,9 +120,9 @@ exports.getRecorders = function() {
120120
recorders['baro'] = function() {
121121
var temp="",press="",alt="";
122122
function onPress(c) {
123-
temp=c.temperature;
124-
press=c.pressure;
125-
alt=c.altitude;
123+
temp=c.temperature.toFixed(1);
124+
press=c.pressure.toFixed(2);
125+
alt=c.altitude.toFixed(2);
126126
}
127127
return {
128128
name : "Baro",

apps/recorder/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "recorder",
33
"name": "Recorder",
44
"shortName": "Recorder",
5-
"version": "0.45",
5+
"version": "0.47",
66
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
77
"icon": "app.png",
88
"tags": "tool,outdoors,gps,widget,clkinfo",

core

0 commit comments

Comments
 (0)