From f5b1dbf122a161d0e8aa9b0b550e4b3ec9ca6d25 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Sun, 4 Aug 2024 17:01:37 +0300 Subject: [PATCH] switched to 0.1ms internal clock resolution. this fixes higher than 193bpm glitch, but needs testing --- Software/Gravity/Gravity.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index f0c2642..74cbc96 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -6,12 +6,12 @@ #include #include -#define VERSION "V:1.1.1" +#define VERSION "V:1.1.1b" byte memCode = 'D'; //Change to different letter if you changed the data structure #define PPQN 24 -#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm) +#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms #define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave #define MINBPM 20 @@ -222,7 +222,7 @@ void setup() { resetClocks(); - FlexiTimer2::set(1, 1.0 / 1000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking + FlexiTimer2::set(1, 1.0 / 10000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking FlexiTimer2::start(); } @@ -524,7 +524,7 @@ void calculateBPMTiming() { } else if (bpmModulationRange != 0 && bpmModulationChannel == 1) { mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10); } - pulsePeriod = 60000 / ((bpm + mod) * PPQN); + pulsePeriod = 600000 / ((bpm + mod) * PPQN); } else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock (hardcoded) pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6;