From 66218a307c1a5a7dbd9d6333f1f51bb8233cb257 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Fri, 27 Oct 2023 11:35:59 +0300 Subject: [PATCH] MIDI in now works (code) --- Software/Gravity/Gravity.ino | 9 ++++++--- Software/Gravity/Interactions.ino | 9 ++++++++- Software/Gravity/UI.ino | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 2a840a0..2239e50 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -212,6 +212,9 @@ void setup() { void loop() { checkInputs(); + if (masterClockMode == 2) { + receiveMIDI(); + } } void sendMIDIClock() { @@ -227,10 +230,10 @@ void receiveMIDI() { if(Serial.available() > 0) { if (Serial.read() == 0xF8) { //Clock MIDIClockRecived = true; - } else if (Serial.read() == 0xFA || Serial.read() == 0xFB) { //start and continue + //} else if (Serial.read() == 0xFA || Serial.read() == 0xFB) { //start and continue isPlaying = true; - } else if (Serial.read() == 0xFC) { //stop - isPlaying = false; + //} else if (Serial.read() == 0xFC) { //stop + // isPlaying = false; } } } diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index 8aa9b2a..c602793 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -317,7 +317,14 @@ void checkInputs() { if (masterClockMode == 0) { calculateBPMTiming(); resetClocks(); - isPlaying = !isPlaying; + //isPlaying = !isPlaying; + if (!isPlaying) { + isPlaying = true; + sendMIDIStart(); + } else { + isPlaying = false; + sendMIDIStop(); + } } playBtnPushed = true; updateScreen(); //to wake up the screen if turned off diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index df01750..301929b 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -25,6 +25,8 @@ void updateScreen() { lastMenuItem = 3; } else if (masterClockMode == 1) { lastMenuItem = 1; + } else if (masterClockMode == 2) { + lastMenuItem = 1; } for (byte i = 1; i <= lastMenuItem; i++) {