diff options
author | Florian Jung <flo@windfisch.org> | 2014-05-30 17:36:39 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2014-06-19 23:51:36 +0200 |
commit | 8e526ebb68f90672fb9305537adbde89001326f2 (patch) | |
tree | c240779a7f509bea4120c2d8ebd07c827241ae6e | |
parent | ca673b5215d2262d92770fdfa763242efaae53af (diff) |
don't break after an invalid input
-rw-r--r-- | main.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -244,8 +244,11 @@ int main() // also check if some time has elapsed since last button press if (state == STATE_WAIT && button_release_counter == 255) { - state = STATE_SEND_KEY; - key_to_send = n_pulses; + if (n_pulses >= 1 && n_pulses <=10) + { + state = STATE_SEND_KEY; + key_to_send = n_pulses; + } } button_release_counter = 0; // now button needs to be released a while until retrigger @@ -269,12 +272,9 @@ int main() switch (state) { case STATE_SEND_KEY: - if (key_to_send>=1 && key_to_send <=10) - { - buildReport(key_to_send); - state = STATE_RELEASE_KEY; // release next - PORTC &= ~LED_BLUE; - } + buildReport(key_to_send); + state = STATE_RELEASE_KEY; // release next + PORTC &= ~LED_BLUE; break; case STATE_RELEASE_KEY: |