diff --git a/speedclock.ino b/speedclock.ino index 0a7638c..621efe1 100644 --- a/speedclock.ino +++ b/speedclock.ino @@ -287,14 +287,17 @@ void loop(void) { if(digitalRead(CANCELBUTTON_IN) == CANCELBUTTON_PRESSED){ timer_new_state = TIMER_CANCELLED; } - if((radio_data.topbuttonpressedtime - running_time_offset) > start_time){ - timer_new_state = TIMER_STOPPED; + Serial.println(radio_data.topbuttonpressedtime); + if(radio_data.topbuttonpressedtime > running_time_offset){ + if((radio_data.topbuttonpressedtime - running_time_offset) > start_time){ + run_time = (radio_data.topbuttonpressedtime - running_time_offset) - start_time; + runner_run_time = runner_start_time - run_time; + timer_new_state = TIMER_STOPPED; + } } break; case TIMER_STOPPED: //calculate the run_time and switch to WAIT - run_time = (radio_data.topbuttonpressedtime - running_time_offset) - start_time; - runner_run_time = runner_start_time - run_time; delay(10); if(digitalRead(CANCELBUTTON_IN) != CANCELBUTTON_PRESSED){ timer_new_state = TIMER_WAIT; @@ -429,9 +432,16 @@ void update_screen(timer_state_e state){ break; case TIMER_STOPPED: header = "Stopped!"; + curr_time_local = run_time/1000.000; + content = curr_time_local; + content += " sec"; + curr_time_local = (runner_start_time - start_time)/1000.000; + footer = "Reaction time: "; + footer += curr_time_local; + footer += " sec"; break; case TIMER_TIMEDOUT: - header = "Time out!"; + header = "Timed out!"; content = "Invalid!"; break; case TIMER_FAIL: