Tested on LilyGo-EPD47 T5 E-Paper 4.7" running MicroPython v1.18
Initialize the L58Touch controller.
Parameters:
bus: SoftI2C object
address: I2C address of the touch controller
Write bytearray `write` to the controller then read `nbytes` bytes from the controller
and return the bytearray result.
Parameters:
write: bytearray to write to the controller
nbytes: number of bytes to read from the controller
Returns:
bytearray: result of the read operation
Clear the touch controller flags
Parse `point` from `point_data` and append it to the touch_data list as a tuple.
Parameters:
point: point number
point_data: list of bytes from the controller
Format of `touch_data`: (finger, x, y, weight, status)
finger: order of the point touched
x: x coordinate of the point touched
y: y coordinate of the point touched
weight: weight/pressure of the point touched (1-15)
status: status of the point touched (3 pressed, 0 released)
Not all points will report released status during multi-touch.
scan the touch controller for touch points and update the touch_data list
Returns:
int: number of points touched
Return the last point in the touch_data list.
Point Format: (finger, x, y, weight, status)
finger: order of the point touched
x: x coordinate of the point touched
y: y coordinate of the point touched
weight: weight/pressure of the point touched (1-15)
status: status of the point touched (3 pressed, 0 released)
Not all points will report released status during multi-touch.
Put the touch controller to sleep
Wake up the touch controller.
Must be called to wake up the controller after sleep.
from time import sleep
from machine import Pin, SoftI2C
import l58_touch
tp = l58_touch.L58Touch(SoftI2C(Pin(14), Pin(15)), 90)
while True:
for _ in range(tp.scan_point()):
if touch_point := tp.get_point():
print(touch_point)
sleep(0.1)