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,7 @@
|
|||||||
|
# Top-level CMake file for ESP-IDF project
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "components")
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(loopy_midi_controller)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "app_task.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES midi hal)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/queue.h>
|
#include <freertos/queue.h>
|
||||||
|
#include "midi/midi_transport.h"
|
||||||
#include "hal/led_stub.h"
|
#include "hal/led_stub.h"
|
||||||
#include "hal/switch_stub.h"
|
#include "hal/switch_stub.h"
|
||||||
|
|
||||||
@@ -17,6 +18,5 @@ struct AppTaskParams {
|
|||||||
BaseType_t app_task(void* parameters);
|
BaseType_t app_task(void* parameters);
|
||||||
|
|
||||||
// Application state management
|
// Application state management
|
||||||
void app_process_midi_event(const MidiEvent& event);
|
void app_process_midi_event(const MidiEvent& event, LedStub* led_driver);
|
||||||
void app_process_switch_event(uint8_t switch_id, bool pressed);
|
void app_process_switch_event(uint8_t switch_id, bool pressed);
|
||||||
void app_initialize_config();
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "led_stub.cpp" "switch_stub.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES )
|
||||||
+12
-26
@@ -1,43 +1,35 @@
|
|||||||
// hal/led_stub.cpp
|
// components/hal/led_stub.cpp
|
||||||
#include "hal/led_stub.h"
|
#include "hal/led_stub.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char* TAG = "led_stub";
|
static const char* TAG = "led_stub";
|
||||||
|
|
||||||
class DefaultLedStub : public LedStub {
|
DefaultLedStub::DefaultLedStub() : initialized(false) {
|
||||||
private:
|
for (int i = 0; i < NUM_LEDS; i++) {
|
||||||
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].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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin() override {
|
void DefaultLedStub::begin() {
|
||||||
// GPIO initialization would go here
|
|
||||||
// For Phase 1, this is a stub
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
ESP_LOGI(TAG, "LED stub initialized (GPIO pins not configured yet)");
|
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 {
|
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) {
|
||||||
if (!initialized) return;
|
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);
|
uint8_t led_index = note_to_index(note);
|
||||||
|
|
||||||
if (led_index < 10) {
|
if (led_index < NUM_LEDS) {
|
||||||
led_states[led_index].note = note;
|
led_states[led_index].note = note;
|
||||||
led_states[led_index].channel = channel;
|
led_states[led_index].channel = channel;
|
||||||
led_states[led_index].velocity = velocity;
|
led_states[led_index].velocity = velocity;
|
||||||
led_states[led_index].active = (velocity > 0);
|
led_states[led_index].active = (velocity > 0);
|
||||||
led_states[led_index].timestamp = 0; // TODO: Add proper timestamp
|
led_states[led_index].timestamp = 0;
|
||||||
|
|
||||||
ESP_LOGI(TAG, "LED STATE: Note %d -> LED %d Channel %d Velocity %d (%s)",
|
ESP_LOGI(TAG, "LED STATE: Note %d -> LED %d Channel %d Velocity %d (%s)",
|
||||||
note, led_index, channel, velocity,
|
note, led_index, channel, velocity,
|
||||||
@@ -47,16 +39,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_all() override {
|
void DefaultLedStub::clear_all() {
|
||||||
for (int i = 0; i < 10; 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;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "All LEDs cleared");
|
ESP_LOGI(TAG, "All LEDs cleared");
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Factory function to create the default LED stub
|
|
||||||
LedStub* create_led_stub() {
|
|
||||||
return new DefaultLedStub();
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// hal/led_stub.h
|
// components/hal/led_stub.h
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
class LedStub {
|
class LedStub {
|
||||||
public:
|
public:
|
||||||
virtual ~LedStub() {}
|
virtual ~LedStub() {}
|
||||||
@@ -11,8 +13,6 @@ public:
|
|||||||
|
|
||||||
// Helper function to map MIDI note to LED index
|
// Helper function to map MIDI note to LED index
|
||||||
virtual uint8_t note_to_index(uint8_t note) {
|
virtual uint8_t note_to_index(uint8_t note) {
|
||||||
// Default implementation - direct mapping
|
|
||||||
// Can be overridden by specific implementations
|
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -25,3 +25,17 @@ struct LedState {
|
|||||||
uint32_t timestamp; // When state was set
|
uint32_t timestamp; // When state was set
|
||||||
bool active; // Current on/off state
|
bool active; // Current on/off state
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Default stub implementation
|
||||||
|
class DefaultLedStub : public LedStub {
|
||||||
|
private:
|
||||||
|
static const uint8_t NUM_LEDS = 10;
|
||||||
|
LedState led_states[NUM_LEDS];
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DefaultLedStub();
|
||||||
|
void begin() override;
|
||||||
|
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) override;
|
||||||
|
void clear_all() override;
|
||||||
|
};
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// hal/switch_stub.h
|
// components/hal/switch_stub.h
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
class SwitchStub {
|
class SwitchStub {
|
||||||
public:
|
public:
|
||||||
virtual ~SwitchStub() {}
|
virtual ~SwitchStub() {}
|
||||||
@@ -22,3 +24,18 @@ struct SwitchState {
|
|||||||
uint32_t last_change_time; // Timestamp of last state change
|
uint32_t last_change_time; // Timestamp of last state change
|
||||||
uint32_t debounce_time; // Debounce time in ms
|
uint32_t debounce_time; // Debounce time in ms
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Default stub implementation
|
||||||
|
class DefaultSwitchStub : public SwitchStub {
|
||||||
|
private:
|
||||||
|
static const uint8_t NUM_SWITCHES = 10;
|
||||||
|
SwitchState switch_states[NUM_SWITCHES];
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DefaultSwitchStub();
|
||||||
|
void begin() override;
|
||||||
|
bool is_pressed(uint8_t switch_id) override;
|
||||||
|
void configure_switch(uint8_t switch_id, uint8_t gpio_pin) override;
|
||||||
|
void set_debounce_time(uint32_t time_ms) override;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "midi_transport.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES driver)
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
// midi/midi_transport.cpp
|
// components/midi/midi_transport.cpp
|
||||||
#include "midi/midi_transport.h"
|
#include "midi/midi_transport.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
#include "class/midi/midi.h"
|
|
||||||
|
|
||||||
static const char* TAG = "midi_transport";
|
static const char* TAG = "midi_transport";
|
||||||
|
|
||||||
@@ -23,15 +22,9 @@ bool UsbMidiTransport::begin() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize TinyUSB MIDI
|
// Initialize TinyUSB
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
// Configure USB device descriptors
|
|
||||||
tusb_device_set_string(1, "Loopy Foot Controller");
|
|
||||||
|
|
||||||
// Register MIDI callback
|
|
||||||
tuh_midi_set_cb(usb_midi_callback);
|
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
ESP_LOGI(TAG, "USB MIDI transport initialized");
|
ESP_LOGI(TAG, "USB MIDI transport initialized");
|
||||||
return true;
|
return true;
|
||||||
@@ -40,82 +33,95 @@ bool UsbMidiTransport::begin() {
|
|||||||
void UsbMidiTransport::task() {
|
void UsbMidiTransport::task() {
|
||||||
if (!initialized) return;
|
if (!initialized) return;
|
||||||
|
|
||||||
// Process USB MIDI events
|
// TinyUSB device task handling
|
||||||
while (tuh_uart_read_available()) {
|
tuh_task();
|
||||||
uint8_t buffer[128];
|
|
||||||
uint32_t bytes_read = tuh_midi_read_packet(buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
if (bytes_read > 0) {
|
// Check for MIDI data on the USB host interface
|
||||||
|
uint8_t cable_num;
|
||||||
|
uint8_t midi_packet[4];
|
||||||
|
|
||||||
|
while (tud_midi_available()) {
|
||||||
|
if (tud_midi_packet_read(midi_packet)) {
|
||||||
MidiEvent event;
|
MidiEvent event;
|
||||||
parse_midi_packet(buffer, bytes_read, event);
|
parse_midi_packet(midi_packet, 4, event);
|
||||||
|
|
||||||
// Log incoming event
|
|
||||||
log_incoming("USB", event);
|
log_incoming("USB", event);
|
||||||
|
|
||||||
// Send to event queue
|
if (xQueueSend(event_queue, &event, 0) != pdPASS) {
|
||||||
if (xQueueSend(event_queue, &event, portMAX_DELAY) != pdPASS) {
|
ESP_LOGW(TAG, "Failed to queue MIDI event (queue full)");
|
||||||
ESP_LOGW(TAG, "Failed to queue MIDI event");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_midi_callback(const uint8_t* event, uint32_t size) {
|
|
||||||
// This callback is called by TinyUSB when MIDI data is received
|
|
||||||
// For now, we'll implement a simple version
|
|
||||||
// In a full implementation, this would parse the MIDI packet
|
|
||||||
|
|
||||||
MidiEvent midi_event;
|
|
||||||
// TODO: Implement actual MIDI parsing based on event type
|
|
||||||
// For Phase 1, we'll handle basic Note On/Off messages
|
|
||||||
}
|
|
||||||
|
|
||||||
void UsbMidiTransport::log_incoming(const char* source, const MidiEvent& event) {
|
void UsbMidiTransport::log_incoming(const char* source, const MidiEvent& event) {
|
||||||
const char* type_str;
|
const char* type_str;
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case MidiEvent::NOTE_ON: type_str = "NOTE_ON"; break;
|
case MidiEvent::NOTE_ON: type_str = "NOTE_ON"; break;
|
||||||
case MidiEvent::NOTE_OFF: type_str = "NOTE_OFF"; break;
|
case MidiEvent::NOTE_OFF: type_str = "NOTE_OFF"; break;
|
||||||
case MidiEvent::CONTROL_CHANGE: type_str = "CONTROL_CHANGE"; break;
|
case MidiEvent::CONTROL_CHANGE: type_str = "CC"; break;
|
||||||
|
case MidiEvent::PROGRAM_CHANGE: type_str = "PC"; break;
|
||||||
|
case MidiEvent::PITCH_BEND: type_str = "PITCH_BEND"; break;
|
||||||
default: type_str = "UNKNOWN"; break;
|
default: type_str = "UNKNOWN"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "MIDI IN: %s Channel: %d Type: %s Note: %d Velocity: %d",
|
ESP_LOGI(TAG, "MIDI IN: %s Ch:%d %s:%d:%d",
|
||||||
source, event.channel, type_str, event.data1, event.data2);
|
source, event.channel, type_str, event.data1, event.data2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsbMidiTransport::parse_midi_packet(const uint8_t* buffer, uint32_t size, MidiEvent& event) {
|
void UsbMidiTransport::parse_midi_packet(const uint8_t* buffer, uint32_t size, MidiEvent& event) {
|
||||||
// Simple MIDI parser for basic messages
|
if (size < 4) return;
|
||||||
// This is a simplified version for Phase 1
|
|
||||||
|
|
||||||
if (size < 2) return;
|
// USB MIDI packet format: [cable_num | CIN], [status], [data1], [data2]
|
||||||
|
uint8_t cin = buffer[0] & 0x0F;
|
||||||
|
uint8_t status = buffer[1];
|
||||||
|
uint8_t type = status & 0xF0;
|
||||||
|
uint8_t channel = (status & 0x0F) + 1; // Convert to 1-16 range
|
||||||
|
|
||||||
uint8_t status = buffer[0];
|
event.channel = channel;
|
||||||
uint8_t type = status & 0xF0; // Message type
|
event.data1 = buffer[2];
|
||||||
uint8_t channel = status & 0x0F; // Channel (0-15, but MIDI uses 1-16)
|
event.data2 = buffer[3];
|
||||||
|
|
||||||
event.channel = channel + 1; // Convert to 1-16 range
|
switch (cin) {
|
||||||
|
case 0x8: // Note Off
|
||||||
switch (type) {
|
|
||||||
case 0x90: // Note On
|
|
||||||
event.type = MidiEvent::NOTE_ON;
|
|
||||||
event.data1 = buffer[1];
|
|
||||||
event.data2 = buffer[2];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x80: // Note Off
|
|
||||||
event.type = MidiEvent::NOTE_OFF;
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
event.data1 = buffer[1];
|
|
||||||
event.data2 = buffer[2];
|
|
||||||
break;
|
break;
|
||||||
|
case 0x9: // Note On
|
||||||
case 0xB0: // Control Change
|
event.type = MidiEvent::NOTE_ON;
|
||||||
|
if (event.data2 == 0) {
|
||||||
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0xB: // Control Change
|
||||||
event.type = MidiEvent::CONTROL_CHANGE;
|
event.type = MidiEvent::CONTROL_CHANGE;
|
||||||
event.data1 = buffer[1];
|
|
||||||
event.data2 = buffer[2];
|
|
||||||
break;
|
break;
|
||||||
|
case 0xC: // Program Change
|
||||||
|
event.type = MidiEvent::PROGRAM_CHANGE;
|
||||||
|
break;
|
||||||
|
case 0xE: // Pitch Bend
|
||||||
|
event.type = MidiEvent::PITCH_BEND;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Unknown message type - ignore for now
|
// Try to infer from status byte
|
||||||
return;
|
switch (type) {
|
||||||
|
case 0x80: event.type = MidiEvent::NOTE_OFF; break;
|
||||||
|
case 0x90: event.type = MidiEvent::NOTE_ON; break;
|
||||||
|
case 0xB0: event.type = MidiEvent::CONTROL_CHANGE; break;
|
||||||
|
case 0xC0: event.type = MidiEvent::PROGRAM_CHANGE; break;
|
||||||
|
case 0xE0: event.type = MidiEvent::PITCH_BEND; break;
|
||||||
|
default: event.type = MidiEvent::NOTE_ON; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_midi_task(void* pvParameters) {
|
||||||
|
UsbMidiTransport* transport = static_cast<UsbMidiTransport*>(pvParameters);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "USB MIDI task started");
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
transport->task();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// midi/midi_transport.h
|
// components/midi/midi_transport.h
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -40,7 +40,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
QueueHandle_t event_queue;
|
QueueHandle_t event_queue;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
|
// MIDI packet parsing
|
||||||
|
void parse_midi_packet(const uint8_t* buffer, uint32_t size, MidiEvent& event);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Forward declaration for USB callback
|
// Task function for USB MIDI processing
|
||||||
void usb_midi_callback(const uint8_t* event, uint32_t size);
|
void usb_midi_task(void* pvParameters);
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
// main.cpp - Entry point for ESP32-S3 FreeRTOS application
|
|
||||||
// Phase 1: USB MIDI + Basic Event Processing
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
#include "freertos/task.h"
|
|
||||||
#include "esp_system.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
|
|
||||||
// Component includes
|
|
||||||
#include "midi/midi_transport.h"
|
|
||||||
#include "controller/app_task.h"
|
|
||||||
#include "hal/led_stub.h"
|
|
||||||
#include "hal/switch_stub.h"
|
|
||||||
|
|
||||||
// Logging tag
|
|
||||||
static const char *TAG = "loopy_midi_controller";
|
|
||||||
|
|
||||||
// FreeRTOS task handles
|
|
||||||
static TaskHandle_t usb_midi_task_handle = NULL;
|
|
||||||
static TaskHandle_t controller_task_handle = NULL;
|
|
||||||
|
|
||||||
extern "C" void app_main(void) {
|
|
||||||
ESP_LOGI(TAG, "Starting Loopy MIDI Controller (Phase 1)");
|
|
||||||
ESP_LOGI(TAG, "Device name: Loopy Foot Controller");
|
|
||||||
|
|
||||||
// Initialize hardware stubs (Phase 1 - no real hardware yet)
|
|
||||||
LedStub led_driver;
|
|
||||||
SwitchStub switch_driver;
|
|
||||||
|
|
||||||
led_driver.begin();
|
|
||||||
switch_driver.begin();
|
|
||||||
|
|
||||||
// Initialize MIDI transport (USB)
|
|
||||||
UsbMidiTransport midi_transport;
|
|
||||||
midi_transport.begin();
|
|
||||||
|
|
||||||
// Create USB MIDI task (High priority)
|
|
||||||
BaseType_t usb_midi_result = xTaskCreate(
|
|
||||||
usb_midi_task,
|
|
||||||
"usb_midi_task",
|
|
||||||
4096,
|
|
||||||
(void*)&midi_transport,
|
|
||||||
tskIDLE_PRIORITY + 3,
|
|
||||||
&usb_midi_task_handle
|
|
||||||
);
|
|
||||||
|
|
||||||
if (usb_midi_result != pdPASS) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create USB MIDI task");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Controller task (Lower priority)
|
|
||||||
AppTaskParams app_params;
|
|
||||||
app_params.led_driver = &led_driver;
|
|
||||||
app_params.switch_driver = &switch_driver;
|
|
||||||
app_params.midi_queue = midi_transport.get_event_queue();
|
|
||||||
|
|
||||||
BaseType_t controller_result = xTaskCreate(
|
|
||||||
app_task,
|
|
||||||
"controller_task",
|
|
||||||
4096,
|
|
||||||
(void*)&app_params,
|
|
||||||
tskIDLE_PRIORITY + 1,
|
|
||||||
&controller_task_handle
|
|
||||||
);
|
|
||||||
|
|
||||||
if (controller_result != pdPASS) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create Controller task");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Loopy MIDI Controller initialized successfully");
|
|
||||||
ESP_LOGI(TAG, "Phase 1 complete: USB MIDI device ready");
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "../main.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES controller midi hal)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
## IDF Component Manager Manifest File
|
||||||
|
dependencies:
|
||||||
|
idf:
|
||||||
|
version: ">=5.0.0"
|
||||||
|
espressif/esp_tinyusb:
|
||||||
|
version: ">=1.0.0"
|
||||||
|
rules:
|
||||||
|
- if: "target == esp32s3"
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# ESP32-S3 Configuration
|
||||||
|
CONFIG_IDF_TARGET="esp32s3"
|
||||||
|
|
||||||
|
# USB Configuration
|
||||||
|
CONFIG_TINYUSB_DESC_MANUFACTURER_STRING="Ashley Strahle"
|
||||||
|
CONFIG_TINYUSB_DESC_PRODUCT_STRING="Loopy Foot Controller"
|
||||||
|
CONFIG_TINYUSB_DESC_CDC_STRING="Loopy Foot Controller"
|
||||||
|
CONFIG_TINYUSB_MIDI_ENABLED=y
|
||||||
|
CONFIG_TINYUSB_MIDI_RX_BUFSIZE=64
|
||||||
|
CONFIG_TINYUSB_MIDI_TX_BUFSIZE=64
|
||||||
|
|
||||||
|
# FreeRTOS
|
||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
|
||||||
|
# Log level
|
||||||
|
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||||
Reference in New Issue
Block a user