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

feat(spo2): Option to select Red/IR as source

parent c28aed8d
Branches
Tags
1 merge request!414SpO2 sensor improvements
import max86150
import display
import utime
import buttons
class SPO2:
......@@ -20,6 +22,7 @@ class SPO2:
self.avg_pos = 0
self.last_sample = 0.0
self.filtered_value = 0.0
self.source = "Red"
def open(self):
def callback(datasets):
......@@ -33,12 +36,21 @@ class SPO2:
self.sensor = max86150.MAX86150(callback)
while True:
pass
utime.sleep(.1)
if buttons.read(buttons.BOTTOM_RIGHT):
if self.source == "Red":
self.source = "IR"
else:
self.source = "Red"
while buttons.read(buttons.BOTTOM_RIGHT): pass
def update_history(self, datasets):
for val in datasets:
# get red value (first in tuple)
self.avg[self.avg_pos] = val.red
if self.source == "Red":
self.avg[self.avg_pos] = val.red
else:
self.avg[self.avg_pos] = val.infrared
if self.avg_pos < 9:
self.avg_pos += 1
else:
......@@ -57,6 +69,7 @@ class SPO2:
def draw_histogram(self):
self.disp.clear(self.COLOR_BACKGROUND)
self.disp.print('Source: {0} '.format(self.source))
# offset in pause_histogram mode
window_end = len(self.history) - self.histogram_offset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment