diff --git a/speedclock.h b/speedclock.h index 6dc4539..b81740e 100644 --- a/speedclock.h +++ b/speedclock.h @@ -93,6 +93,7 @@ void set_state_LEDs(timer_state_e state, boolean warn); void startSequence(void); void update_statemessage(timer_state_e timer_state); void failSequence(void); +void wait(unsigned long ms); #endif diff --git a/speedclock.ino b/speedclock.ino index 35c42fe..56003ce 100644 --- a/speedclock.ino +++ b/speedclock.ino @@ -467,25 +467,25 @@ void startSequence(void) // 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); + wait(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); + wait(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); + wait(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); + wait(STARTSEQ_TON_3_LENGTH_MS); } } @@ -519,3 +519,13 @@ void false_start_isr(void) } } } + +void wait(unsigned long ms){ + unsigned long current = 0; + unsigned long started = millis(); + do{ + current = millis()-started; + }while(current < ms); +} + +