Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/recorder/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@
0.47: Fix 'blip' on speed map on some recordings
Ensure Battery voltage is only stored to 0.01v
Add graphs for Steps+Battery
0.48: Add ability to log average acceleration values
0.48: Add ability to log average acceleration values
0.49: Log average high confidence (>=80) HR reading for each interval, instead of logging the last
reading. If none pass confidence threshold, fall back to highest low confidence reading.
39 changes: 33 additions & 6 deletions apps/recorder/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,45 @@ exports.getRecorders = function() {
};
},
hrm:function() {
var bpm = "", bpmConfidence = "", src="";
const CONFIDENCE_THRESHOLD = 80;
var avgBpm = 0, avgBpmConfidence = 0, src="", nAvgReadings=0, lowConfBpm=null, lowConfBpmConfidence=-1;

function onHRM(h) {
bpmConfidence = h.confidence;
bpm = h.bpm;
let newBpmConfidence = h.confidence;
let newBpm = h.bpm;
src = h.src;

if (newBpmConfidence >= CONFIDENCE_THRESHOLD){
nAvgReadings++;
avgBpm = avgBpm + (newBpm-avgBpm)/nAvgReadings;
avgBpmConfidence = avgBpmConfidence + (newBpmConfidence-avgBpmConfidence)/nAvgReadings;

} else if (newBpmConfidence > lowConfBpmConfidence) {
lowConfBpmConfidence = newBpmConfidence;
lowConfBpm = newBpm;
}
}

return {
name : "HR",
fields : ["Heartrate", "Confidence", "Source"],
getValues : () => {
var r = [bpm,bpmConfidence,src];
bpm = ""; bpmConfidence = ""; src="";
let r;

if (nAvgReadings === 0) {
if (lowConfBpm === null) r = ["","",""];
else r = [lowConfBpm,lowConfBpmConfidence,src];
} else {
r = [Math.round(avgBpm),Math.round(avgBpmConfidence),src];
}

avgBpm = 0;
avgBpmConfidence = 0;
nAvgReadings=0;
lowConfBpm=null;
lowConfBpmConfidence=-1;
src="";

return r;
},
start : () => {
Expand Down Expand Up @@ -384,4 +411,4 @@ exports.isRecording = function() {
return !!writeSetup;
};

exports.reload({noUpdateWidget:true});
exports.reload({noUpdateWidget:true});
2 changes: 1 addition & 1 deletion apps/recorder/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "recorder",
"name": "Recorder",
"shortName": "Recorder",
"version": "0.48",
"version": "0.49",
"author": "bobrippling",
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
"icon": "app.png",
Expand Down