12static constexpr uint8_t TCA8418_REG_CFG = 0x01;
13static constexpr uint8_t TCA8418_REG_INT_STAT = 0x02;
14static constexpr uint8_t TCA8418_REG_KEY_LCK_EC = 0x03;
15static constexpr uint8_t TCA8418_REG_KEY_EVENT_A = 0x04;
16static constexpr uint8_t TCA8418_REG_GPIO_INT_EN1 = 0x1A;
17static constexpr uint8_t TCA8418_REG_KP_GPIO1 = 0x1D;
18static constexpr uint8_t TCA8418_REG_GPI_EM1 = 0x20;
19static constexpr uint8_t TCA8418_REG_GPIO_PULL1 = 0x2C;
22static constexpr uint8_t TCA8418_CFG_KEY_INT_EN = 0x01;
23static constexpr uint8_t TCA8418_CFG_INT_CFG = 0x10;
25static constexpr uint8_t TCA8418_INT_STAT_ALL = 0x1F;
27static constexpr uint8_t TCA8418_EVENT_COUNT_MASK = 0x0F;
29static constexpr uint8_t TCA8418_KEY_PRESSED = 0x80;
30static constexpr uint8_t TCA8418_KEY_CODE_MASK = 0x7F;
32static constexpr uint8_t TCA8418_FIFO_DEPTH = 10;
43 void setup()
override;
56#ifdef TCA8418_LISTENER_COUNT
69 void dispatch_(uint8_t key,
bool pressed);
76#ifdef TCA8418_LISTENER_COUNT
Minimal static vector - saves memory by avoiding std::vector overhead.
This Class provides the methods to read/write bytes from/to an i2c device.
interface for components that provide keypresses
static void IRAM_ATTR interrupt_handler(TCA8418Component *arg)
Wakes the loop so queued events are read. Runs in interrupt context.
bool configure_pins_()
Write the matrix / individual-input pin configuration. Returns false on I2C failure.
void set_columns(uint8_t columns)
InternalGPIOPin * interrupt_pin_
StaticVector< TCA8418Listener *, TCA8418_LISTENER_COUNT > listeners_
bool drain_events_(bool dispatch)
Read every queued key event, dispatching them if asked, then clear the interrupt flags.
uint8_t key_char_(uint8_t key) const
The character mapped to a matrix key, or 0 when it has none.
void dispatch_(uint8_t key, bool pressed)
void register_listener(TCA8418Listener *listener)
void set_rows(uint8_t rows)
void set_gpi_events(bool gpi_events)
void set_interrupt_pin(InternalGPIOPin *pin)
void dump_config() override
void set_keys(const uint8_t *keys, uint8_t size)
virtual void key_pressed(uint8_t key)
Called with the key number reported by the device (1..80 matrix, 97..114 individual inputs).
virtual void key_released(uint8_t key)