Fixed some stopp issues

This commit is contained in:
Fenoglio 2018-07-08 01:57:34 +02:00
parent a49f0f7d52
commit c6cad0bd1d

View file

@ -287,14 +287,17 @@ void loop(void) {
if(digitalRead(CANCELBUTTON_IN) == CANCELBUTTON_PRESSED){
timer_new_state = TIMER_CANCELLED;
}
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: