20#define PRINT_KEY_STATE(key) \
21 if (g_matrix_keyboard.Pressed(emakefun::MatrixKeyboard::kKey##key)) { \
22 Serial.println(F("key " #key " pressed")); \
23 } else if (g_matrix_keyboard.Pressing(emakefun::MatrixKeyboard::kKey##key)) { \
24 Serial.println(F("key " #key " pressing")); \
25 } else if (g_matrix_keyboard.Released(emakefun::MatrixKeyboard::kKey##key)) { \
26 Serial.println(F("key " #key " released")); \
31constexpr gpio_num_t kI2cPinSda = GPIO_NUM_21;
32constexpr gpio_num_t kI2cPinScl = GPIO_NUM_22;
43 Wire.begin(kI2cPinSda, kI2cPinScl);
48 const auto result = g_matrix_keyboard.Initialize();
51 Serial.println(F(
"matrix keyboard initialization successful"));
53 Serial.print(F(
"Error: matrix keyboard initialization failed: "));
54 Serial.println(
static_cast<uint32_t
>(result));
60 g_matrix_keyboard.Tick();
75 PRINT_KEY_STATE(Asterisk);
76 PRINT_KEY_STATE(NumberSign);
MatrixKeyboard是用于矩阵键盘模块的驱动类。
static constexpr uint8_t kDefaultI2cAddress
默认I2C地址。