Skip to content
Snippets Groups Projects
Commit ddb872c3 authored by schneider's avatar schneider
Browse files

chore(spo2): Small app cleanup

parent ef21ef02
No related branches found
No related tags found
No related merge requests found
...@@ -40,8 +40,8 @@ class SPO2: ...@@ -40,8 +40,8 @@ class SPO2:
# don't update on every callback # don't update on every callback
if self.update_screen >= self.DRAW_AFTER_SAMPLES: if self.update_screen >= self.DRAW_AFTER_SAMPLES:
self.disp.clear(self.COLOR_BACKGROUND) self.disp.clear(self.COLOR_BACKGROUND)
self.draw_histogram(self.ir_history, color.RED) self.draw_history(self.ir_history, color.RED)
self.draw_histogram(self.red_history, color.GREEN) self.draw_history(self.red_history, color.GREEN)
spo2, spo2_valid, hr, hr_valid = spo2_algo.maxim_rd117( spo2, spo2_valid, hr, hr_valid = spo2_algo.maxim_rd117(
self.ir_history, self.red_history self.ir_history, self.red_history
) )
...@@ -76,12 +76,6 @@ class SPO2: ...@@ -76,12 +76,6 @@ class SPO2:
# 4x over sampling is active ATM # 4x over sampling is active ATM
self.sensor = max86150.MAX86150(callback=callback, sample_rate=self.RATE * 4) self.sensor = max86150.MAX86150(callback=callback, sample_rate=self.RATE * 4)
while True:
utime.sleep(0.1)
if buttons.read(buttons.BOTTOM_RIGHT):
pass
while buttons.read(buttons.BOTTOM_RIGHT):
pass
def update_history(self, datasets): def update_history(self, datasets):
for val in datasets: for val in datasets:
...@@ -121,7 +115,7 @@ class SPO2: ...@@ -121,7 +115,7 @@ class SPO2:
self.ir_history = self.ir_history[-self.HISTORY_MAX :] self.ir_history = self.ir_history[-self.HISTORY_MAX :]
self.red_history = self.red_history[-self.HISTORY_MAX :] self.red_history = self.red_history[-self.HISTORY_MAX :]
def draw_histogram(self, history, col): def draw_history(self, history, col):
# offset in pause_histogram mode # offset in pause_histogram mode
window_end = len(history) - self.histogram_offset window_end = len(history) - self.histogram_offset
s_start = max(0, window_end - (self.RATE * 2)) s_start = max(0, window_end - (self.RATE * 2))
...@@ -156,3 +150,10 @@ if __name__ == "__main__": ...@@ -156,3 +150,10 @@ if __name__ == "__main__":
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
sensor.close() sensor.close()
raise e raise e
while True:
utime.sleep(0.1)
if buttons.read(buttons.BOTTOM_RIGHT):
pass
while buttons.read(buttons.BOTTOM_RIGHT):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment