From 07e291ec9da7c9bf93b9fb68a3a65bfa19697da7 Mon Sep 17 00:00:00 2001 From: midilab Date: Sat, 26 Jul 2025 07:43:37 -0300 Subject: [PATCH] adding SYNCING clock_state for external sync --- src/uClock.cpp | 7 ++++++- src/uClock.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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 };