From 3d9435e67e65ec7a58bcda6a0d73c5eea0b1d180 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 27 Jul 2021 17:01:00 +0100 Subject: [PATCH] more hrm tweaks - show filtered data if available --- apps/hrm/heartrate.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/hrm/heartrate.js b/apps/hrm/heartrate.js index 9bc708ee8..a6b8e791a 100644 --- a/apps/hrm/heartrate.js +++ b/apps/hrm/heartrate.js @@ -3,6 +3,8 @@ Bangle.setLCDTimeout(0); Bangle.setHRMPower(1); var hrmInfo, hrmOffset = 0; var hrmInterval; +var btm = g.getHeight()-1; + function onHRM(h) { if (counter!==undefined) { // the first time we're called remove @@ -26,7 +28,7 @@ function onHRM(h) { var px = g.getWidth()/2; g.setFontAlign(0,0); - g.clearRect(0,24,239,90); + g.clearRect(0,24,239,80); g.setFont("6x8").drawString("Confidence "+hrmInfo.confidence+"%", px, 75); var str = hrmInfo.bpm; g.setFontVector(40).drawString(str,px,45); @@ -38,15 +40,16 @@ Bangle.on('HRM', onHRM); /* On newer (2v10) firmwares we can subscribe to get HRM events as they happen */ Bangle.on('HRM-raw', function(v) { - var a = v.raw; hrmOffset++; if (hrmOffset>g.getWidth()) { hrmOffset=0; - g.clearRect(0,90,239,239); + g.clearRect(0,80,239,239); g.moveTo(-100,0); } - y = E.clip(170 - (v.raw),100,230); + y = E.clip(btm-v.filt/4,btm-10,btm); + g.setColor(1,0,0).fillRect(hrmOffset,btm, hrmOffset, y); + y = E.clip(170 - (v.raw/2),80,btm); g.setColor(g.theme.fg).lineTo(hrmOffset, y); if (counter !==undefined) { counter = undefined;