fix keyboard startup delay
This commit is contained in:
parent
77702c0d05
commit
44f10676b3
|
|
@ -5,6 +5,8 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue