Commit 15188591 authored by Sven Greiner's avatar Sven Greiner

Refactor event handling

Move common actions out of mode specific handler. Compiles into same
binary size. Removes redundant code, but does not allow the same
flexibility as before (different actions in each mode).
parent 2c51abbc
......@@ -367,53 +367,43 @@ int main(void) {
}
// Input handling
if (options.fixed_mode) {
switch (fast_presses) {
switch (fast_presses) {
#ifdef BATTCHECK
case FIXED_SIZE + 1:
state = kBattcheck;
break;
case FIXED_SIZE + 1:
state = kBattcheck;
break;
#endif // ifdef BATTCHECK
case 10:
state = kConfig;
break;
case 10:
state = kConfig;
break;
default:
default:
if (options.fixed_mode) {
output = (output % FIXED_SIZE) + 1;
state = kFixed;
save_output();
break;
}
} else {
switch (fast_presses) {
case 2:
state = kTurbo;
break;
#ifdef BATTCHECK
case FIXED_SIZE + 1:
state = kBattcheck;
break;
#endif // ifdef BATTCHECK
case 10:
state = kConfig;
break;
default:
switch (state) {
case kRamping:
state = kFrozen;
save_output();
} else {
switch (fast_presses) {
case 2:
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