From dbae211294f1df2bf55d68aac4b366088b807887 Mon Sep 17 00:00:00 2001 From: Fenoglio Date: Sat, 7 Jul 2018 23:51:35 +0200 Subject: [PATCH] Removed delays from startsquence --- speedclock.h | 1 + speedclock.ino | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) 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 6a8886d..1c8d2c3 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); +} + +