This library interfaces the GT911 touch controller with a microcontroller running Micropython
Complete examples are in the files:
example_polling.py
example_interrupt.py
To continuously checks for touch events in a loop:
tp = gt911.GT911(sda="PB7", scl="PB6", interrupt="PB4", reset="PB3")
tp.begin(gt.Addr.ADDR1)
while True:
points = tp.get_points()
if points:
print(f"Received touch events: {points}")
The interrupt example configures an interrupt handler to respond to touch events
def on_touch(_):
points = tp.get_points()
if points:
print(f"Received touch events: {points}")
Defining the rest of the program
tp = gt911.GT911(sda="PB7", scl="PB6", interrupt="PB4", reset="PB3")
tp.begin(gt.Addr.ADDR1)
print("Finished initialization.")
print(f" Screen: {tp.width}x{tp.height}")
tp.enable_interrupt(on_touch)