From 5dc12a7c1a8707474b6fda3515dee35f2acbdf9b Mon Sep 17 00:00:00 2001 From: doctea Date: Wed, 26 Mar 2025 00:12:12 +0000 Subject: [PATCH] enable to pause clock and then continue playing from where we left off --- src/uClock.cpp | 15 +++++++++++++-- src/uClock.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/uClock.cpp b/src/uClock.cpp index 9f27935..0fc802d 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -183,13 +183,24 @@ void uClockClass::stop() } } +void uClockClass::continue_playing() { + if (state == PAUSED) { + start_timer = millis(); + if (mode == INTERNAL_CLOCK) { + state = STARTED; + } else { + state = STARTING; + } + } +} + void uClockClass::pause() { if (mode == INTERNAL_CLOCK) { if (state == PAUSED) { - start(); + continue_playing(); } else { - stop(); + state = PAUSED; } } } diff --git a/src/uClock.h b/src/uClock.h index df1a08d..e7bfd49 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -127,6 +127,7 @@ class uClockClass { void start(); void stop(); void pause(); + void continue_playing(); void setTempo(float bpm); float getTempo();