Commit be2111af authored by Sven Greiner's avatar Sven Greiner

Refactor event handling

Move common actions out of mode specific handler. Removes redundant
code, but might not provide the same level of flexibility as before and
might reduce readability.

Saves 2 bytes of flash.
parent bf1b84b5
......@@ -391,53 +391,45 @@ int main(void) {
}
// Input handling
if (options.fixed_mode) {
switch (fast_presses) {
switch (fast_presses) {
#ifdef BATTCHECK
case BATTCHECK_PRESSES:
state = kBattcheck;
break;
case BATTCHECK_PRESSES:
state = kBattcheck;
break;
#endif // ifdef BATTCHECK
case CONFIG_PRESSES:
state = kConfig;
break;
case CONFIG_PRESSES:
state = kConfig;
break;
default:
default:
if (options.fixed_mode) {
output = (output % FIXED_SIZE) + 1;
state = kFixed;
save_output();
break;
}
} else {
switch (fast_presses) {
case TURBO_PRESSES:
state = kTurbo;
break;
#ifdef BATTCHECK
case BATTCHECK_PRESSES:
state = kBattcheck;
break;
#endif // ifdef BATTCHECK
case CONFIG_PRESSES:
state = kConfig;
break;
default:
switch (state) {
case kRamping:
state = kFrozen;
save_output();
} else {
switch (fast_presses) {
case TURBO_PRESSES:
state = kTurbo;
break;
default:
state = kRamping;
switch (state) {
case kRamping:
state = kFrozen;
save_output();
break;
default:
state = kRamping;
break;
}
break;
}
break;
}
}
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment