Added ext MIDI start and stop handeling
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
const char version[5] = "v:1.b";
|
||||
const char version[5] = "v:1.1";
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
@ -105,10 +105,10 @@ int playingModes[6]; // should be renamed to currentSubdivs or something. Updat
|
||||
int playingModesOld[6];
|
||||
|
||||
unsigned int pulsePeriod;
|
||||
bool isPlaying = false;
|
||||
bool isPlaying;// = false;
|
||||
bool isRecording = false;
|
||||
bool recordToNextStep = false;
|
||||
bool MIDIClockRecived = false;
|
||||
bool MIDIClockReceived = false;
|
||||
|
||||
unsigned int tickCount = 0;
|
||||
unsigned int pulseCount = 0;
|
||||
@ -190,7 +190,6 @@ const uint8_t stkL[569] U8G2_FONT_SECTION("stk-l") =
|
||||
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(9600);
|
||||
Serial.begin(31250);
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
@ -221,12 +220,12 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkInputs();
|
||||
if (masterClockMode == 2) {
|
||||
receiveMIDI();
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
calculateBPMTiming();
|
||||
}
|
||||
}
|
||||
checkInputs();
|
||||
}
|
||||
|
||||
void sendMIDIClock() {
|
||||
@ -238,18 +237,21 @@ void sendMIDIStart() {
|
||||
void sendMIDIStop() {
|
||||
Serial.write(0xFC);
|
||||
}
|
||||
|
||||
void receiveMIDI() {
|
||||
if(Serial.available() > 0) {
|
||||
if (Serial.read() == 0xF8) { //Clock
|
||||
MIDIClockRecived = true;
|
||||
//} else if (Serial.read() == 0xFA || Serial.read() == 0xFB) { //start and continue
|
||||
//if(Serial.available() > 0) {
|
||||
int msg = Serial.read();
|
||||
if (msg == 0xF8) { //Clock
|
||||
MIDIClockReceived = true;
|
||||
} else if (msg == 0xFC) { //stop
|
||||
isPlaying = false;
|
||||
} else if (msg == 0xFA || msg == 0xFB) { //start and continue
|
||||
isPlaying = true;
|
||||
//} else if (Serial.read() == 0xFC) { //stop
|
||||
// isPlaying = false;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void clock() {
|
||||
if (isPlaying) {
|
||||
|
||||
@ -283,14 +285,14 @@ void clock() {
|
||||
}
|
||||
}
|
||||
|
||||
if (masterClockMode == 2 && MIDIClockRecived) { // MIDI should happen here (needs testing)
|
||||
if (masterClockMode == 2 && MIDIClockReceived) { // MIDI should happen here (needs testing)
|
||||
tickCount = 0; //to make things happen in the main clock function
|
||||
if (pulseCount < (PPQN - 1)) {
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
MIDIClockRecived = false;
|
||||
MIDIClockReceived = false;
|
||||
}
|
||||
|
||||
// pull low all outputs after set pulse length
|
||||
|
||||
@ -51,7 +51,7 @@ void checkInputs() {
|
||||
} else if (insideTab && displayScreen == 0) {
|
||||
menuItemSelected = !menuItemSelected;
|
||||
} else if (displayScreen == 1 && !isRecording) {
|
||||
isPlaying = 1;
|
||||
isPlaying = true;
|
||||
isRecording = 1;
|
||||
} else if (displayScreen == 1 && isRecording) {
|
||||
isRecording = 0;
|
||||
|
||||
Reference in New Issue
Block a user