- Added CC 123 Command to reset the NoteOn Counters
- Fixed Bug, where NoteOn Counters could be negative
This commit is contained in:
@@ -283,6 +283,9 @@ enum Idle_Screen
|
||||
#define MIDI_SYSTEM_ACTIVE_SENSING 0xE // Active Sensing (Keep Alive)
|
||||
#define MIDI_SYSTEM_RESET 0xF // Reset
|
||||
|
||||
// MIDI Control Changes
|
||||
#define MIDI_CC_ALL_NOTES_OFF 0x7B // [Channel Mode Message] All Notes Off
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Helping functions parsing MIDI Data //
|
||||
|
||||
@@ -268,7 +268,10 @@ void Core1_Light_Controller_MIDI_Full_Note_Received(uint8_t midi_event, uint8_t
|
||||
{
|
||||
if(midi_note_in_octave == NOTE_COLOR_RED || midi_note_in_octave == NOTE_COLOR_RED_ALT)
|
||||
{
|
||||
_NoteOn_Color_Counter[ch][R]--;
|
||||
if(_NoteOn_Color_Counter[ch][R] > 0) {
|
||||
_NoteOn_Color_Counter[ch][R]--;
|
||||
}
|
||||
|
||||
if(_NoteOn_Color_Counter[ch][R] == 0) { Core1_LED_Control_Set_DC_Direct(ch, R, 0); }
|
||||
|
||||
#ifdef COUNT_APPLIED_NOTES
|
||||
@@ -277,7 +280,10 @@ void Core1_Light_Controller_MIDI_Full_Note_Received(uint8_t midi_event, uint8_t
|
||||
}
|
||||
else if(midi_note_in_octave == NOTE_COLOR_GREEN || midi_note_in_octave == NOTE_COLOR_GREEN_ALT)
|
||||
{
|
||||
_NoteOn_Color_Counter[ch][G]--;
|
||||
if(_NoteOn_Color_Counter[ch][G] > 0) {
|
||||
_NoteOn_Color_Counter[ch][G]--;
|
||||
}
|
||||
|
||||
if(_NoteOn_Color_Counter[ch][G] == 0) { Core1_LED_Control_Set_DC_Direct(ch, G, 0); }
|
||||
|
||||
#ifdef COUNT_APPLIED_NOTES
|
||||
@@ -286,7 +292,10 @@ void Core1_Light_Controller_MIDI_Full_Note_Received(uint8_t midi_event, uint8_t
|
||||
}
|
||||
else if(midi_note_in_octave == NOTE_COLOR_BLUE || midi_note_in_octave == NOTE_COLOR_BLUE_ALT)
|
||||
{
|
||||
_NoteOn_Color_Counter[ch][B]--;
|
||||
if(_NoteOn_Color_Counter[ch][B] > 0) {
|
||||
_NoteOn_Color_Counter[ch][B]--;
|
||||
}
|
||||
|
||||
if(_NoteOn_Color_Counter[ch][B] == 0) { Core1_LED_Control_Set_DC_Direct(ch, B, 0); }
|
||||
|
||||
#ifdef COUNT_APPLIED_NOTES
|
||||
@@ -313,6 +322,35 @@ void Core1_Light_Controller_MIDI_Full_Note_Received(uint8_t midi_event, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
void Core1_Light_Controller_MIDI_Full_CC_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t controller_number, uint8_t controller_value)
|
||||
{
|
||||
Core1_Light_Controller_Pause_Light_Trigger(midi_event, midi_channel);
|
||||
|
||||
for(uint ch=0;ch<NUM_LED_CHANNELS;ch++)
|
||||
{
|
||||
if(Core1_Light_Controller_Check_Channel_Match(ch, midi_channel) != true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(midi_event == MIDI_EVENT_CONTROL_CHANGE) {
|
||||
switch(controller_number) {
|
||||
case MIDI_CC_ALL_NOTES_OFF:
|
||||
_NoteOn_Color_Counter[ch][R] = 0;
|
||||
_NoteOn_Color_Counter[ch][G] = 0;
|
||||
_NoteOn_Color_Counter[ch][B] = 0;
|
||||
|
||||
Core1_LED_Control_Set_DC_Direct(ch, R, 0);
|
||||
Core1_LED_Control_Set_DC_Direct(ch, G, 0);
|
||||
Core1_LED_Control_Set_DC_Direct(ch, B, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core1_Light_Controller_Set_MIDI_To_Light_Enabled(bool enabled)
|
||||
{
|
||||
_MIDI_To_Light_Enabled = enabled;
|
||||
|
||||
@@ -34,6 +34,7 @@ void Core1_Light_Controller_Tick(void);
|
||||
void Core1_Light_Controller_MIDI_OnOff_Event_Received(uint8_t midi_command_shifted_right, uint8_t midi_channel);
|
||||
void Core1_Light_Controller_MIDI_Other_Event_Received(uint8_t midi_data);
|
||||
void Core1_Light_Controller_MIDI_Full_Note_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t midi_note, uint8_t value);
|
||||
void Core1_Light_Controller_MIDI_Full_CC_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t controller_number, uint8_t controller_value);
|
||||
|
||||
void Core1_Light_Controller_Set_MIDI_To_Light_Enabled(bool enabled);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
enum PARSING_STATE_e
|
||||
{
|
||||
WAITING_FOR_COMMAND,
|
||||
WAITING_FOR_NOTE,
|
||||
WAITING_FOR_VALUE
|
||||
WAITING_FOR_DATA1,
|
||||
WAITING_FOR_DATA2
|
||||
};
|
||||
|
||||
struct PARSING_s
|
||||
@@ -33,7 +33,7 @@ struct PARSING_s
|
||||
enum PARSING_STATE_e State;
|
||||
uint8_t MIDI_Event;
|
||||
uint8_t MIDI_Channel;
|
||||
uint8_t MIDI_Note;
|
||||
uint8_t MIDI_Data1;
|
||||
};
|
||||
|
||||
volatile struct PARSING_s _Parsing;
|
||||
@@ -46,7 +46,7 @@ History_Buffer_t _MIDI_History_Buffer[RECEIVED_MIDI_HISTORY_BUFFER_SIZE];
|
||||
void Core1_MIDI_Receiver_Histroy_Update (uint8_t data);
|
||||
void Core1_MIDI_Receiver_Issue_Event_On_Off_Received(uint8_t midi_channel, uint8_t midi_event);
|
||||
void Core1_MIDI_Receiver_Issue_Data_Received (uint8_t midi_data);
|
||||
void Core1_MIDI_Receiver_Issue_Full_Note_Received (uint8_t midi_event, uint8_t midi_channel, uint8_t midi_note, uint8_t value);
|
||||
void Core1_MIDI_Receiver_Issue_Full_Event_Received (uint8_t midi_event, uint8_t midi_channel, uint8_t midi_data1, uint8_t midi_data2);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
@@ -70,7 +70,7 @@ void Core1_MIDI_Receiver_Init(void)
|
||||
_Parsing.State = WAITING_FOR_COMMAND;
|
||||
_Parsing.MIDI_Event = MIDI_EVENT_NOTE_ON;
|
||||
_Parsing.MIDI_Channel = MIDI_CHANNEL_1;
|
||||
_Parsing.MIDI_Note = NOTE_UNDEFINED;
|
||||
_Parsing.MIDI_Data1 = NOTE_UNDEFINED;
|
||||
}
|
||||
|
||||
void Core1_MIDI_Receiver_Process(void)
|
||||
@@ -87,7 +87,7 @@ void Core1_MIDI_Receiver_Process(void)
|
||||
{
|
||||
_Parsing.MIDI_Event = MIDI_EVENT_FROM_COMMAND(Data);
|
||||
_Parsing.MIDI_Channel = MIDI_CHANNEL_FROM_COMMAND(Data);
|
||||
_Parsing.State = WAITING_FOR_NOTE;
|
||||
_Parsing.State = WAITING_FOR_DATA1;
|
||||
|
||||
Core1_MIDI_Receiver_Issue_Event_On_Off_Received(_Parsing.MIDI_Channel, _Parsing.MIDI_Event);
|
||||
break;
|
||||
@@ -96,11 +96,11 @@ void Core1_MIDI_Receiver_Process(void)
|
||||
Core1_MIDI_Receiver_Issue_Data_Received(Data);
|
||||
break;
|
||||
|
||||
case WAITING_FOR_NOTE:
|
||||
case WAITING_FOR_DATA1:
|
||||
if(IS_MIDI_DATA(Data))
|
||||
{
|
||||
_Parsing.MIDI_Note = Data;
|
||||
_Parsing.State = WAITING_FOR_VALUE;
|
||||
_Parsing.MIDI_Data1 = Data;
|
||||
_Parsing.State = WAITING_FOR_DATA2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -110,10 +110,10 @@ void Core1_MIDI_Receiver_Process(void)
|
||||
}
|
||||
break;
|
||||
|
||||
case WAITING_FOR_VALUE:
|
||||
case WAITING_FOR_DATA2:
|
||||
if(IS_MIDI_DATA(Data))
|
||||
{
|
||||
Core1_MIDI_Receiver_Issue_Full_Note_Received(_Parsing.MIDI_Event, _Parsing.MIDI_Channel, _Parsing.MIDI_Note, Data);
|
||||
Core1_MIDI_Receiver_Issue_Full_Event_Received(_Parsing.MIDI_Event, _Parsing.MIDI_Channel, _Parsing.MIDI_Data1, Data);
|
||||
}
|
||||
|
||||
// Reset State Machine and wait for next MIDI Command
|
||||
@@ -151,7 +151,12 @@ void Core1_MIDI_Receiver_Issue_Data_Received(uint8_t midi_data)
|
||||
Core1_Light_Controller_MIDI_Other_Event_Received(midi_data);
|
||||
}
|
||||
|
||||
void Core1_MIDI_Receiver_Issue_Full_Note_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t midi_note, uint8_t value)
|
||||
void Core1_MIDI_Receiver_Issue_Full_Event_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t midi_data1, uint8_t midi_data2)
|
||||
{
|
||||
Core1_Light_Controller_MIDI_Full_Note_Received(midi_event, midi_channel, midi_note, value);
|
||||
if(midi_event == MIDI_EVENT_CONTROL_CHANGE) {
|
||||
Core1_Light_Controller_MIDI_Full_CC_Received(midi_event, midi_channel, midi_data1, midi_data2);
|
||||
}
|
||||
else {
|
||||
Core1_Light_Controller_MIDI_Full_Note_Received(midi_event, midi_channel, midi_data1, midi_data2);
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
840
|
||||
841
|
||||
|
||||
Reference in New Issue
Block a user