more hrm tweaks - show filtered data if available

pull/780/head^2
Gordon Williams 2021-07-27 17:01:00 +01:00
parent c09ec22599
commit 3d9435e67e
1 changed files with 7 additions and 4 deletions

View File

@ -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;