EXT-B now works without delay

This commit is contained in:
--global
2023-05-16 01:57:51 +03:00
parent 4ed28110c9
commit ca9c391811

View File

@ -11,13 +11,14 @@
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
#define MINBPM 20
#define SCREEN_TIMEOUT 30000 //Turn display off after 30 sec
#define SCREEN_TIMEOUT 120000 //Turn display off after 2 min
#define INPUT_PIN 2 //needs to be an interrupt pin
#define ENC_BTN_PIN 14
#define ENC_D1_PIN 17
#define ENC_D2_PIN 4
#define START_STOP_BTN_PIN 5
#define INPUT_PIN 2 //needs to be an interrupt pin
#define ANALOGUE_INPUT_1_PIN A2
#define ANALOGUE_INPUT_2_PIN A1
@ -145,7 +146,7 @@ void loop() {
display.clearDisplay();
display.display();
}
if (masterClockMode == 2) {
if (masterClockMode == 2 && tickCount > PULSE_LENGTH) {
calculateBPMTiming();
}
}
@ -177,7 +178,7 @@ void clock() {
//EXT-B
if (masterClockMode == 2) {
if (tickCount == pulsePeriod && pulseCount < (PPQN-1)) {
if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) {
tickCount = 0;
pulseCount++;
}
@ -220,8 +221,11 @@ void externalClock() {
if (!isPlaying) {
isPlaying = true;
}
pulseCount = 0;
if ((newExtPulseTime - lastExtPulseTime) > 3000) { //3000ms is 1/4 at 20bpm
resetClocks();
}
tickCount = 0;
pulseCount = 0;
}
}
@ -410,9 +414,12 @@ void checkInputs() {
}
//play button
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed && masterClockMode == 0) {
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed) {
if (masterClockMode == 0) {
calculateBPMTiming();
resetClocks();
isPlaying = !isPlaying;
}
playBtnPushed = true;
saveState();
updateScreen(); //to wake up the screen if turned off