From 9779ffb678f72bf5f6eb84633f0aa0581ec68eb4 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:27:45 -0300 Subject: [PATCH] Update heartrate.py --- heartrate.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/heartrate.py b/heartrate.py index 048d348..64f0a57 100644 --- a/heartrate.py +++ b/heartrate.py @@ -22,9 +22,11 @@ antnode = None hr_monitor = None power_meter = None + xp = [0] yp = [0] last = 0 +stopped = True zones_file = '%s/zones.csv' % SCRIPT_DIR if os.path.isfile(zones_file): @@ -64,11 +66,16 @@ def interp(x_arr, y_arr, x): def heart_rate_data(computed_heartrate, event_time_ms, rr_interval_ms): global last + global stopped t = int(time.time()) if t >= last + 1: power = int(interp(xp, yp, computed_heartrate)) - if power and power_meter: - power_meter.update(power) + if power: + if power_meter: power_meter.update(power) + stopped = False + elif not stopped: + if power_meter: power_meter.update(power) + stopped = True last = t try: