Modified Tone and ISR

This commit is contained in:
Fenoglio 2018-07-07 19:11:52 +02:00
parent 0414b7d938
commit 5389049a1f
1 changed files with 6 additions and 4 deletions

View File

@ -401,16 +401,17 @@ void startSequence(void)
// first tone
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
delay(STARTSEQ_TONEPAUSE_MS);
delay(STARTSEQ_TONEPAUSE_MS + STARTSEQ_TON_1_2_LENGTH_MS);
}
//second tone
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
delay(STARTSEQ_TONEPAUSE_MS);
delay(STARTSEQ_TONEPAUSE_MS + STARTSEQ_TON_1_2_LENGTH_MS );
}
//third tone
if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_3_FREQUENCY,STARTSEQ_TON_3_LENGTH_MS );
delay(STARTSEQ_TON_3_LENGTH_MS);
}
}
@ -431,12 +432,13 @@ 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){
Serial.println("** Interrupt service routine set timer_new_state to TIMER_FAIL **");
timer_new_state = TIMER_FAIL;
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
noTone(PIEZO_PIN);
} else {
if(timer_state == TIMER_RUNNING | timer_new_state == TIMER_RUNNING ){
if(timer_state == TIMER_RUNNING){
// disable this interrupt;
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
}