From 5af61d5ddc807304cf8693cf9da24bb63e749792 Mon Sep 17 00:00:00 2001 From: Nero Date: Sat, 15 Aug 2020 00:46:27 -0400 Subject: [PATCH] v0.0.13 updated Serial Monitor Reader and added fas func_id --- library.properties | 2 +- src/BMC-Version.h | 2 +- src/addon/BMC-Fas.h | 57 ++++++++++++++++++++++++--------- src/utility/BMC-SerialMonitor.h | 8 ++--- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/library.properties b/library.properties index e813627..6b93447 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=BMC -version=0.0.13 +version=0.0.14 author=Nero Rox maintainer=Nero Rox sentence=Badass MIDI Controller (BMC), a fully featured MIDI Controller with a Desktop Editor App. For 32-bit Teensy Only diff --git a/src/BMC-Version.h b/src/BMC-Version.h index 83e7616..57dac99 100644 --- a/src/BMC-Version.h +++ b/src/BMC-Version.h @@ -23,7 +23,7 @@ // BMC Version stored in EEPROM (for editor usage) #define BMC_VERSION_MAJ 0 #define BMC_VERSION_MIN 0 -#define BMC_VERSION_PATCH 13 +#define BMC_VERSION_PATCH 14 //16 bits unsigned, LSB byte is minor, MSB byte is major #define BMC_VERSION ((BMC_VERSION_MAJ<<8) | BMC_VERSION_MIN) diff --git a/src/addon/BMC-Fas.h b/src/addon/BMC-Fas.h index e7b2b4a..d2825b6 100644 --- a/src/addon/BMC-Fas.h +++ b/src/addon/BMC-Fas.h @@ -45,6 +45,7 @@ #define BMC_FAS_FUNC_ID_BLOCKS_DATA 0x0E #define BMC_FAS_FUNC_ID_TUNER_INFO 0x0D #define BMC_FAS_FUNC_ID_PRESET_NAME 0x0F +#define BMC_FAS_FUNC_ID_MFC_TAP 0x10 // unused #define BMC_FAS_FUNC_ID_BLOCK_XY 0x11 #define BMC_FAS_FUNC_ID_CPU 0x13 #define BMC_FAS_FUNC_ID_GET_PRESET_NUMBER 0x14 @@ -77,24 +78,46 @@ class BMCFas { void debugPrintFasMessageInfo(BMCMidiMessage& message){ char str[50]; switch(message.sysex[5]){ - case BMC_FAS_FUNC_ID_BLOCK_PARAM: strcpy(str, "\"BMC_FAS_FUNC_ID_BLOCK_PARAM\"");break; - case BMC_FAS_FUNC_ID_FIRMWARE: strcpy(str, "\"BMC_FAS_FUNC_ID_FIRMWARE\"");break; - case BMC_FAS_FUNC_ID_BLOCKS_DATA: strcpy(str, "\"BMC_FAS_FUNC_ID_BLOCKS_DATA\"");break; - case BMC_FAS_FUNC_ID_TUNER_INFO: strcpy(str, "\"BMC_FAS_FUNC_ID_TUNER_INFO\"");break; - case BMC_FAS_FUNC_ID_PRESET_NAME: strcpy(str, "\"BMC_FAS_FUNC_ID_PRESET_NAME\"");break; - case BMC_FAS_FUNC_ID_BLOCK_XY: strcpy(str, "\"BMC_FAS_FUNC_ID_BLOCK_XY\"");break; - case BMC_FAS_FUNC_ID_CPU: strcpy(str, "\"BMC_FAS_FUNC_ID_CPU\"");break; - case BMC_FAS_FUNC_ID_GET_PRESET_NUMBER: strcpy(str, "\"BMC_FAS_FUNC_ID_GET_PRESET_NUMBER\"");break; - case BMC_FAS_FUNC_ID_GET_MIDI_CHANNEL: strcpy(str, "\"BMC_FAS_FUNC_ID_GET_MIDI_CHANNEL\"");break; - case BMC_FAS_FUNC_ID_RESYNC: strcpy(str, "\"BMC_FAS_FUNC_ID_RESYNC\"");break; - case BMC_FAS_FUNC_ID_LOOPER: strcpy(str, "\"BMC_FAS_FUNC_ID_LOOPER\"");break; - case BMC_FAS_FUNC_ID_SCENE_NUMBER: strcpy(str, "\"BMC_FAS_FUNC_ID_SCENE_NUMBER\"");break; - case BMC_FAS_FUNC_ID_SET_PRESET_NUMBER: strcpy(str, "\"BMC_FAS_FUNC_ID_SET_PRESET_NUMBER\"");break; - case BMC_FAS_FUNC_ID_DISCONNECT: strcpy(str, "\"BMC_FAS_FUNC_ID_DISCONNECT\"");break; - case BMC_FAS_FUNC_ID_GENERAL_PURPOSE: strcpy(str, "\"BMC_FAS_FUNC_ID_GENERAL_PURPOSE\"");break; + case BMC_FAS_FUNC_ID_BLOCK_PARAM: strcpy(str, "BMC_FAS_FUNC_ID_BLOCK_PARAM");break; + case BMC_FAS_FUNC_ID_FIRMWARE: strcpy(str, "BMC_FAS_FUNC_ID_FIRMWARE");break; + case BMC_FAS_FUNC_ID_BLOCKS_DATA: strcpy(str, "BMC_FAS_FUNC_ID_BLOCKS_DATA");break; + case BMC_FAS_FUNC_ID_TUNER_INFO: strcpy(str, "BMC_FAS_FUNC_ID_TUNER_INFO");break; + case BMC_FAS_FUNC_ID_PRESET_NAME: strcpy(str, "BMC_FAS_FUNC_ID_PRESET_NAME");break; + case BMC_FAS_FUNC_ID_BLOCK_XY: strcpy(str, "BMC_FAS_FUNC_ID_BLOCK_XY");break; + case BMC_FAS_FUNC_ID_CPU: strcpy(str, "BMC_FAS_FUNC_ID_CPU");break; + case BMC_FAS_FUNC_ID_GET_PRESET_NUMBER: strcpy(str, "BMC_FAS_FUNC_ID_GET_PRESET_NUMBER");break; + case BMC_FAS_FUNC_ID_GET_MIDI_CHANNEL: strcpy(str, "BMC_FAS_FUNC_ID_GET_MIDI_CHANNEL");break; + case BMC_FAS_FUNC_ID_RESYNC: strcpy(str, "BMC_FAS_FUNC_ID_RESYNC");break; + case BMC_FAS_FUNC_ID_LOOPER: strcpy(str, "BMC_FAS_FUNC_ID_LOOPER");break; + case BMC_FAS_FUNC_ID_SCENE_NUMBER: strcpy(str, "BMC_FAS_FUNC_ID_SCENE_NUMBER");break; + case BMC_FAS_FUNC_ID_SET_PRESET_NUMBER: strcpy(str, "BMC_FAS_FUNC_ID_SET_PRESET_NUMBER");break; + case BMC_FAS_FUNC_ID_DISCONNECT: strcpy(str, "BMC_FAS_FUNC_ID_DISCONNECT");break; + case BMC_FAS_FUNC_ID_GENERAL_PURPOSE: strcpy(str, "BMC_FAS_FUNC_ID_GENERAL_PURPOSE");break; + default: strcpy(str, "UNUSED"); } BMC_PRINTLN("--> FAS MESSAGE RECEIVED, ID:", message.sysex[5], str, "SIZE:", message.size()); } + bool isValidFasFunction(uint8_t funcId){ + switch(funcId){ + case BMC_FAS_FUNC_ID_BLOCK_PARAM: + case BMC_FAS_FUNC_ID_FIRMWARE: + case BMC_FAS_FUNC_ID_BLOCKS_DATA: + case BMC_FAS_FUNC_ID_TUNER_INFO: + case BMC_FAS_FUNC_ID_PRESET_NAME: + case BMC_FAS_FUNC_ID_BLOCK_XY: + case BMC_FAS_FUNC_ID_CPU: + case BMC_FAS_FUNC_ID_GET_PRESET_NUMBER: + case BMC_FAS_FUNC_ID_GET_MIDI_CHANNEL: + case BMC_FAS_FUNC_ID_RESYNC: + case BMC_FAS_FUNC_ID_LOOPER: + case BMC_FAS_FUNC_ID_SCENE_NUMBER: + case BMC_FAS_FUNC_ID_SET_PRESET_NUMBER: + case BMC_FAS_FUNC_ID_DISCONNECT: + case BMC_FAS_FUNC_ID_GENERAL_PURPOSE: + return true; + } + return false; + } #endif public: @@ -394,6 +417,8 @@ class BMCFas { // messages that don't have a Checksum switch(message.sysex[5]){ + case BMC_FAS_FUNC_ID_MFC_TAP: + return true; case BMC_FAS_FUNC_ID_TUNER_INFO: receivedTunerInfo(message); return true; @@ -405,7 +430,7 @@ class BMCFas { return true; } // the rest require a valid CRC - if(!message.validateChecksum()){ + if(isValidFasFunction(message.sysex[5]) && !message.validateChecksum()){ BMC_PRINTLN("FAS Received Bad CRC?"); return false; } diff --git a/src/utility/BMC-SerialMonitor.h b/src/utility/BMC-SerialMonitor.h index dbf2f9d..facf838 100644 --- a/src/utility/BMC-SerialMonitor.h +++ b/src/utility/BMC-SerialMonitor.h @@ -14,8 +14,6 @@ #define BMC_SERIAL_MONITOR_FLAG_READY 0 - - class BMCSerialMonitor { public: BMCSerialMonitor(){ @@ -30,14 +28,16 @@ class BMCSerialMonitor { char receivedChar; while(Serial.available() > 0 && !readFlag(BMC_SERIAL_MONITOR_FLAG_READY)){ receivedChar = Serial.read(); - if(receivedChar != '\n') { + //if(receivedChar != '\n') { + if((uint8_t)receivedChar != 10) { buff[i] = receivedChar; i++; if(i >= BMC_SERIAL_MONITOR_MAX_CHARS){ i = BMC_SERIAL_MONITOR_MAX_CHARS-1; } } else { - buff[i] = '\0'; + //buff[i] = '\0'; + buff[i] = 0; i = 0; writeFlag(BMC_SERIAL_MONITOR_FLAG_READY, true); }