Typing without a host clock

This commit is contained in:
Dejvino 2023-04-06 07:59:00 +02:00
parent eadfe70f1d
commit c1144e6124

View File

@ -26,6 +26,7 @@ int test = 0;
volatile int counter = 0;
int numbits = 10;
volatile int typedKey = -1;
bool hostOnline = false;
// MODS >>>
// [1] send debug scancode information to serial port
@ -373,12 +374,13 @@ void onTimerInterrupt()
// --------------
// User Interface
// --------------
void updateOnlineLeds()
void updateOnlineStatus()
{
long timeNow = millis();
bool online = (lastChange > timeNow) || ((timeNow - lastChange) < 10000);
digitalWrite(pinLedOffline, online ? LOW : HIGH);
digitalWrite(pinLedOnline, online ? HIGH : LOW);
hostOnline = (lastChange > timeNow) || ((timeNow - lastChange) < 10000);
digitalWrite(pinLedOffline, hostOnline ? LOW : HIGH);
digitalWrite(pinLedOnline, hostOnline ? HIGH : LOW);
}
// ----
@ -422,7 +424,7 @@ void setup(void)
digitalWrite(pinLedOnline, LOW);
delay(500);
updateOnlineLeds();
updateOnlineStatus();
tone(pinSpeaker, 440, 200);
delay(200);
@ -458,8 +460,12 @@ void loop(void)
if (qwe % 5 == 0) delay(2000);
/**/
updateOnlineLeds();
if (typedKey != -1) {
updateOnlineStatus();
if (nextKeyReady && !hostOnline) { // skip sending key without a host (used for USB)
nextKeyReady = false;
typedKey = nextKey;
}
if (!nextKeyReady && typedKey != -1) {
tone(pinSpeaker, 200 + typedKey, 100);
typedKey = -1;
}