diff --git a/preload/apps/ecg/__init__.py b/preload/apps/ecg/__init__.py index 4a2b8e53c3a80ef1552f9483cd66659525fcaa30..b359d2007c22e7616fee14569518e84716ed5d95 100644 --- a/preload/apps/ecg/__init__.py +++ b/preload/apps/ecg/__init__.py @@ -256,7 +256,8 @@ def toggle_leds(): disp.update() -def draw_leds(vmin,vmax): + +def draw_leds(vmin, vmax): # vmin should be in [0, -1] # vmax should be in [0, 1] global pulse, samples_since_last_pulse, last_pulse_blink @@ -269,15 +270,23 @@ def draw_leds(vmin,vmax): # update led bar if led_mode & LED_FLAG_BAR: for i in reversed(range(6)): - leds.prep_hsv(5 + i, COLORS[5 + i] if vmin <= 0 and i <= vmin * -6 else (0, 0, 0)) + leds.prep_hsv( + 5 + i, COLORS[5 + i] if vmin <= 0 and i <= vmin * -6 else (0, 0, 0) + ) for i in reversed(range(6)): - leds.prep_hsv(i, COLORS[i] if vmax >= 0 and 5 - i <= vmax * 6 else (0, 0, 0)) + leds.prep_hsv( + i, COLORS[i] if vmax >= 0 and 5 - i <= vmax * 6 else (0, 0, 0) + ) else: for i in range(11): leds.prep(i, (0, 0, 0)) # blink red on pulse - if led_mode & LED_FLAG_PULSE and pulse > 0 and samples_since_last_pulse < last_pulse_blink: + if ( + led_mode & LED_FLAG_PULSE + and pulse > 0 + and samples_since_last_pulse < last_pulse_blink + ): last_pulse_blink = 0 for i in range(4): leds.prep(11 + i, (255, 0, 0)) @@ -338,7 +347,9 @@ def draw_histogram(): ) else: led_range = last_sample_count if last_sample_count > 5 else 5 - draw_leds(min(history[-led_range:]) / value_max, max(history[-led_range:]) / value_max) + draw_leds( + min(history[-led_range:]) / value_max, max(history[-led_range:]) / value_max + ) if pulse < 0: disp.print( current_mode + ("+Bias" if bias else ""), @@ -375,9 +386,15 @@ def main(): disp.clear(COLOR_BACKGROUND) disp.print(" BUTTONS ", posx=0, posy=0, fg=COLOR_TEXT, font=display.FONT20) disp.line(0, 20, 159, 20, col=COLOR_LINE) - disp.print(" Pause >", posx=0, posy=28, fg=COLOR_MODE_FINGER, font=display.FONT16) - disp.print(" Mode / Bias >", posx=0, posy=44, fg=COLOR_MODE_USB, font=display.FONT16) - disp.print("< LED/WriteLog", posx=0, posy=64, fg=COLOR_WRITE_BG, font=display.FONT16) + disp.print( + " Pause >", posx=0, posy=28, fg=COLOR_MODE_FINGER, font=display.FONT16 + ) + disp.print( + " Mode / Bias >", posx=0, posy=44, fg=COLOR_MODE_USB, font=display.FONT16 + ) + disp.print( + "< LED/WriteLog", posx=0, posy=64, fg=COLOR_WRITE_BG, font=display.FONT16 + ) disp.update() utime.sleep(3)