summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2014-05-30 17:36:39 +0200
committerFlorian Jung <flo@windfisch.org>2014-06-19 23:51:36 +0200
commit8e526ebb68f90672fb9305537adbde89001326f2 (patch)
treec240779a7f509bea4120c2d8ebd07c827241ae6e
parentca673b5215d2262d92770fdfa763242efaae53af (diff)
don't break after an invalid input
-rw-r--r--main.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/main.c b/main.c
index 84adfef..826df0d 100644
--- a/main.c
+++ b/main.c
@@ -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: