Fix CC feedback: route to correct pixel by LED index

This commit is contained in:
ash
2026-06-30 04:04:43 +00:00
parent 3dc9e445be
commit a4131adf2a
3 changed files with 23 additions and 4 deletions
+19 -1
View File
@@ -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;