Permalink
Browse files

timeout

  • Loading branch information...
1 parent 1d75d8c commit 2da0fa9744ff5cc234fddccb9568cce932c2117b @sebseb7 committed May 15, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 firmware/apps/replicate.c
View
@@ -14,9 +14,14 @@ static uint8_t sub_step;
static char score[5] = { ' ', ' ', '0', '0', '0' };
+
+static uint8_t timeout = 0;
+
static uint8_t tick() {
uint8_t x, y;
+ timeout++;
+
switch(state) {
case INIT:
length = 1;
@@ -73,11 +78,20 @@ static uint8_t tick() {
}
}
++sub_step;
+ if(timeout == 150){
+ state = QUIT;
+ }
break;
case QUIT:
state = INIT;
return 1;
+ case LISTEN:
+ if(timeout == 200){
+ state = SCORE;
+ timeout = 0;
+ }
+ break;
default:
break;
@@ -87,6 +101,9 @@ static uint8_t tick() {
static void key(key_type key, event_type event) {
if(event != DOWN) return;
+
+ timeout=0;
+
if(state == SCORE) state = QUIT;
if(state != LISTEN) return;

0 comments on commit 2da0fa9

Please sign in to comment.