1
0
Fork 0

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>
This commit is contained in:
Daniel Thompson 2020-08-15 20:40:26 +01:00
parent 34ca73ee60
commit 44ba8ebd22

View file

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