diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index acde9ad..2b0096f 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -4,8 +4,9 @@ #include #include #include +#include -const char version[5] = "1.1b3"; +const char version[5] = "1.1b4"; #define SCREEN_ADDRESS 0x3C @@ -190,7 +191,8 @@ const uint8_t stkL[569] U8G2_FONT_SECTION("stk-l") = void setup() { - Serial.begin(31250); + NeoSerial.begin(31250); + NeoSerial.attachInterrupt(receiveMIDI); pinMode(ENC_BTN_PIN, INPUT_PULLUP); pinMode(START_STOP_BTN_PIN, INPUT_PULLUP); @@ -220,27 +222,26 @@ void setup() { } void loop() { - if (masterClockMode == 2) { - receiveMIDI(); - } else if (masterClockMode == 1 && extClockPPQN == 1) { + if (masterClockMode == 1 && extClockPPQN == 1) { calculateBPMTiming(); } checkInputs(); } void sendMIDIClock() { - Serial.write(0xF8); + NeoSerial.write(0xF8); } void sendMIDIStart() { - Serial.write(0xFA); + NeoSerial.write(0xFA); } void sendMIDIStop() { - Serial.write(0xFC); + NeoSerial.write(0xFC); } void receiveMIDI() { + if (masterClockMode == 2) { //if(Serial.available() > 0) { - int msg = Serial.read(); + int msg = NeoSerial.read(); if (msg == 0xF8) { //Clock MIDIClockReceived = true; } else if (msg == 0xFC) { //stop @@ -249,6 +250,7 @@ void receiveMIDI() { isPlaying = true; } //} + } }