drivers: cst816s: Decouple from the watch module
This commit is contained in:
parent
6dd50f89ba
commit
e5f455b5ba
1 changed files with 3 additions and 5 deletions
|
@ -1,13 +1,11 @@
|
||||||
"""Hynitron CST816S touch contoller driver for MicroPython."""
|
"""Hynitron CST816S touch contoller driver for MicroPython."""
|
||||||
|
|
||||||
import watch
|
|
||||||
|
|
||||||
class CST816S:
|
class CST816S:
|
||||||
"""Hynitron CST816S I2C touch controller driver."""
|
"""Hynitron CST816S I2C touch controller driver."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, bus):
|
||||||
|
self.i2c = bus
|
||||||
self.dbuf = bytearray(6)
|
self.dbuf = bytearray(6)
|
||||||
pass
|
|
||||||
|
|
||||||
def get_event(self, queue):
|
def get_event(self, queue):
|
||||||
"""Receive a touch event.
|
"""Receive a touch event.
|
||||||
|
@ -20,7 +18,7 @@ class CST816S:
|
||||||
dbuf = self.dbuf
|
dbuf = self.dbuf
|
||||||
|
|
||||||
try:
|
try:
|
||||||
watch.i2c.readfrom_mem_into(21, 1, dbuf)
|
self.i2c.readfrom_mem_into(21, 1, dbuf)
|
||||||
except OSError:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue