From 9932baf93735f6650f10c4b2a7cc15e097c7f84e Mon Sep 17 00:00:00 2001 From: midilab Date: Wed, 4 May 2022 07:14:55 -0300 Subject: [PATCH] volatile tempo var and handling --- src/uClock.cpp | 11 +++++++---- src/uClock.h | 3 --- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uClock.cpp b/src/uClock.cpp index a22bc56..b4a8572 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -166,8 +166,8 @@ void uClockClass::pause() void uClockClass::setTimerTempo(float bpm) { // 96 ppqn resolution - tick_us_interval = (60000000 / 24 / bpm); - tick_hertz_interval = 1/((float)tick_us_interval/1000000); + uint32_t tick_us_interval = (60000000 / 24 / bpm); + float tick_hertz_interval = 1/((float)tick_us_interval/1000000); #if defined(ARDUINO_ARCH_AVR) uint32_t ocr; @@ -221,9 +221,12 @@ void uClockClass::setTempo(float bpm) return; } - setTimerTempo(bpm); + ATOMIC( + tempo = bpm + ) - tempo = bpm; + setTimerTempo(tempo); + } float inline uClockClass::freqToBpm(uint32_t freq) diff --git a/src/uClock.h b/src/uClock.h index 46c667d..59a56b8 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -84,9 +84,6 @@ class uClockClass { uint32_t last_interval; uint32_t sync_interval; - uint32_t tick_us_interval; - float tick_hertz_interval; - float tempo; uint32_t start_timer; uint8_t mode;