diff --git a/firmware/Rhythm/Rhythm.ino b/firmware/Rhythm/Rhythm.ino index fd29dee..a6a028f 100644 --- a/firmware/Rhythm/Rhythm.ino +++ b/firmware/Rhythm/Rhythm.ino @@ -251,6 +251,23 @@ void ProcessSequencerTick(uint32_t tick) { } } +void HandleExtClockTick() { + switch (selected_source) { + case Clock::SOURCE_INTERNAL: + case Clock::SOURCE_EXTERNAL_MIDI: + // Use EXT as Reset when not used for clock source. + for (int i = 0; i < 6; i++) { + gravity.outputs[i].Low(); + } + gravity.clock.Reset(); + current_step = 0; + break; + default: + // Register EXT clock tick. + gravity.clock.Tick(); + } +} + void OnPlayPress() { if (!gravity.clock.IsPaused()) { gravity.clock.Stop(); @@ -604,6 +621,7 @@ void setup() { gravity.encoder.AttachPressRotateHandler(OnEncoderPressRotate); gravity.clock.AttachIntHandler(ProcessSequencerTick); + gravity.clock.AttachExtHandler(HandleExtClockTick); // Default to 120 BPM internal gravity.clock.SetTempo(120); gravity.clock.SetSource(Clock::SOURCE_INTERNAL);