Fix some logic in the health app
parent
e9bfe885e7
commit
cdb441d40f
|
|
@ -1,28 +1,28 @@
|
||||||
(function(){
|
(function() {
|
||||||
var settings = require("Storage").readJSON("health.json",1)||{};
|
var settings = require("Storage").readJSON("health.json", 1) || {};
|
||||||
var hrm = 0|settings.hrm;
|
var hrm = 0|settings.hrm;
|
||||||
if (hrm == 1 || hrm == 2) {
|
if (hrm == 1 || hrm == 2) {
|
||||||
function onHealth() {
|
function onHealth() {
|
||||||
Bangle.setHRMPower(1, "health");
|
Bangle.setHRMPower(1, "health");
|
||||||
setTimeout(()=>Bangle.setHRMPower(0, "health"),hrm*60000); // give it 1 minute detection time for 3 min setting and 2 minutes for 10 min setting
|
setTimeout(() => Bangle.setHRMPower(0, "health"), hrm * 60000); // give it 1 minute detection time for 3 min setting and 2 minutes for 10 min setting
|
||||||
if (hrm == 1){
|
if (hrm == 1) {
|
||||||
for (var i = 1; i <= 2; i++){
|
function startMeasurement() {
|
||||||
setTimeout(()=>{
|
|
||||||
Bangle.setHRMPower(1, "health");
|
Bangle.setHRMPower(1, "health");
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
Bangle.setHRMPower(0, "health");
|
Bangle.setHRMPower(0, "health");
|
||||||
}, 60000);
|
}, 60000);
|
||||||
}, (i * 200000));
|
|
||||||
}
|
}
|
||||||
|
setTimeout(startMeasurement, 200000);
|
||||||
|
setTimeout(startMeasurement, 400000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bangle.on("health", onHealth);
|
Bangle.on("health", onHealth);
|
||||||
Bangle.on('HRM', h => {
|
Bangle.on("HRM", (h) => {
|
||||||
if (h.confidence>80) Bangle.setHRMPower(0, "health");
|
if (h.confidence > 80 && Bangle.getHealthStatus().bpm == h.bpm) Bangle.setHRMPower(0, "health");
|
||||||
});
|
});
|
||||||
if (Bangle.getHealthStatus().bpmConfidence) return;
|
if (Bangle.getHealthStatus().bpmConfidence > 80) return;
|
||||||
onHealth();
|
onHealth();
|
||||||
} else Bangle.setHRMPower(hrm!=0, "health");
|
} else Bangle.setHRMPower(!!hrm, "health");
|
||||||
})();
|
})();
|
||||||
|
|
||||||
Bangle.on("health", health => {
|
Bangle.on("health", health => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue