Commit bc7e3b92 authored by Yuval Adam's avatar Yuval Adam
Browse files

Add led activity to ECG app

parent 1d21f7c1
import os import os
import display import display
import leds
import utime import utime
import buttons import buttons
import max30001 import max30001
...@@ -36,6 +37,10 @@ histogram_offset = 0 ...@@ -36,6 +37,10 @@ histogram_offset = 0
sensor = 0 sensor = 0
disp = display.open() disp = display.open()
leds.dim_top(1)
COLORS = [((23 + (15 * i)) % 360, 1.0, 1.0) for i in range(11)]
colors = COLORS
def callback_ecg(datasets): def callback_ecg(datasets):
global update_screen, history, filebuffer, write global update_screen, history, filebuffer, write
...@@ -161,6 +166,14 @@ def toggle_pause(): ...@@ -161,6 +166,14 @@ def toggle_pause():
histogram_offset = 0 histogram_offset = 0
def draw_leds(val):
global colors
# val should be in [0, 11]
for i in range(11):
leds.prep_hsv(10 - i, COLORS[10 - i] if i < val else (0, 0, 0))
leds.update()
def draw_histogram(): def draw_histogram():
global disp, history, current_mode, bias, write, pause_screen, update_screen global disp, history, current_mode, bias, write, pause_screen, update_screen
...@@ -211,6 +224,7 @@ def draw_histogram(): ...@@ -211,6 +224,7 @@ def draw_histogram():
old = value old = value
x += 1 x += 1
draw_leds((60 - int((max(history[-3:]) * scale + OFFSET) - 20)) * 11 / 60)
# draw text: mode/bias/write # draw text: mode/bias/write
if pause_histogram == True: if pause_histogram == True:
disp.print( disp.print(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment