This commit is contained in:
CodeCrafter912 2018-07-07 23:14:13 +02:00
commit ad17222ced

View file

@ -250,26 +250,38 @@ void loop(void) {
//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;
}
break;
case TIMER_FAIL:
//fail start case ....
failSequence();
run_time = 99999;
runner_run_time = runner_start_time - start_time;
delay(10);
if(digitalRead(CANCELBUTTON_IN) != CANCELBUTTON_PRESSED){
timer_new_state = TIMER_WAIT;
}
break;
case TIMER_CANCELLED:
// what to do in chancel mode ?
run_time = 99999;
runner_run_time = runner_start_time - start_time;
delay(10);
if(digitalRead(CANCELBUTTON_IN) != CANCELBUTTON_PRESSED){
timer_new_state = TIMER_WAIT;
}
break;
case TIMER_TIMEDOUT:
// time out
run_time = millis() - start_time;
runner_run_time = runner_start_time - start_time;
delay(10);
if(digitalRead(CANCELBUTTON_IN) != CANCELBUTTON_PRESSED){
timer_new_state = TIMER_WAIT;
}
break;
case TIMER_WAIT:
// disable interrupt if not already done
@ -453,20 +465,24 @@ void startSequence(void)
Serial.print("Start time is: ");
Serial.println(start_time);
// this is sequence of usually three tones after a wait time 1sec , in between the tones there is also a delay of 1 sec. Each tone is 200ms seconds long, except the last
update_statemessage(timer_new_state);
if(timer_new_state == TIMER_RUNNING){
delay(STARTSEQ_STARTPAUSE_MS);
}
// first tone
update_statemessage(timer_new_state);
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
delay(STARTSEQ_TONEPAUSE_MS);
}
//second tone
update_statemessage(timer_new_state);
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
delay(STARTSEQ_TONEPAUSE_MS);
}
//third tone
update_statemessage(timer_new_state);
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_3_FREQUENCY,STARTSEQ_TON_3_LENGTH_MS );
delay(STARTSEQ_TON_3_LENGTH_MS);
@ -490,10 +506,12 @@ void false_start_isr(void)
// this will save the time when the runner is really started
Serial.println("** Interrupt service routine started: false_start_ISR **");
runner_start_time = millis();
if((timer_state == TIMER_STARTED) & (timer_new_state == TIMER_STARTED)){
if((timer_state == TIMER_STARTED) & (timer_new_state == TIMER_RUNNING)){
timer_new_state = TIMER_FAIL;
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
noTone(PIEZO_PIN);
Serial.println("** Interrupt service routine detected false_start. Set new state to TIMER_FAIL **");
update_statemessage(timer_new_state);
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
} else {
if((timer_state == TIMER_RUNNING) | (timer_new_state == TIMER_RUNNING) ){
// disable this interrupt;