Kleidos API Search

In development. It changes without notice.

Topic

Touch Controller Drivers

The FT6x36 and GT911 touch controllers.

  • Ft6x36: Core2 v1.3 and CoreS3 SE.
  • Gt911: LILYGO T-Deck. The chip takes one of two addresses when its supply comes up, and the driver looks at both. It also puts the controller to sleep and wakes it.

They return the controller's own coordinates. What a point means is decided in Input Sources & the Wake Rule.

See also
Input Sources & the Wake Rule, Display Panel Drivers

Files

file src/drivers/touch/ft6x36.h
FocalTech FT6x36 capacitive touch controller driver.
file src/drivers/touch/ft6x36_regs.h
FocalTech FT6x36 touch controller register map (Kleidos subset).
file src/drivers/touch/gt911.h
Goodix GT911 capacitive touch controller driver.
file src/drivers/touch/gt911_regs.h
Goodix GT911 touch controller register map, addresses and INT-line timings (Kleidos subset).
file src/drivers/touch/i_touch.h
Chip-level capacitive-touch driver contract.
file src/drivers/touch/touch_factory.cpp
Touch controller factory — probes the bus for a supported controller.

Classes

class kleidos::drivers::touch::Ft6x36
FT6206/FT6236/FT6336 touch driver: the FT6336U of the Core2 v1.3 and the CoreS3 SE. More about kleidos::drivers::touch::Ft6x36
class kleidos::drivers::touch::Gt911
GT911 touch driver (LILYGO T-Deck). More about kleidos::drivers::touch::Gt911
struct kleidos::drivers::touch::TouchContact
The primary contact a touch controller reports, in its raw coordinates. More about kleidos::drivers::touch::TouchContact
class kleidos::drivers::touch::ITouch
The contract every capacitive-touch chip driver implements. More about kleidos::drivers::touch::ITouch

Functions

constexpr std::array< uint8_t, kAddressCount >kleidos::drivers::touch::gt911::probeOrder (uint8_t lastAnswered)
The order to probe the two addresses in.
constexpr boolkleidos::drivers::touch::gt911::isGt9xxProductId (const std::array< uint8_t, kProductIdLength > &id)
Whether a product-id block read back is a GT9xx controller's.
constexpr boolkleidos::drivers::touch::gt911::isControllerAddress (uint8_t address)
Whether a remembered address is one this controller can answer at.
ITouch *kleidos::drivers::touch::createTouch (uint8_t address)
Probes the touch controller at address, returning a ready singleton driver for the detected chip, or nullptr if absent/unsupported. The instance lives in static storage; callers must not delete it.

Variables

constexpr uint8_tkleidos::drivers::touch::ft6x36::kRegStatus
Number of touch points (low nibble).
constexpr uint8_tkleidos::drivers::touch::ft6x36::kRegTouch1Xh
First contact: Xh, Xl, Yh, Yl.
constexpr uint8_tkleidos::drivers::touch::ft6x36::kPointCountMask
Mask for the active-point count (low nibble of 0x02).
constexpr uint8_tkleidos::drivers::touch::ft6x36::kCoordHighMask
Mask for the high nibble of each Xh/Yh byte.
constexpr uint8_tkleidos::drivers::touch::ft6x36::kMaxTouchPoints
Upper bound on points the driver decodes per read.
constexpr uint8_tkleidos::drivers::touch::gt911::kI2cAddressLow
constexpr uint8_tkleidos::drivers::touch::gt911::kI2cAddressHigh
constexpr uint8_tkleidos::drivers::touch::gt911::kNoAddress
No address has answered yet.
constexpr uint16_tkleidos::drivers::touch::gt911::kRegCommand
Real-time command register.
constexpr uint16_tkleidos::drivers::touch::gt911::kRegStatus
Buffer status / touch count.
constexpr uint16_tkleidos::drivers::touch::gt911::kRegPoint1
First contact: Xl, Xh, Yl, Yh, Sl, Sh.
constexpr uint16_tkleidos::drivers::touch::gt911::kRegProductId
Product ID ("911\0").
constexpr uint16_tkleidos::drivers::touch::gt911::kRegXResLo
X_OUTPUT_MAX (config block, little-endian).
constexpr uint8_tkleidos::drivers::touch::gt911::kCommandScreenOff
constexpr uint8_tkleidos::drivers::touch::gt911::kProductIdFamily
constexpr uint8_tkleidos::drivers::touch::gt911::kStatusBufferReady
Set when a fresh frame is ready.
constexpr uint8_tkleidos::drivers::touch::gt911::kStatusPointCountMask
Number of active contacts.
constexpr uint8_tkleidos::drivers::touch::gt911::kPointDataLength
X(2) + Y(2) + Size(2).
constexpr uint8_tkleidos::drivers::touch::gt911::kResolutionDataLength
X_MAX(2) + Y_MAX(2).
constexpr uint16_tkleidos::drivers::touch::gt911::kMaxResolution
Sanity bound for config values.
constexpr uint16_tkleidos::drivers::touch::gt911::kDefaultXMax
Native panel resolution fall-back when the config block cannot be read.
constexpr uint32_tkleidos::drivers::touch::gt911::kWakePulseMs
constexpr uint32_tkleidos::drivers::touch::gt911::kSleepIntLeadMs
constexpr uint32_tkleidos::drivers::touch::gt911::kSleepToWakeMinMs
constexpr uint32_tkleidos::drivers::touch::gt911::kWakeAnswerBudgetMs
constexpr uint32_tkleidos::drivers::touch::gt911::kWakeProbeIntervalMs
Gap between two probes while a woken controller is awaited.
constexpr size_tkleidos::drivers::touch::gt911::kAddressCount
Number of addresses a probe tries.

Function Documentation

createTouch() #

ITouch * kleidos::drivers::touch::createTouch(uint8_t address)

Probes the touch controller at address, returning a ready singleton driver for the detected chip, or nullptr if absent/unsupported. The instance lives in static storage; callers must not delete it.

The one family it knows is the FocalTech FT6x36. begin() is idempotent, so the caller may invoke createTouch() repeatedly to retry a controller that was not ready at boot.

Parameters
NameDirectionMeaning
addressinI2C address of the touch controller.
Returns
Pointer to the singleton driver, or nullptr.
See also
Ft6x36, Gt911

isControllerAddress() #

bool kleidos::drivers::touch::gt911::isControllerAddress(uint8_t address)
constexpr

Whether a remembered address is one this controller can answer at.

Parameters
NameDirectionMeaning
addressinA 7-bit address read back from memory that survives a reset, so it may hold anything.
Return values
ValueMeaning
true0x5D or 0x14.
falseAnything else.

isGt9xxProductId() #

bool kleidos::drivers::touch::gt911::isGt9xxProductId(const std::array< uint8_t, kProductIdLength > & id)
constexpr

Whether a product-id block read back is a GT9xx controller's.

Parameters
NameDirectionMeaning
idinThe block read at kRegProductId.
Return values
ValueMeaning
trueIt starts with kProductIdFamily.
falseIt does not (zeros, or another device at the address).

probeOrder() #

std::array< uint8_t, kAddressCount > kleidos::drivers::touch::gt911::probeOrder(uint8_t lastAnswered)
constexpr

The order to probe the two addresses in.

The address that answered last first, so a controller that keeps its address (every boot but a power-up of its supply) costs one transaction; the low address first when none has answered, as the vendor's library does.

Parameters
NameDirectionMeaning
lastAnsweredinThe address that answered last, or kNoAddress.
Returns
Both addresses, the one to try first at index 0.

Variable Documentation

kCommandScreenOff #

uint8_t kleidos::drivers::touch::gt911::kCommandScreenOff
constexpr

Command value that puts the controller into Sleep ("screen off"); the datasheet requires INT driven low before it is written.

kI2cAddressHigh #

uint8_t kleidos::drivers::touch::gt911::kI2cAddressHigh
constexpr

7-bit address 0x14 (0x28/0x29 on the wire): latched when INT is high as the controller leaves reset.

kI2cAddressLow #

uint8_t kleidos::drivers::touch::gt911::kI2cAddressLow
constexpr

7-bit address 0x5D (0xBA/0xBB on the wire): latched when INT is low as the controller leaves reset.

kProductIdFamily #

uint8_t kleidos::drivers::touch::gt911::kProductIdFamily
constexpr

First character of every product id of the GT9xx family ("911" here). A probe accepts an address only when the id it reads starts with it, so an acknowledge that returns no id is not taken for an awake controller.

kSleepIntLeadMs #

uint32_t kleidos::drivers::touch::gt911::kSleepIntLeadMs
constexpr

How long INT is held low before the screen-off command is written (the datasheet asks only for INT low first).

kSleepToWakeMinMs #

uint32_t kleidos::drivers::touch::gt911::kSleepToWakeMinMs
constexpr

Shortest gap between the screen-off command and a wake pulse (the datasheet asks for more than 58 ms).

kWakeAnswerBudgetMs #

uint32_t kleidos::drivers::touch::gt911::kWakeAnswerBudgetMs
constexpr

Longest a woken controller is given to answer its address: twice the datasheet's response time out of Sleep (under 200 ms), so a slow part is not given up on at the edge of its specification.

kWakePulseMs #

uint32_t kleidos::drivers::touch::gt911::kWakePulseMs
constexpr

How long INT is held high to wake the controller from Sleep: inside the datasheet's 2 to 5 ms window, away from both ends.