refactor debug events
parent
56de397afb
commit
fb540562b7
|
@ -53,6 +53,10 @@ SwitchEvent handleSwitch() {
|
|||
|
||||
bool shouldReleaseDebugSwitch = false;
|
||||
SwitchEvent handleDebugSwitch(char key) {
|
||||
if (auto event = handleSwitch()) {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (shouldReleaseDebugSwitch) {
|
||||
shouldReleaseDebugSwitch = false;
|
||||
return SWITCH_RELEASED;
|
||||
|
@ -102,6 +106,10 @@ EncoderEvent handleEncoder() {
|
|||
}
|
||||
|
||||
EncoderEvent handleDebugEncoder(char key) {
|
||||
if (auto event = handleEncoder()) {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (key == '[') {
|
||||
return ENCODER_COUNTER_CLOCKWISE;
|
||||
} else if (key == ']') {
|
||||
|
|
|
@ -131,6 +131,11 @@ uint8_t getPressedDigit(Key key) {
|
|||
}
|
||||
|
||||
Key handleDebugKeyboard(char key) {
|
||||
auto keyboardKey = handleKeyboard();
|
||||
if (keyboardKey != KEY_NONE) {
|
||||
return keyboardKey;
|
||||
}
|
||||
|
||||
if (!key) {
|
||||
return KEY_NONE;
|
||||
}
|
||||
|
|
|
@ -84,10 +84,7 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
auto key = handleKeyboard();
|
||||
if (key == KEY_NONE && debugKey) {
|
||||
key = handleDebugKeyboard(debugKey);
|
||||
}
|
||||
auto key = handleDebugKeyboard(debugKey);
|
||||
if (key != KEY_NONE) {
|
||||
Serial.print("Key pressed: ");
|
||||
Serial.print(allKeys[key]);
|
||||
|
@ -123,24 +120,14 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
auto switchEvent = handleSwitch();
|
||||
if (!switchEvent) {
|
||||
switchEvent = handleDebugSwitch(debugKey);
|
||||
}
|
||||
if (switchEvent) {
|
||||
if (auto switchEvent = handleDebugSwitch(debugKey)) {
|
||||
tick();
|
||||
Serial.println(switchEvent == SWITCH_PRESSED ? "Pressed" : "Released");
|
||||
}
|
||||
|
||||
auto encoderEvent = handleEncoder();
|
||||
if (!encoderEvent) {
|
||||
encoderEvent = handleDebugEncoder(debugKey);
|
||||
}
|
||||
if (encoderEvent) {
|
||||
if (auto encoderEvent = handleDebugEncoder(debugKey)) {
|
||||
tick();
|
||||
Serial.println(encoderEvent == ENCODER_CLOCKWISE ? "Clockwise" : "Counter-clockwise");
|
||||
setTimerCadence(getTimerCadence() + (encoderEvent == ENCODER_CLOCKWISE ? -1 : 1));
|
||||
Serial.println(OCR1A);
|
||||
Serial.println(TCNT1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue