Typing without a host clock
This commit is contained in:
parent
eadfe70f1d
commit
c1144e6124
@ -26,6 +26,7 @@ int test = 0;
|
|||||||
volatile int counter = 0;
|
volatile int counter = 0;
|
||||||
int numbits = 10;
|
int numbits = 10;
|
||||||
volatile int typedKey = -1;
|
volatile int typedKey = -1;
|
||||||
|
bool hostOnline = false;
|
||||||
|
|
||||||
// MODS >>>
|
// MODS >>>
|
||||||
// [1] send debug scancode information to serial port
|
// [1] send debug scancode information to serial port
|
||||||
@ -373,12 +374,13 @@ void onTimerInterrupt()
|
|||||||
// --------------
|
// --------------
|
||||||
// User Interface
|
// User Interface
|
||||||
// --------------
|
// --------------
|
||||||
void updateOnlineLeds()
|
void updateOnlineStatus()
|
||||||
{
|
{
|
||||||
long timeNow = millis();
|
long timeNow = millis();
|
||||||
bool online = (lastChange > timeNow) || ((timeNow - lastChange) < 10000);
|
hostOnline = (lastChange > timeNow) || ((timeNow - lastChange) < 10000);
|
||||||
digitalWrite(pinLedOffline, online ? LOW : HIGH);
|
|
||||||
digitalWrite(pinLedOnline, online ? HIGH : LOW);
|
digitalWrite(pinLedOffline, hostOnline ? LOW : HIGH);
|
||||||
|
digitalWrite(pinLedOnline, hostOnline ? HIGH : LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
@ -422,7 +424,7 @@ void setup(void)
|
|||||||
digitalWrite(pinLedOnline, LOW);
|
digitalWrite(pinLedOnline, LOW);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
updateOnlineLeds();
|
updateOnlineStatus();
|
||||||
tone(pinSpeaker, 440, 200);
|
tone(pinSpeaker, 440, 200);
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
@ -458,8 +460,12 @@ void loop(void)
|
|||||||
if (qwe % 5 == 0) delay(2000);
|
if (qwe % 5 == 0) delay(2000);
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
updateOnlineLeds();
|
updateOnlineStatus();
|
||||||
if (typedKey != -1) {
|
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);
|
tone(pinSpeaker, 200 + typedKey, 100);
|
||||||
typedKey = -1;
|
typedKey = -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user