5 namespace matrix_keypad {
7 static const char *
const TAG =
"matrix_keypad";
10 for (
auto *pin : this->
rows_) {
29 static uint32_t active_start = 0;
30 static int active_key = -1;
34 int pos = 0, row, col;
35 for (
auto *row : this->
rows_) {
56 if (key != active_key) {
57 if ((active_key != -1) && (this->
pressed_key_ == active_key)) {
60 ESP_LOGD(TAG,
"key @ row %d, col %d released", row, col);
62 listener->button_released(row, col);
63 if (!this->
keys_.empty()) {
65 ESP_LOGD(TAG,
"key '%c' released", keycode);
66 for (
auto &listener : this->listeners_)
67 listener->key_released(keycode);
83 ESP_LOGD(TAG,
"key @ row %d, col %d pressed", row, col);
85 listener->button_pressed(row, col);
86 if (!this->
keys_.empty()) {
87 uint8_t keycode = this->
keys_[key];
88 ESP_LOGD(TAG,
"key '%c' pressed", keycode);
90 trigger->trigger(keycode);
91 for (
auto &listener : this->listeners_)
92 listener->key_pressed(keycode);
99 ESP_LOGCONFIG(TAG,
"Matrix Keypad:");
100 ESP_LOGCONFIG(TAG,
" Rows:");
101 for (
auto &pin : this->
rows_) {
102 LOG_PIN(
" Pin: ", pin);
104 ESP_LOGCONFIG(TAG,
" Cols:");
106 LOG_PIN(
" Pin: ", pin);
void send_key_(uint8_t key)
std::vector< MatrixKeyTrigger * > key_triggers_
uint32_t IRAM_ATTR HOT millis()
void dump_config() override
std::vector< GPIOPin * > columns_
void register_key_trigger(MatrixKeyTrigger *trig)
std::vector< MatrixKeypadListener * > listeners_
Implementation of SPI Controller mode.
void register_listener(MatrixKeypadListener *listener)
std::vector< GPIOPin * > rows_