Fix Phase 1 skeleton: add build system, fix compilation errors
- 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
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// components/hal/switch_stub.cpp
|
||||
#include "hal/switch_stub.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char* TAG = "switch_stub";
|
||||
|
||||
DefaultSwitchStub::DefaultSwitchStub() : initialized(false) {
|
||||
for (int i = 0; i < NUM_SWITCHES; i++) {
|
||||
switch_states[i].id = i;
|
||||
switch_states[i].gpio_pin = 0;
|
||||
switch_states[i].current_state = false;
|
||||
switch_states[i].previous_state = false;
|
||||
switch_states[i].last_change_time = 0;
|
||||
switch_states[i].debounce_time = 50;
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultSwitchStub::begin() {
|
||||
initialized = true;
|
||||
ESP_LOGI(TAG, "Switch stub initialized (GPIO pins not configured yet)");
|
||||
}
|
||||
|
||||
bool DefaultSwitchStub::is_pressed(uint8_t switch_id) {
|
||||
if (!initialized || switch_id >= NUM_SWITCHES) {
|
||||
return false;
|
||||
}
|
||||
return switch_states[switch_id].current_state;
|
||||
}
|
||||
|
||||
void DefaultSwitchStub::configure_switch(uint8_t switch_id, uint8_t gpio_pin) {
|
||||
if (switch_id >= NUM_SWITCHES) return;
|
||||
switch_states[switch_id].gpio_pin = gpio_pin;
|
||||
ESP_LOGI(TAG, "Switch %d configured to GPIO %d", switch_id, gpio_pin);
|
||||
}
|
||||
|
||||
void DefaultSwitchStub::set_debounce_time(uint32_t time_ms) {
|
||||
for (int i = 0; i < NUM_SWITCHES; i++) {
|
||||
switch_states[i].debounce_time = time_ms;
|
||||
}
|
||||
ESP_LOGI(TAG, "Debounce time set to %lu ms", time_ms);
|
||||
}
|
||||
Reference in New Issue
Block a user