|
TinyGPU
|
GT911 capacitive touch controller. More...
#include <TouchDriverArduino.h>


Public Member Functions | |
| TouchDriverGT911 (TwoWire &wire=Wire, int8_t rstPin=-1, int8_t irqPin=-1, uint8_t i2cAddr=I2C_ADDR_1) | |
| bool | begin () override |
| Initialize the controller. | |
| bool | isTouched () override |
| Return whether the panel currently appears touched. | |
| bool | getPoint (Point &outPoint) override |
| Read the current touch point. | |
| bool | getSecondPoint (Point &outPoint) override |
| Read a second, simultaneous touch point, for multi-touch gestures (pinch/rotate). | |
Public Member Functions inherited from TouchDriver | |
| virtual | ~TouchDriver ()=default |
| virtual bool | begin ()=0 |
| Initialize the controller. | |
| virtual bool | isTouched ()=0 |
| Return whether the panel currently appears touched. | |
| virtual bool | getPoint (Point &outPoint)=0 |
| Read the current touch point. | |
| virtual bool | getSecondPoint (Point &outPoint) |
| Read a second, simultaneous touch point, for multi-touch gestures (pinch/rotate). | |
| void | setRotation (Rotation rotation) |
| Rotation | getRotation () const |
| bool | setCalibration (const CalibrationData &cal) |
| Set and validate calibration. | |
| const CalibrationData & | getCalibration () const |
| bool | hasCalibration () const |
Static Public Attributes | |
| static constexpr uint8_t | I2C_ADDR_1 = 0x5D |
| static constexpr uint8_t | I2C_ADDR_2 = 0x14 |
Additional Inherited Members | |
Protected Member Functions inherited from TouchDriver | |
| Point | mapCoordinates (int16_t rawX, int16_t rawY, uint16_t pressure=255) const |
| Convert raw controller coordinates into logical display space. | |
Static Protected Member Functions inherited from TouchDriver | |
| static bool | validateCalibration (const CalibrationData &cal) |
| static int32_t | clamp32 (int32_t value, int32_t minimum, int32_t maximum) |
| Clamp an integer to an inclusive range. | |
| static int32_t | mapRange (int32_t value, int32_t inMin, int32_t inMax, int32_t outMin, int32_t outMax) |
| Map an integer from one range to another. | |
Protected Attributes inherited from TouchDriver | |
| Rotation | rotation_ = Rotation::Deg0 |
| CalibrationData | calibration_ |
| bool | hasCalibration_ = false |
GT911 capacitive touch controller.
I2C address is normally 0x5D (alt 0x14, selected via the INT pin's level while RST is pulsed - see begin()). Unlike FT6236/CST816S, GT911's register addresses are 16-bit (MSB first), and its X/Y bytes are little-endian (low byte first) rather than the big-endian nibble-packed layout FT6236 uses.
Register layout used:
0x8100 CONFIG_FRESH: write 1 after reset to make the chip start its sensing engine. Without this, the chip stays fully alive and correctly configured but never scans - status sits at 0x80 ("config loaded, idle") forever. 0x80FF config checksum: round-tripped (read then written back unchanged) alongside the CONFIG_FRESH write. 0x814E status: bit7 = buffer ready, bits[3:0] = touch point count. Must be cleared (write 0x00) unconditionally on every poll, not only when a touch was found - clearing it only after a detected touch is a deadlock, since a stale, unacknowledged flag prevents the chip from ever reporting a new one. 0x814F point 0 data (7 bytes: track_id, x_lo, x_hi, y_lo, y_hi, size_lo, size_hi); point N starts at 0x814F + N*7.
Because status must be cleared unconditionally exactly once per poll cycle, isTouched() does the chip's actual read/clear I/O and caches whatever point data was present; getPoint()/getSecondPoint() just return the cached result rather than re-querying the chip. Call isTouched() once per loop iteration (the same usage pattern as this file's other touch drivers) - calling it more than once between getPoint() calls will consume/clear a pending touch before getPoint() sees it.
GT911 genuinely reports up to 5 simultaneous touches (unlike the single-touch FT6236/CST816S/XPT2046 parts also in this file), so getSecondPoint() is a real second contact, not a stub.
|
inline |
|
inlineoverridevirtual |
Initialize the controller.
The driver does NOT initialize the SPI/I2C bus itself. The application is responsible for calling Wire.begin(), SPI.begin(), and configuring any board-specific bus pins.
Implements TouchDriver.
|
inlineoverridevirtual |
Read the current touch point.
Implements TouchDriver.
|
inlineoverridevirtual |
Read a second, simultaneous touch point, for multi-touch gestures (pinch/rotate).
Returns false by default. Only override this if the underlying controller can genuinely report two simultaneous touches - none of the drivers built into this library can (XPT2046 is a resistive, inherently single-touch controller; CST816S/FT6236 are single-touch capacitive parts), so pinch/rotate gestures built on top of this will not fire against them.
Reimplemented from TouchDriver.
|
inlineoverridevirtual |
Return whether the panel currently appears touched.
For controllers without an IRQ pin this may perform a controller read.
Implements TouchDriver.
|
staticconstexpr |
|
staticconstexpr |