- Added POGRAM CHANGES to switch Mode via MIDI

- Added Control Change to switch On/Off Pause Light
This commit is contained in:
2025-11-24 09:37:03 +01:00
parent 7b0c993e0b
commit 43f37e0b57
7 changed files with 159 additions and 44 deletions

View File

@@ -27,8 +27,6 @@
#define NOTE_COLOR_COUNT_RESET_THRESHOLD_TICKS (_EEPROM_Content.Channel_MIDI_Configuration[ch].Note_Reset_Timeout * (1000 / TIMER_INTERVALL_LED_UPDATE_ms))
// #define COUNT_APPLIED_NOTES
// ============================================================================================
// Datatypes
@@ -45,6 +43,9 @@ volatile Pause_Light_Timer_s _Pause_Light_Timer[NUM_LED_CHANNELS];
volatile int _NoteOn_Color_Counter[NUM_LED_CHANNELS][NUM_LED_COLORS];
volatile int _NoteOn_Color_Reset_Counter;
static bool _Mode_Change_Received[NUM_LED_CHANNELS];
static Mode _Mode_Change_New_Mode[NUM_LED_CHANNELS];
// 1 LED Channel, 3 LED Colors, 2 Event Types (Note On & Off)
int32_t _Event_Received_Counter[NUM_LED_CHANNELS][NUM_LED_COLORS][2];
@@ -120,6 +121,9 @@ void Core1_Light_Controller_Init(void)
_Event_Received_Counter[ch][col][MIDI_EVENT_NOTE_OFF - MIDI_EVENT_NOTE_OFF] = 0;
_Event_Received_Counter[ch][col][MIDI_EVENT_NOTE_ON - MIDI_EVENT_NOTE_OFF] = 0;
}
_Mode_Change_Received[ch] = false;
_Mode_Change_New_Mode[ch] = MIDI;
}
Core1_Light_Controller_Reset_NoteOn_Counter();
@@ -322,32 +326,68 @@ 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)
void Core1_Light_Controller_MIDI_Full_ProgramChange_Received(uint8_t midi_event, uint8_t midi_channel, uint8_t program_number)
{
Core1_Light_Controller_Pause_Light_Trigger(midi_event, midi_channel);
if(midi_event != MIDI_EVENT_PROGRAM_CHANGE) {
return;
}
for(uint32_t ch=0;ch<NUM_LED_CHANNELS;ch++)
{
if(Core1_Light_Controller_Check_Channel_Match(ch, midi_channel) != true) {
continue;
}
switch (program_number)
{
case MIDI:
case JAM:
case CONSTANT:
_Mode_Change_Received[ch] = true;
_Mode_Change_New_Mode[ch] = program_number;
break;
default:
break;
}
}
}
void Core1_Light_Controller_MIDI_Full_ControlChange_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(midi_event != MIDI_EVENT_CONTROL_CHANGE) {
return;
}
for(uint32_t 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;
switch(controller_number)
{
case MIDI_CC_GENERAL_PURPOSE_ONOFF_1:
_EEPROM_Content.Pause_Light_Configuration[ch].Enabled = (controller_value >= 64);
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;
if(!_EEPROM_Content.Pause_Light_Configuration[ch].Enabled)
{
_Pause_Light_Timer[ch].Timer = 0;
Core1_LED_Control_Set_Fade_Speed(ch, 0);
}
break;
case MIDI_CC_ALL_NOTES_OFF:
Core1_Light_Controller_Reset_NoteOn_Counter();
break;
default:
break;
}
}
default:
break;
}
}
}
@@ -355,12 +395,34 @@ void Core1_Light_Controller_Set_MIDI_To_Light_Enabled(bool enabled)
{
_MIDI_To_Light_Enabled = enabled;
for(uint ch=0;ch<NUM_LED_CHANNELS;ch++) {
for(uint32_t ch=0;ch<NUM_LED_CHANNELS;ch++) {
_Pause_Light_Timer[ch].Timer = 0;
_Pause_Light_Timer[ch].Is_Active = false;
}
}
bool Core1_Light_Controller_Get_Mode_Change_Received(enum LED_Channel channel)
{
if(channel >= NUM_LED_CHANNELS) {
return false;
}
bool Return_Value = _Mode_Change_Received[channel];
_Mode_Change_Received[channel] = false;
return Return_Value;
}
Mode Core1_Light_Controller_Get_Mode_Change_New_Mode(enum LED_Channel channel)
{
if(channel >= NUM_LED_CHANNELS) {
return MIDI;
}
return _Mode_Change_New_Mode[channel];
}
/*******************************************************************
Internal Functions
@@ -389,7 +451,7 @@ bool Core1_Light_Controller_Check_Octave_Match(enum LED_Channel channel, uint mi
void Core1_Light_Controller_Pause_Light_Trigger(uint8_t midi_event, uint8_t midi_channel)
{
for(uint ch=0;ch<NUM_LED_CHANNELS;ch++)
for(uint32_t ch=0;ch<NUM_LED_CHANNELS;ch++)
{
bool Match_Success = false;
@@ -443,16 +505,15 @@ void Core1_Light_Controller_Pause_Light_Trigger(uint8_t midi_event, uint8_t midi
void Core1_Light_Controller_Reset_NoteOn_Counter()
{
for(uint ch=0;ch<NUM_LED_CHANNELS;ch++)
for(uint32_t ch=0;ch<NUM_LED_CHANNELS;ch++)
{
for(uint l=0;l<NUM_LED_COLORS;l++)
{
if(_NoteOn_Color_Counter[ch][l] > 0) {
Core1_LED_Control_Set_DC_Direct(ch, l, 0);
}
_NoteOn_Color_Counter[ch][l] = 0;
}
if(_NoteOn_Color_Counter[ch][R] > 0) { Core1_LED_Control_Set_DC_Direct(ch, R, 0); }
if(_NoteOn_Color_Counter[ch][G] > 0) { Core1_LED_Control_Set_DC_Direct(ch, G, 0); }
if(_NoteOn_Color_Counter[ch][B] > 0) { Core1_LED_Control_Set_DC_Direct(ch, B, 0); }
_NoteOn_Color_Counter[ch][R] = 0;
_NoteOn_Color_Counter[ch][G] = 0;
_NoteOn_Color_Counter[ch][B] = 0;
}
}