1
0
Fork 0

Merge pull request #1651 from GrandVizierOlaf/master

[exstats/run] Include maxbpm as a stat that can be tracked
master
Gordon Williams 2022-04-04 09:28:45 +01:00 committed by GitHub
commit c2ca52fd1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -14,7 +14,8 @@ the red `STOP` in the bottom right turns to a green `RUN`.
shown will increase, even if you are standing still.
* `TIME` - the elapsed time for your run
* `PACE` - the number of minutes it takes you to run a given distance, configured in settings (default 1km) **based on your run so far**
* `HEART` - Your heart rate
* `HEART (BPM)` - Your current heart rate
* `Max BPM` - Your maximum heart rate reached during the run
* `STEPS` - Steps since you started exercising
* `CADENCE` - Steps per second based on your step rate *over the last minute*
* `GPS` - this is green if you have a GPS lock. GPS is turned on automatically
@ -35,7 +36,7 @@ Under `Settings` -> `App` -> `Run` you can change settings for this app.
record GPS/HRM/etc data every time you start a run?
* `Pace` is the distance that pace should be shown over - 1km, 1 mile, 1/2 Marathon or 1 Marathon
* `Boxes` leads to a submenu where you can configure what is shown in each of the 6 boxes on the display.
Available stats are "Time", "Distance", "Steps", "Heart (BPM)", "Pace (avg)", "Pace (curr)", "Speed", and "Cadence".
Available stats are "Time", "Distance", "Steps", "Heart (BPM)", "Max BPM", "Pace (avg)", "Pace (curr)", "Speed", and "Cadence".
Any box set to "-" will display no information.
* Box 1 is the top left (defaults to "Distance")
* Box 2 is the top right (defaults to "Time")

View File

@ -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("maxbpm")) {
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;