Skip to content

Commit

Permalink
v0.0.13 updated Serial Monitor Reader and added fas func_id
Browse files Browse the repository at this point in the history
  • Loading branch information
neroroxxx committed Aug 15, 2020
1 parent 6453b80 commit 5af61d5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/BMC-Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
57 changes: 41 additions & 16 deletions src/addon/BMC-Fas.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/utility/BMC-SerialMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#define BMC_SERIAL_MONITOR_FLAG_READY 0



class BMCSerialMonitor {
public:
BMCSerialMonitor(){
Expand All @@ -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);
}
Expand Down

0 comments on commit 5af61d5

Please sign in to comment.