gt911 — GT911 5-Point Capacitive Touch Controller¶
The gt911 module provides a driver for the Goodix GT911
projected-capacitive touchscreen controller, a common pairing with
4.3”–7” 800x480 LCD panels. The controller tracks up to five
simultaneous touch points and reports each as an (x, y, size,
id) tuple where id is stable across reads for as long as the
finger remains on the panel.
The driver communicates with the chip over I2C and uses two extra GPIOs:
a reset line, held low during power-up and toggled together with the IRQ line to select the GT911’s 7-bit I2C address (
0x5Dwhen IRQ is low during reset,0x14when IRQ is high);an interrupt line, asserted by the controller when a touch event occurs.
After construction, applications can poll for touches with
GT911.read_points() or supply a touch_callback to be
invoked on the IRQ pin’s falling edge.
class GT911 – 5-Point Capacitive Touch Controller¶
- class gt911.GT911(bus: machine.I2C, reset_pin: int | str, irq_pin: int | str, address: int = _DEFAULT_ADDR, width: int = 800, height: int = 480, touch_points: int = 1, reverse_x: bool = False, reverse_y: bool = False, reverse_axis: bool = True, sito: bool = True, refresh_rate: int = 240, touch_callback: Callable | None = None)¶
Creates a GT911 touch screen controller object.
busis themachine.I2Cbus object the GT911 is attached to.reset_pinis the pin number or name (not aPinobject) connected to the GT911 reset line. The driver needs to change pin direction during reset.irq_pinis the pin number or name (not aPinobject) connected to the GT911 interrupt line. The driver needs to change pin direction during reset.addressis the I2C address of the controller. Defaults togt911._DEFAULT_ADDR.widthis the touch panel resolution along the X axis in pixels.heightis the touch panel resolution along the Y axis in pixels.touch_pointsis the maximum number of simultaneous touch points to report (1 to 5).reverse_xif True flips the X axis.reverse_yif True flips the Y axis.reverse_axisif True swaps the X and Y axes.sitoenables the controller’s Single-Input-Touch-Output mode when True.refresh_rateis the touch report rate in Hz.touch_callbackis an optional callable invoked on the falling edge of the IRQ pin when a touch event occurs. PassNoneto use polling mode.- read_points() tuple¶
Returns a tuple
(n, points)wherenis the number of active touch points andpointsis a list of 5array("H", ...)entries. Each entry contains[x, y, size, id]:xandyare the screen coordinates,sizeis the touch pressure, andidis a unique tracking ID that remains stable for a given finger across reads.Only the first
nentries ofpointscontain valid data.