10-20-2018 03:12
10-20-2018 03:12
I have had a couple of reports that the heart rate is not displaying on the clock face i made.
They are saying they see Null or the 2 dashes i have set which is when the timestamp is the same as the previous reading. here is my code:
const hrm = new HeartRateSensor();
hrm.start();
hrm.onreading = function() {
if (hrm.timestamp === lastReading) {
heartRate.text = "--";
} else {
heartRate.text = hrm.heartRate;
let bpm = user.heartRateZone(hrm.heartRate || 0);
let hrmi = document.getElementById("heartRateImage");
if (bpm === "out-of-range") {
//console.log('out of range ----');
hrmi.href = "icons/heart_open.png";
} else {
//console.log('in range');
hrmi.href = "icons/heart_solid.png";
}
}
lastReading = hrm.timestamp;
}
//stop heart monitor if screen is off
display.onchange = function() {
if (display.on) {
//console.log('screen on');
hrm.start();
hrm.onreading();
} else {
//console.log('screen off');
hrm.stop();
}
}I'm sure my code is pretty standard ? would it be better to not set the heart sensor as a constant ?
Answered! Go to the Best Answer.
Best Answer10-22-2018 09:54
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-22-2018 09:54
I don't think you should be calling onreading() manually. Other than that, it looks ok.
Best Answer10-22-2018 09:54
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-22-2018 09:54
I don't think you should be calling onreading() manually. Other than that, it looks ok.
Best Answer10-22-2018 12:49
10-22-2018 12:49
thanks Jon, i had that as when i was testing it on the simulator i had to manually move the heart rate up on the scale. i assume on the watch it should send a responce so will trigger the change. ill remove it and re-submit it and see if that helps the user.
thanks!
Best Answer