In development. It changes without notice.
Topic
Keyboard Drivers
The M5Cardputer ADV's key-matrix controller and the LILYGO T-Deck's keyboard.
- Tca8418 scans the Cardputer ADV's matrix and queues each press and release by the key's number.
- LilygoKeyboard reads the T-Deck's keyboard, which is a microcontroller of its own: it gives characters, and takes the level of its light.
What a key means is decided in Input Sources & the Wake Rule.
- See also
- Input Sources & the Wake Rule
Files | |
| file | src/ |
| Chip-level keyboard-controller driver contract. | |
| file | src/ |
| Probe factory for the keyboard-controller driver. | |
| file | src/ |
| Pure decision helpers + shared constants for the kleidos:: | |
| file | src/ |
| Raw transport driver for the LILYGO T-Deck I2C keyboard controller. | |
| file | src/ |
| The LILYGO T-Deck keyboard controller's I2C commands, and the frames the driver sends them in. | |
| file | src/ |
| No-op keyboard controller for the boards without a physical keyboard. | |
| file | src/ |
| Driver for the NXP TCA8418 keypad-matrix controller. | |
| file | src/ |
| Register map for the NXP TCA8418 keypad/GPIO expander. | |
Classes | |
| class | kleidos:: |
| Chip-level keyboard-controller driver interface. More about kleidos:: | |
| class | kleidos:: |
| Raw I2C transport for the LILYGO T-Deck keyboard controller. More about kleidos:: | |
| class | kleidos:: |
| No-op keyboard controller used on the boards that have no keyboard. More about kleidos:: | |
| class | kleidos:: |
| NXP TCA8418 keypad-matrix controller (raw FIFO event transport). More about kleidos:: | |
Enumerations | |
| enum class | kleidos:: |
| Keyboard-controller family selected by an address probe. More about kleidos:: | |
Functions | |
| constexpr KeyboardFamily | kleidos:: |
| Classify a keyboard controller from its per-family probe results (pure). | |
| IKeyboardController * | kleidos:: |
| Resolve and return the fitted keyboard-controller driver. | |
| constexpr bool | kleidos:: |
| Whether a register write-readback proves the I2C WRITE path. | |
| constexpr bool | kleidos:: |
| Whether an event-FIFO count read is within the hardware's bounds. | |
| constexpr BacklightFrame | kleidos:: |
The write that sets the backlight to duty. | |
| constexpr KeyModeFrame | kleidos:: |
| The write that puts the controller in key mode. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| Upper bound of a plausible event-FIFO count for the sanity read (10-deep FIFO). | |
| constexpr uint8_t | kleidos:: |
| Sets the keyboard backlight's duty; one payload byte follows. | |
| constexpr uint8_t | kleidos:: |
| Sets the duty Alt+B lights the keys at; one payload byte. Never sent. | |
| constexpr uint8_t | kleidos:: |
| Raw mode: a read returns the key matrix. Never sent. | |
| constexpr uint8_t | kleidos:: |
| Key mode: a read returns the key the C3 latched (0 = none) and clears it. | |
| constexpr size_t | kleidos:: |
| Bytes in a backlight frame: the command and its duty, and nothing after them. | |
| constexpr size_t | kleidos:: |
| Bytes in a key-mode frame: the command alone. | |
| constexpr uint8_t | kleidos:: |
| Physical matrix wired to the expander. | |
| constexpr uint8_t | kleidos:: |
| Number of matrix columns wired up. | |
| constexpr uint8_t | kleidos:: |
| Upper bound on events drained per poll. | |
| constexpr uint8_t | kleidos:: |
| Configuration register. | |
| constexpr uint8_t | kleidos:: |
| Interrupt status register. | |
| constexpr uint8_t | kleidos:: |
| Key-lock and event-count register. | |
| constexpr uint8_t | kleidos:: |
| Key event FIFO (read-only). | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt status, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt status, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt status, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt enable, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt enable, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt enable, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| Keypad/GPIO select, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| Keypad/GPIO select, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| Keypad/GPIO select, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| GPI event mode, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPI event mode, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPI event mode, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| GPIO direction, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO direction, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO direction, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt level, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt level, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| GPIO interrupt level, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| Debounce disable, rows 0-7. | |
| constexpr uint8_t | kleidos:: |
| Debounce disable, cols 0-7. | |
| constexpr uint8_t | kleidos:: |
| Debounce disable, GPIO 8-9. | |
| constexpr uint8_t | kleidos:: |
| Config bit: enable GPIO interrupts. | |
| constexpr uint8_t | kleidos:: |
| Config bit: enable keypad interrupts. | |
| constexpr uint8_t | kleidos:: |
| Interrupt status mask: GPIO + key event. | |
| constexpr uint8_t | kleidos:: |
| Event-count field in 0x03 (low nibble). | |
| constexpr uint8_t | kleidos:: |
| Functional READ register (CFG). | |
| constexpr uint8_t | kleidos:: |
| Safe unused-bank R/W register. | |
| constexpr uint8_t | kleidos:: |
| Both writable COL8-9 debounce bits. | |
| constexpr uint8_t | kleidos:: |
| Writable field mask (COL8-9 only). | |
Enumeration Type Documentation
KeyboardFamily #
Function Documentation
backlightFrame() #
The write that sets the backlight to duty.
- Parameters
-
Name Direction Meaning duty in Duty, 0 (off) to 255 (full).
- Returns
- {0x01, duty}: the whole transaction, nothing after it.
classifyKeyboard() #
Classify a keyboard controller from its per-family probe results (pure).
The TCA8418 has no identity register, so each family is identified by whether its own probe (address ACK + a functional/
- Parameters
-
Name Direction Meaning tcaProbeOk in Whether the TCA8418 CFG-register probe succeeded. lilygoProbeOk in Whether the LILYGO address-ACK + benign read succeeded.
- Returns
- The detected KeyboardFamily, or KeyboardFamily::
None.
createKeyboardController() #
Resolve and return the fitted keyboard-controller driver.
Probes address on the internal I2C bus for the keyboard families compiled into this build, then returns the matching driver (constructed but not yet initialized — the caller runs IKeyboardController::
- Parameters
-
Name Direction Meaning address in 7-bit I2C address of the keyboard controller. intPin in Keyboard INT GPIO, or -1 if unused: the TCA8418's active-low interrupt, or the LILYGO C3's line, which its stock firmware never drives.
- Returns
- A driver owned by function-local
staticstorage (never delete, nevernullptr).
keyModeFrame() #
The write that puts the controller in key mode.
- Returns
- {0x04}: the whole transaction, sent on its own.
selfTestFifoCountPlausible() #
Whether an event-FIFO count read is within the hardware's bounds.
The TCA8418 key-lock/
- Parameters
-
Name Direction Meaning count in Event count from the key-lock/ event-count register (masked).
- Return values
-
Value Meaning true countis within [0, kSelfTestMaxFifoEvents].false countexceeds the physical FIFO depth (implausible).
selfTestWriteVerified() #
Whether a register write-readback proves the I2C WRITE path.
Compares only the writable field bits selected by mask; reserved bits (which read back as 0) are ignored, so a full-register mask of 0xFF collapses to exact equality.
- Parameters
-
Name Direction Meaning readback in Value read back after writing pattern.pattern in Test pattern written to the register. mask in Writable-field bitmask for the register.
- Return values
-
Value Meaning true The writable bits of readbackmatchpattern.false The write did not take effect on the writable bits.
Variable Documentation
kRows #
Physical matrix wired to the expander.
Number of matrix rows wired up.