gt911
— 触摸屏驱动¶
基本轮询模式示例用法:
import time
from gt911 import GT911
from machine import I2C
# Note use pin numbers or names not Pin objects because the
# driver needs to change pin directions to reset the controller.
touch = GT911(I2C(1, freq=400_000), reset_pin="P1", irq_pin="P2", touch_points=5)
while True:
n, points = touch.read_points()
for i in range(0, n):
print(f"id {points[i][3]} x {points[i][0]} y {points[i][1]} size {points[i][2]}")
time.sleep_ms(100)
构造¶
方法¶
- GT911.read_points()¶
返回一个包含点数计数和点元组数组的元组。每个点元组具有 x[0]、y[1]、size[2] 和 id[3]。x/y 是屏幕上的位置。Size 是施加的压力量。Id 是每个点的唯一 ID,应与读取的相同点相关联。