From d7b8753d40d964ee9e66f8e0f869dfb00414c26b Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sat, 11 Apr 2020 04:18:32 +0200
Subject: [PATCH] fix(max86150): Use 4x averaging on chip

---
 epicardium/modules/max86150.c | 2 ++
 preload/apps/spo2/__init__.py | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/epicardium/modules/max86150.c b/epicardium/modules/max86150.c
index 154705bfa..f452f303c 100644
--- a/epicardium/modules/max86150.c
+++ b/epicardium/modules/max86150.c
@@ -66,6 +66,8 @@ int epic_max86150_enable_sensor(
 		ppg_sample_rate = MAX86150_PPG_SAMPLERATE_100;
 	} else if (config->ppg_sample_rate == 200) {
 		ppg_sample_rate = MAX86150_PPG_SAMPLERATE_200;
+	} else if (config->ppg_sample_rate == 400) {
+		ppg_sample_rate = MAX86150_PPG_SAMPLERATE_400;
 	} else {
 		result = -EINVAL;
 		goto out_free;
diff --git a/preload/apps/spo2/__init__.py b/preload/apps/spo2/__init__.py
index dbe9b83c4..120666228 100644
--- a/preload/apps/spo2/__init__.py
+++ b/preload/apps/spo2/__init__.py
@@ -7,7 +7,7 @@ import buttons
 class SPO2:
     def __init__(self):
         self.sensor = None
-        self.RATE = 128
+        self.RATE = 100
         self.HISTORY_MAX = self.RATE * 4
         self.history = []
         self.update_screen = 0
@@ -35,7 +35,7 @@ class SPO2:
             if self.update_screen >= self.DRAW_AFTER_SAMPLES:
                 self.draw_histogram()
 
-        self.sensor = max86150.MAX86150(callback)
+        self.sensor = max86150.MAX86150(callback=callback, sample_rate=self.RATE * 4)
         while True:
             utime.sleep(.1)
             if buttons.read(buttons.BOTTOM_RIGHT):
-- 
GitLab