Fix duplicate set_led_state, add set_led_brightness to interface
This commit is contained in:
+7
-31
@@ -163,41 +163,17 @@ void DefaultLedStub::set_led_brightness(uint8_t brightness) {
|
||||
mux_ptr->show();
|
||||
}
|
||||
|
||||
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) {
|
||||
if (!initialized || !mux_ptr) return;
|
||||
|
||||
uint8_t led_index = note_to_index(note);
|
||||
|
||||
if (led_index < NUM_LEDS) {
|
||||
led_states[led_index].note = note;
|
||||
led_states[led_index].channel = channel;
|
||||
led_states[led_index].velocity = velocity;
|
||||
led_states[led_index].active = (velocity > 0);
|
||||
led_states[led_index].timestamp = millis();
|
||||
|
||||
if (velocity > 0) {
|
||||
uint8_t brightness = map(velocity, 1, 127, 50, 255);
|
||||
mux_ptr->set_led_color(led_index, brightness, brightness, brightness);
|
||||
} else {
|
||||
mux_ptr->set_led_color(led_index, 0, 0, 0);
|
||||
}
|
||||
mux_ptr->show();
|
||||
|
||||
Serial.printf("[LED] Note %d -> LED %d Vel %d (%s)\n",
|
||||
note, led_index, velocity,
|
||||
velocity > 0 ? "ON" : "OFF");
|
||||
} else {
|
||||
Serial.printf("[LED] Out of range: %d (Note: %d)\n", led_index, note);
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultLedStub::clear_all() {
|
||||
if (!initialized || !mux_ptr) return;
|
||||
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
led_states[i].active = false;
|
||||
led_states[i].velocity = 0;
|
||||
led_states[i].note = 0;
|
||||
led_states[i].channel = 0;
|
||||
led_states[i].timestamp = 0;
|
||||
mux_ptr->set_led_color(i, 0, 0, 0);
|
||||
}
|
||||
if (mux_ptr) {
|
||||
mux_ptr->clear_all();
|
||||
}
|
||||
mux_ptr->show();
|
||||
Serial.println("[LED] All cleared");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user