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);
89 for (
auto &listener : this->listeners_)
90 listener->key_pressed(keycode);
97 ESP_LOGCONFIG(TAG,
"Matrix Keypad:");
98 ESP_LOGCONFIG(TAG,
" Rows:");
99 for (
auto &pin : this->
rows_) {
100 LOG_PIN(
" Pin: ", pin);
102 ESP_LOGCONFIG(TAG,
" Cols:");
104 LOG_PIN(
" Pin: ", pin);
void send_key_(uint8_t key)
uint32_t IRAM_ATTR HOT millis()
void dump_config() override
std::vector< GPIOPin * > columns_
std::vector< MatrixKeypadListener * > listeners_
Implementation of SPI Controller mode.
void register_listener(MatrixKeypadListener *listener)
std::vector< GPIOPin * > rows_