diff --git a/src/meshberry/cardkb.cpp b/src/meshberry/cardkb.cpp index 8fc853c..dd57037 100644 --- a/src/meshberry/cardkb.cpp +++ b/src/meshberry/cardkb.cpp @@ -5,6 +5,8 @@ #include static TwoWire kbWire(1); // Use other I2C bus +static bool present = false; +static unsigned long lastRetry = 0; void cardkb_init() { esp_log_level_set("esp32-hal-i2c-ng", ESP_LOG_NONE); @@ -13,13 +15,11 @@ void cardkb_init() { pinMode(PIN_KB_SCL, INPUT_PULLUP); kbWire.begin(PIN_KB_SDA, PIN_KB_SCL); kbWire.setClock(CARDKB_I2C_HZ); + lastRetry = millis() - 10000; } char cardkb_read() { - static bool present = false; - static unsigned long lastRetry = 0; - - // test if the keyboard is connected, + // test if the keyboard is connected, // prevent endless logging of errors if (!present) { unsigned long now = millis(); @@ -33,7 +33,7 @@ char cardkb_read() { return 0; } present = true; - + char key = kbWire.available() ? (char)kbWire.read() : 0; - return key; + return key; }