1
0
Fork 0

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>
This commit is contained in:
Daniel Thompson 2020-11-11 22:05:23 +00:00
parent 12110aa79c
commit 294797d826

View file

@ -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)