Skip to content

Commit

Permalink
Update heartrate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm authored Jul 28, 2020
1 parent 2291b86 commit 9779ffb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions heartrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9779ffb

Please sign in to comment.