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)

构造函数

class gt911.GT911(bus, reset_pin, irq_pin[, address=0x5D[, width=800[, height=480[, touch_points=1[, reserve_x=False[, reserve_y=False[, reverse_axis=True[, stio=True[, refresh_rate=240[, touch_callback=None]]]]]]]]]])

创建一个触摸屏控制器对象。您应该根据上面的示例进行初始化。

方法

GT911._read_reg(reg[, size=1[, buf=None]])

读取寄存器值。

GT911._write_reg(reg, val[, size=1])

写入寄存器值。

GT911.read_id()

返回gt911芯片的ID。

GT911.read_points()

返回一个包含点数计数和点元组数组的元组。每个点元组具有 x[0]、y[1]、size[2] 和 id[3]。x/y 是屏幕上的位置。Size 是施加的压力量。Id 是每个点的唯一 ID,应与读取的相同点相关联。

GT911.reset()

复位gt911芯片。