diff --git a/modules/exstats.js b/modules/exstats.js index 5d7cf0c2b..830398a51 100644 --- a/modules/exstats.js +++ b/modules/exstats.js @@ -15,6 +15,7 @@ print(ExStats.getList()); {name: "Distance", id:"dist"}, {name: "Steps", id:"step"}, {name: "Heart (BPM)", id:"bpm"}, + {name: "Max BPM", id:"maxbpm"}, {name: "Pace (avr)", id:"pacea"}, {name: "Pace (current)", id:"pacec"}, {name: "Cadence", id:"caden"}, @@ -72,6 +73,7 @@ var state = { // cadence // steps per minute adjusted if <1 minute // BPM // beats per minute // BPMage // how many seconds was BPM set? + // maxBPM // The highest BPM reached while active // Notifies: 0 for disabled, otherwise how often to notify in meters, seconds, or steps notify: { dist: { @@ -159,6 +161,10 @@ Bangle.on("HRM", function(h) { if (h.confidence>=60) { state.BPM = h.bpm; state.BPMage = 0; + if (state.maxBPM < h.bpm) { + state.maxBPM = h.bpm; + if (stats["maxbpm"]) stats["maxbpm"].emit("changed",stats["maxbpm"]); + } if (stats["bpm"]) stats["bpm"].emit("changed",stats["bpm"]); } }); @@ -170,6 +176,7 @@ exports.getList = function() { {name: "Distance", id:"dist"}, {name: "Steps", id:"step"}, {name: "Heart (BPM)", id:"bpm"}, + {name: "Max BPM", id:"maxbpm"}, {name: "Pace (avg)", id:"pacea"}, {name: "Pace (curr)", id:"pacec"}, {name: "Speed", id:"speed"}, @@ -230,6 +237,14 @@ exports.getStats = function(statIDs, options) { getString : function() { return state.BPM||"--" }, }; } + if (statIDs.includes("bpm")) { + needHRM = true; + stats["maxbpm"]={ + title : "Max BPM", + getValue : function() { return state.maxBPM; }, + getString : function() { return state.maxBPM||"--" }, + }; + } if (statIDs.includes("pacea")) { needGPS = true; stats["pacea"]={ @@ -299,6 +314,7 @@ exports.getStats = function(statIDs, options) { state.curSpeed = 0; state.BPM = 0; state.BPMage = 0; + state.maxBPM = 0; state.notify = options.notify; if (options.notify.dist.increment > 0) { state.notify.dist.next = state.distance + options.notify.dist.increment;