From 294797d8263b316809214a2d1cb9534dff810bd0 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Wed, 11 Nov 2020 22:05:23 +0000 Subject: [PATCH] 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 --- wasp/drivers/hrs3300.py | 3 +++ 1 file changed, 3 insertions(+) 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)