summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-11-11 22:05:23 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-11-11 22:07:21 (GMT)
commit294797d8263b316809214a2d1cb9534dff810bd0 (patch)
treec97dfc78eafb3bc2f3b88be3841a29267215da50
parent12110aa79ccf3b0fb307527d9968132d1214bb1c (diff)
hrs3300: Defer initialization until the HRS is used
This means hardware failure won't cause the initial boot to fail. This won't stop the heart rate app from crashing when it starts up but at least it will give a comprehensible crash report. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--wasp/drivers/hrs3300.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/wasp/drivers/hrs3300.py b/wasp/drivers/hrs3300.py
index 3843887..83f716b 100644
--- a/wasp/drivers/hrs3300.py
+++ b/wasp/drivers/hrs3300.py
@@ -27,6 +27,7 @@ class HRS3300:
def __init__(self, i2c):
self._i2c = i2c
+ def init(self):
w = self.write_reg
# HRS disabled, 12.5 ms wait time between cycles, (partly) 20mA drive
@@ -50,6 +51,8 @@ class HRS3300:
self._i2c.writeto_mem(_I2CADDR, addr, bytes((val,)))
def enable(self):
+ self.init()
+
enable = self.read_reg(_ENABLE)
enable |= _ENABLE_HEN
self.write_reg(_ENABLE, enable)