summaryrefslogtreecommitdiff
path: root/wasp/drivers
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-08-15 19:40:26 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-08-15 19:40:26 (GMT)
commit44ba8ebd22d525e8a8e9fdfe1d6c99a6965e06e2 (patch)
tree3bf14eba730d8297e27dc1de971546fa88abb9e3 /wasp/drivers
parent34ca73ee60c1ee4d5b8ccfa171c2a3a7f21950bc (diff)
drivers: cst816s: Handle a failure to sleep
Exceptions on th sleep path more or less kill the device (it is half alseep and is not on... but not off enough for the power button to work. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/drivers')
-rw-r--r--wasp/drivers/cst816s.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/wasp/drivers/cst816s.py b/wasp/drivers/cst816s.py
index 2aeaf25..0273ea9 100644
--- a/wasp/drivers/cst816s.py
+++ b/wasp/drivers/cst816s.py
@@ -87,10 +87,14 @@ class CST816S:
def sleep(self):
"""Put touch controller chip on sleep mode to save power.
"""
- # Before we can sent the sleep command we have to reset the
+ # Before we can send the sleep command we have to reset the
# panel to get the I2C hardware running again...
self._reset()
- self.i2c.writeto_mem(21, 0xa5, b'\x03')
+ try:
+ self.i2c.writeto_mem(21, 0xa5, b'\x03')
+ except:
+ # If we can't power down then let's just put it in reset instead
+ self.tp_rst.off()
# Ensure get_event() cannot return anything
self.event[0] = 0