diff --git a/master_clock.ino b/master_clock.ino index 2e43ef2..9eb1947 100644 --- a/master_clock.ino +++ b/master_clock.ino @@ -188,9 +188,9 @@ void checkRPot() { Serial.println(currentPos); if (currentPos > previousPos) { - BPM++; + handleBPMChange(1); } else { - BPM--; + handleBPMChange(0); } forceScreenUpdate = 1; @@ -202,6 +202,17 @@ void checkRPot() { } } +void handleBPMChange(byte increase) { + if (increase == 1) { + BPM++; + } else { + BPM--; + } + + period = (minute / BPM) / ppqn; + Timer1.setPeriod(period); +} + void updateEncoder() { // The ISR should be as short and fast as possible // Check the state of the DT pin to determine direction