Skip to content
Snippets Groups Projects

ECG App update

Merged Daniel Hoffend requested to merge griffon/firmware:ecg-ledupdate into master
All threads resolved!
1 file
+ 18
19
Compare changes
  • Side-by-side
  • Inline
+ 18
19
@@ -6,6 +6,7 @@ import buttons
@@ -6,6 +6,7 @@ import buttons
import max30001
import max30001
import math
import math
import struct
import struct
 
import itertools
WIDTH = 160
WIDTH = 160
HEIGHT = 80
HEIGHT = 80
@@ -24,11 +25,17 @@ COLOR_MODE_FINGER = [0, 255, 0]
@@ -24,11 +25,17 @@ COLOR_MODE_FINGER = [0, 255, 0]
COLOR_MODE_USB = [0, 0, 255]
COLOR_MODE_USB = [0, 0, 255]
COLOR_WRITE_FG = [255, 255, 255]
COLOR_WRITE_FG = [255, 255, 255]
COLOR_WRITE_BG = [255, 0, 0]
COLOR_WRITE_BG = [255, 0, 0]
LED_FLAG_BAR = 1
LED_FLAG_PULSE = 2
current_mode = MODE_FINGER
current_mode = MODE_FINGER
led_mode = LED_FLAG_BAR + LED_FLAG_PULSE
modes = itertools.cycle(
 
[
 
({"bar", "pulse"}, {"text": "Top + Pulse", "posx": 0}),
 
({}, {"text": "off", "posx": 55}),
 
({"bar"}, {"text": "Top Only", "posx": 25}),
 
({"pulse"}, {"text": "Pulse Only", "posx": 5}),
 
]
 
)
 
led_mode = next(modes)[0]
history = []
history = []
filebuffer = bytearray()
filebuffer = bytearray()
write = 0
write = 0
@@ -240,21 +247,13 @@ def toggle_pause():
@@ -240,21 +247,13 @@ def toggle_pause():
def toggle_leds():
def toggle_leds():
global led_mode, disp, pause_screen, leds
global led_mode, disp, pause_screen, leds, modes
led_mode = (led_mode + 1) % 4
led_mode, display_args = next(modes)
pause_screen = utime.time_ms() + 250
pause_screen = utime.time_ms() + 250
disp.clear(COLOR_BACKGROUND)
disp.clear(COLOR_BACKGROUND)
disp.print("LEDs", posx=50, posy=20, fg=COLOR_TEXT)
disp.print("LEDs", posx=50, posy=20, fg=COLOR_TEXT)
if not led_mode:
disp.print(**display_args, posy=40, fg=COLOR_TEXT)
disp.print("off", posx=55, posy=40, fg=COLOR_TEXT)
elif led_mode == LED_FLAG_BAR:
disp.print("Top only", posx=25, posy=40, fg=COLOR_TEXT)
elif led_mode == LED_FLAG_PULSE:
disp.print("Pulse only", posx=5, posy=40, fg=COLOR_TEXT)
elif led_mode == LED_FLAG_BAR + LED_FLAG_PULSE:
disp.print("Top + Pulse", posx=0, posy=40, fg=COLOR_TEXT)
disp.update()
disp.update()
leds.clear()
leds.clear()
@@ -265,11 +264,11 @@ def draw_leds(vmin, vmax):
@@ -265,11 +264,11 @@ def draw_leds(vmin, vmax):
global pulse, samples_since_last_pulse, last_pulse_blink
global pulse, samples_since_last_pulse, last_pulse_blink
# stop blinking
# stop blinking
if not led_mode:
if not bool(led_mode):
return
return
# update led bar
# update led bar
if led_mode & LED_FLAG_BAR:
if "bar" in led_mode:
for i in reversed(range(6)):
for i in reversed(range(6)):
leds.prep_hsv(
leds.prep_hsv(
5 + i, COLORS[5 + i] if vmin <= 0 and i <= vmin * -6 else (0, 0, 0)
5 + i, COLORS[5 + i] if vmin <= 0 and i <= vmin * -6 else (0, 0, 0)
@@ -281,13 +280,13 @@ def draw_leds(vmin, vmax):
@@ -281,13 +280,13 @@ def draw_leds(vmin, vmax):
# blink red on pulse
# blink red on pulse
if (
if (
led_mode & LED_FLAG_PULSE
"pulse" in led_mode
and pulse > 0
and pulse > 0
and samples_since_last_pulse < last_pulse_blink
and samples_since_last_pulse < last_pulse_blink
):
):
for i in range(4):
for i in range(4):
leds.prep(11 + i, (255, 0, 0))
leds.prep(11 + i, (255, 0, 0))
elif led_mode & LED_FLAG_PULSE:
elif "pulse" in led_mode:
for i in range(4):
for i in range(4):
leds.prep(11 + i, (0, 0, 0))
leds.prep(11 + i, (0, 0, 0))
last_pulse_blink = samples_since_last_pulse
last_pulse_blink = samples_since_last_pulse
@@ -387,7 +386,7 @@ def main():
@@ -387,7 +386,7 @@ def main():
" Pause >", posx=0, posy=28, fg=COLOR_MODE_FINGER, font=display.FONT16
" Pause >", posx=0, posy=28, fg=COLOR_MODE_FINGER, font=display.FONT16
)
)
disp.print(
disp.print(
" Mode / Bias >", posx=0, posy=44, fg=COLOR_MODE_USB, font=display.FONT16
" Mode/Bias >", posx=0, posy=44, fg=COLOR_MODE_USB, font=display.FONT16
)
)
disp.print(
disp.print(
"< LED/WriteLog", posx=0, posy=64, fg=COLOR_WRITE_BG, font=display.FONT16
"< LED/WriteLog", posx=0, posy=64, fg=COLOR_WRITE_BG, font=display.FONT16
Loading