Convert to PlatformIO/Arduino format

- Replace ESP-IDF structure with PlatformIO (platformio.ini)
- Move source files to src/ and include/
- Move libraries to lib/ directory
- Replace FreeRTOS with Arduino task/vTaskDelay
- Use Arduino MIDI library instead of raw TinyUSB
- Dual-core: MIDI on core 0, controller on core 1
This commit is contained in:
2026-06-23 12:55:12 +00:00
parent 458cb5060f
commit 9078001404
20 changed files with 341 additions and 355 deletions
+45
View File
@@ -0,0 +1,45 @@
#include "led_stub.h"
#include <Arduino.h>
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;
Serial.println("[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 = millis();
Serial.printf("[LED] Note %d -> LED %d Ch %d Vel %d (%s)\n",
note, led_index, channel, velocity,
velocity > 0 ? "ON" : "OFF");
} else {
Serial.printf("[LED] Index out of range: %d (Note: %d)\n", 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;
}
Serial.println("[LED] All LEDs cleared");
}
+38
View File
@@ -0,0 +1,38 @@
#include "switch_stub.h"
#include <Arduino.h>
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;
Serial.println("[SW] 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;
Serial.printf("[SW] Switch %d configured to GPIO %d\n", 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;
}
Serial.printf("[SW] Debounce time set to %lu ms\n", time_ms);
}