Files
loopy_midi_controller/components/hal/led_stub.cpp
T
2026-06-23 08:55:42 +00:00

62 lines
1.9 KiB
C++

// hal/led_stub.cpp
#include "hal/led_stub.h"
#include "esp_log.h"
static const char* TAG = "led_stub";
class DefaultLedStub : public LedStub {
private:
LedState led_states[10]; // Support up to 10 LEDs
bool initialized;
public:
DefaultLedStub() : initialized(false) {
// Initialize all LEDs to off state
for (int i = 0; i < 10; i++) {
led_states[i].active = false;
led_states[i].velocity = 0;
}
}
void begin() override {
// GPIO initialization would go here
// For Phase 1, this is a stub
initialized = true;
ESP_LOGI(TAG, "LED stub initialized (GPIO pins not configured yet)");
}
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) override {
if (!initialized) return;
// For Phase 1, we assume note 0-9 maps directly to LED 0-9
// This is configurable in the PadMapping
uint8_t led_index = note_to_index(note);
if (led_index < 10) {
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 = 0; // TODO: Add proper timestamp
ESP_LOGI(TAG, "LED STATE: Note %d -> LED %d Channel %d Velocity %d (%s)",
note, led_index, channel, velocity,
velocity > 0 ? "ON" : "OFF");
} else {
ESP_LOGW(TAG, "LED index out of range: %d (Note: %d)", led_index, note);
}
}
void clear_all() override {
for (int i = 0; i < 10; i++) {
led_states[i].active = false;
led_states[i].velocity = 0;
}
ESP_LOGI(TAG, "All LEDs cleared");
}
};
// Factory function to create the default LED stub
LedStub* create_led_stub() {
return new DefaultLedStub();
}