From 801237b2cfad1caf17a0d4bb496527bd4a217e8a Mon Sep 17 00:00:00 2001 From: Marco Heiming Date: Wed, 5 Jan 2022 15:35:01 +0100 Subject: [PATCH] Let's only register HRM and battery events when respective circle is visible --- apps/circlesclock/app.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/apps/circlesclock/app.js b/apps/circlesclock/app.js index 2d6c132bb..e10d55f17 100644 --- a/apps/circlesclock/app.js +++ b/apps/circlesclock/app.js @@ -280,31 +280,32 @@ Bangle.on('lock', function(isLocked) { drawHeartRate(); } } + if (isCircleEnabled("steps")) drawSteps(); + if (isCircleEnabled("stepsDistance")) drawStepsDistance(); } else { if (isCircleEnabled("hr")) { Bangle.setHRMPower(0, "watch"); } } - if (isCircleEnabled("hr")) drawHeartRate(); - if (isCircleEnabled("steps")) drawSteps(); - if (isCircleEnabled("stepsDistance")) drawStepsDistance(); }); -Bangle.on('HRM', function(hrm) { - if (isCircleEnabled("hr")) { - //if(hrm.confidence > 90){ - hrtValue = hrm.bpm; - if (Bangle.isLCDOn()) - drawHeartRate(); - //} else { - // hrtValue = undefined; - //} - } -}); +if (isCircleEnabled("hr")) { + Bangle.on('HRM', function(hrm) { + //if(hrm.confidence > 90){ + hrtValue = hrm.bpm; + if (Bangle.isLCDOn()) + drawHeartRate(); + //} else { + // hrtValue = undefined; + //} + }); +} -Bangle.on('charging', function(charging) { - if (isCircleEnabled("battery")) drawBattery(); -}); +if (isCircleEnabled("battery")) { + Bangle.on('charging', function(charging) { + drawBattery(); + }); +} g.clear();