From 5389049a1fd63c4e56e0c405887969db8b0c53a6 Mon Sep 17 00:00:00 2001 From: Fenoglio Date: Sat, 7 Jul 2018 19:11:52 +0200 Subject: [PATCH] Modified Tone and ISR --- speedclock.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/speedclock.ino b/speedclock.ino index 24b3856..c2a4b6d 100644 --- a/speedclock.ino +++ b/speedclock.ino @@ -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)); }