diff --git a/src/uClock.cpp b/src/uClock.cpp index 98f557d..70eb03a 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -304,10 +304,15 @@ void uClockClass::handleExternalClock() break; case STARTING: - clock_state = STARTED; + clock_state = SYNCING; ext_clock_us = micros(); break; + case SYNCING: + // set clock_mode as start and goes on to calculate the first ext_interval + clock_state = STARTED; + // no break here just go on to calculate our first ext_interval + case STARTED: uint32_t now_clock_us = micros(); last_interval = clock_diff(ext_clock_us, now_clock_us); diff --git a/src/uClock.h b/src/uClock.h index aa933c7..e9d4f31 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -66,6 +66,7 @@ class uClockClass { enum ClockState { PAUSED = 0, STARTING, + SYNCING, STARTED };