From 14d1c497b32ac91bac7461415c65e5a83737365d Mon Sep 17 00:00:00 2001 From: Adam Wonak Date: Fri, 4 Jul 2025 10:54:16 -0700 Subject: [PATCH] Add clock reset behavior to EXT when internally clocked. --- clock.h | 5 +++++ examples/Gravity/Gravity.ino | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/clock.h b/clock.h index 5401d1a..8fa084e 100644 --- a/clock.h +++ b/clock.h @@ -145,6 +145,11 @@ class Clock { uClock.stop(); } + // Reset all clock counters to 0. + void Reset() { + uClock.resetCounters(); + } + // Returns true if the clock is not running. bool IsPaused() { return uClock.clock_state == uClock.PAUSED; diff --git a/examples/Gravity/Gravity.ino b/examples/Gravity/Gravity.ino index 7cc17d7..a7842b2 100644 --- a/examples/Gravity/Gravity.ino +++ b/examples/Gravity/Gravity.ino @@ -35,6 +35,14 @@ * BTN2: * Shift - hold and rotate encoder to change current selected output channel. * + * EXT: + * External clock input. When Gravity is set to INTERNAL clock mode, this + * input is used to reset clocks. + * + * CV1: + * CV2: + * External analog input used to provide modulation to any channel parameter. + * */ #include @@ -143,11 +151,14 @@ void HandleIntClockTick(uint32_t tick) { } void HandleExtClockTick() { - // Ignore tick if not using external source. - if (!gravity.clock.ExternalSource()) { - return; + if (gravity.clock.InternalSource()) { + // Use EXT as Reset when internally clocked. + ResetOutputs(); + gravity.clock.Reset(); + } else { + // Register clock tick. + gravity.clock.Tick(); } - gravity.clock.Tick(); app.refresh_screen = true; }