From cdc2da170b2fe53949613566ba2228496bc3d445 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 3 Jul 2022 10:30:27 +0200 Subject: [PATCH] hrmaccevents - Use internal HRM event if needed --- apps/hrmaccevents/README.md | 2 +- apps/hrmaccevents/custom.html | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/hrmaccevents/README.md b/apps/hrmaccevents/README.md index 9c131cfd8..188ca325a 100644 --- a/apps/hrmaccevents/README.md +++ b/apps/hrmaccevents/README.md @@ -6,7 +6,7 @@ This app can use [BTHRM](https://banglejs.com/apps/#bthrm) as a reference. ## Steps for usage * (Optional) Install [BTHRM](https://banglejs.com/apps/#bthrm) as reference (use ECG based sensor for best accuracy). - * Configure BTHRM to "Both"-Mode. This prevents data beeing lost because BTHRM can replace the HRM-events data with BTHRM data. + * Configure BTHRM to "Both"-Mode or use a version >= 0.12. This prevents data beeing lost because BTHRM can replace the HRM-events data with BTHRM data. * Click "Start" in browser. * Wait until the "Events" number starts to grow, that means there are events recorded. * Record for some time, since BTHRM and HRM often need some seconds to start getting useful values. Consider 2000 events a useful minimum. diff --git a/apps/hrmaccevents/custom.html b/apps/hrmaccevents/custom.html index b7b9d53a8..a5bf9796f 100644 --- a/apps/hrmaccevents/custom.html +++ b/apps/hrmaccevents/custom.html @@ -56,7 +56,12 @@ function createCode(){ return gotBTHRM && gotHRM && gotHRMraw && gotAcc; } + let bthrmSettings = (require("Storage").readJSON("bthrm.json",1) || {}); + Bangle.setHRMPower(1); + + if (bthrmSettings.replace) Bangle.origSetHRMPower(1); + if (Bangle.setBTHRMPower){ Bangle.setBTHRMPower(1); } else { @@ -123,7 +128,11 @@ function createCode(){ Bangle.on("accel", writeAccDirect); } Bangle.on("HRM-raw", writeHRMraw); - Bangle.on("HRM", writeHRM); + if (bthrmSettings.replace){ + Bangle.origOn("HRM", writeHRM); + } else { + Bangle.on("HRM", writeHRM); + } Bangle.on("BTHRM", writeBTHRM); g.clear(); @@ -280,7 +289,7 @@ document.getElementById("btnConnect").addEventListener("click", function() { l.forEach(onLine); }); connection.write("reset();\n", function() { - setTimeout(function() { + setTimeout(function() { connection.write("\x03\x10if(1){"+createCode()+"}\n", function() { console.log("Ready..."); }); }, 1500);