Fix CC feedback: route to correct pixel by LED index
This commit is contained in:
+2
-1
@@ -112,7 +112,8 @@ void AppTask::process_midi_event(const MidiEvent& event) {
|
||||
led_driver->set_led_state(
|
||||
pad_mapping[led_index].midi_note,
|
||||
pad_mapping[led_index].midi_channel,
|
||||
cc_val
|
||||
cc_val,
|
||||
led_index
|
||||
);
|
||||
Serial.printf("[APP] CC -> LED: Ch%d CC%d Val%d -> LED%d\n",
|
||||
midi_channel, cc_num, cc_val, led_index);
|
||||
|
||||
+19
-1
@@ -200,9 +200,27 @@ void DefaultLedStub::begin() {
|
||||
Serial.println("[LED] Startup complete");
|
||||
}
|
||||
|
||||
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) {
|
||||
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity, int8_t led_index) {
|
||||
if (!initialized || !mux_ptr) return;
|
||||
|
||||
// Direct index mode (used by CC feedback)
|
||||
if (led_index >= 0 && led_index < NUM_LEDS) {
|
||||
led_states[led_index].active = (velocity > 0);
|
||||
led_states[led_index].note = note;
|
||||
led_states[led_index].channel = channel;
|
||||
led_states[led_index].velocity = velocity;
|
||||
led_states[led_index].timestamp = millis();
|
||||
uint32_t color = velocity_to_color(velocity);
|
||||
uint8_t r = (color >> 16) & 0xFF;
|
||||
uint8_t g = (color >> 8) & 0xFF;
|
||||
uint8_t b = color & 0xFF;
|
||||
mux_ptr->set_led_color(led_index, r, g, b);
|
||||
mux_ptr->show();
|
||||
Serial.printf("[LED] Set LED %d: note=%d ch=%d vel=%d\n", led_index, note, channel, velocity);
|
||||
return;
|
||||
}
|
||||
|
||||
// Note-match mode (used by NOTE_ON/OFF)
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
if (led_states[i].active && led_states[i].note == note) {
|
||||
led_states[i].channel = channel;
|
||||
|
||||
Reference in New Issue
Block a user