458cb5060f
- Add CMakeLists.txt for project and all components - Add idf_component.yml with TinyUSB dependency - Create switch_stub.cpp implementation - Fix app_task.h to match .cpp implementation (2-param signature) - Fix led_stub.h/cpp class naming (DefaultLedStub) - Fix midi_transport.cpp TinyUSB API usage (tud_midi_*) - Move main.cpp to main/ directory - Add sdkconfig.defaults for ESP32-S3
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
// components/hal/led_stub.cpp
|
|
#include "hal/led_stub.h"
|
|
#include "esp_log.h"
|
|
|
|
static const char* TAG = "led_stub";
|
|
|
|
DefaultLedStub::DefaultLedStub() : initialized(false) {
|
|
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;
|
|
}
|
|
}
|
|
|
|
void DefaultLedStub::begin() {
|
|
initialized = true;
|
|
ESP_LOGI(TAG, "LED stub initialized (GPIO pins not configured yet)");
|
|
}
|
|
|
|
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) {
|
|
if (!initialized) 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 = 0;
|
|
|
|
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 DefaultLedStub::clear_all() {
|
|
for (int i = 0; i < NUM_LEDS; i++) {
|
|
led_states[i].active = false;
|
|
led_states[i].velocity = 0;
|
|
}
|
|
ESP_LOGI(TAG, "All LEDs cleared");
|
|
}
|