diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-06-30 22:04:01 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-06-30 22:04:01 (GMT) |
| commit | ae5743529f82d398876456b7e175defb19a6ccfc (patch) | |
| tree | abaebb87754a952a15d7b062d36bfd9b668794e3 /wasp/drivers | |
| parent | 11be7ca3280134cf4e565198f87c316179cf2dc9 (diff) | |
wasp: Switch to scheduling from interrupt
This has two useful properties. Firstly it means the watch will be
maintained in the background, allowing the REPL to be used for
notifications and other updates. Secondly it will save a little bit
of power by reducing the work needed to handle spurious wake ups.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/drivers')
| -rw-r--r-- | wasp/drivers/cst816s.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/wasp/drivers/cst816s.py b/wasp/drivers/cst816s.py index 135c15f..2aeaf25 100644 --- a/wasp/drivers/cst816s.py +++ b/wasp/drivers/cst816s.py @@ -15,7 +15,7 @@ class CST816S: .. automethod:: __init__ """ - def __init__(self, bus, intr, rst): + def __init__(self, bus, intr, rst, schedule=None): """Specify the bus used by the touch controller. :param machine.I2C bus: I2C bus for the CST816S. @@ -23,6 +23,7 @@ class CST816S: self.i2c = bus self.tp_int = intr self.tp_rst = rst + self.schedule = schedule self.dbuf = bytearray(6) self.event = array.array('H', (0, 0, 0)) @@ -53,6 +54,9 @@ class CST816S: event[1] = ((dbuf[2] & 0xf) << 8) + dbuf[3] # x coord event[2] = ((dbuf[4] & 0xf) << 8) + dbuf[5] # y coord + if self.schedule: + self.schedule(self) + def get_event(self): """Receive a touch event. |
