Fix duplicate set_led_state, add set_led_brightness to interface
This commit is contained in:
@@ -9,6 +9,7 @@ public:
|
|||||||
virtual void begin() = 0;
|
virtual void begin() = 0;
|
||||||
virtual void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) = 0;
|
virtual void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) = 0;
|
||||||
virtual void clear_all() = 0;
|
virtual void clear_all() = 0;
|
||||||
|
virtual void set_led_brightness(uint8_t brightness) = 0;
|
||||||
|
|
||||||
virtual uint8_t note_to_index(uint8_t note) {
|
virtual uint8_t note_to_index(uint8_t note) {
|
||||||
return note;
|
return note;
|
||||||
@@ -36,6 +37,7 @@ public:
|
|||||||
void begin() override;
|
void begin() override;
|
||||||
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) override;
|
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) override;
|
||||||
void clear_all() override;
|
void clear_all() override;
|
||||||
|
void set_led_brightness(uint8_t brightness) override;
|
||||||
|
|
||||||
void set_mux(PixelStompMux* mux);
|
void set_mux(PixelStompMux* mux);
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-31
@@ -163,41 +163,17 @@ void DefaultLedStub::set_led_brightness(uint8_t brightness) {
|
|||||||
mux_ptr->show();
|
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() {
|
void DefaultLedStub::clear_all() {
|
||||||
|
if (!initialized || !mux_ptr) return;
|
||||||
|
|
||||||
for (int i = 0; i < NUM_LEDS; i++) {
|
for (int i = 0; i < NUM_LEDS; i++) {
|
||||||
led_states[i].active = false;
|
led_states[i].active = false;
|
||||||
led_states[i].velocity = 0;
|
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->show();
|
||||||
mux_ptr->clear_all();
|
|
||||||
}
|
|
||||||
Serial.println("[LED] All cleared");
|
Serial.println("[LED] All cleared");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user