Fix for ESP32-S3-WROOM-1: safe GPIO pins, serial flush, delays

- Switch pins: 2-7, 15-18 (avoids USB 19/20, PSRAM 26-32, JTAG 34-37)
- LED pins: 38-42, 45-48, 21 (high GPIOs, no special functions)
- Add Serial.flush() after init messages
- Increase startup delays for reliable serial output
- Board: esp32-s3-devkitc-1-n16r8
This commit is contained in:
2026-06-23 13:22:49 +00:00
parent bb32ec65d1
commit c94be67384
4 changed files with 31 additions and 20 deletions
+3 -2
View File
@@ -3,17 +3,18 @@
[env:esp32s3]
platform = espressif32
board = esp32-s3-devkitc-1
board = esp32-s3-devkitc-1-n16r8
framework = arduino
lib_deps =
adafruit/Adafruit TinyUSB Library@^2.0.0
adafruit/Adafruit NeoPixel
build_flags =
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
monitor_speed = 115200
monitor_port = /dev/ttyACM0
board_build.partitions = default_8MB.csv
board_build.arduino.memory_type = qio_opi
+14 -12
View File
@@ -2,7 +2,7 @@
#include <Arduino.h>
static const uint8_t LED_PINS[10] = {
11, 12, 13, 14, 15, 16, 17, 18, 19, 20
38, 39, 40, 41, 42, 45, 46, 47, 48, 21
};
DefaultLedStub::DefaultLedStub() : initialized(false) {
@@ -22,21 +22,23 @@ void DefaultLedStub::begin() {
}
initialized = true;
Serial.println("[LED] Startup colour cycle...");
Serial.println("[LED] Startup animation...");
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(LED_PINS[i], HIGH);
Serial.printf("[LED] LED %d ON (GPIO %d)\n", i, LED_PINS[i]);
Serial.printf("[LED] LED %d ON (GPIO %d)\n", i, LED_PINS[i]);
delay(150);
}
delay(300);
for (int i = NUM_LEDS - 1; i >= 0; i--) {
digitalWrite(LED_PINS[i], LOW);
Serial.printf("[LED] LED %d OFF (GPIO %d)\n", i, LED_PINS[i]);
delay(100);
}
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(LED_PINS[i], LOW);
delay(50);
}
clear_all();
Serial.println("[LED] Startup cycle complete");
Serial.println("[LED] Startup complete");
}
void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) {
@@ -57,7 +59,7 @@ void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t veloci
note, led_index, channel, velocity,
velocity > 0 ? "ON" : "OFF");
} else {
Serial.printf("[LED] Index out of range: %d (Note: %d)\n", led_index, note);
Serial.printf("[LED] Out of range: %d (Note: %d)\n", led_index, note);
}
}
@@ -69,5 +71,5 @@ void DefaultLedStub::clear_all() {
digitalWrite(LED_PINS[i], LOW);
}
}
Serial.println("[LED] All LEDs cleared");
Serial.println("[LED] All cleared");
}
+10 -2
View File
@@ -26,17 +26,24 @@ void midi_task(void* parameter) {
void setup() {
Serial.begin(115200);
delay(1000);
delay(2000);
Serial.println("=================================");
Serial.println(" Loopy MIDI Controller v0.1");
Serial.println(" Phase 1: USB MIDI");
Serial.println(" Board: ESP32-S3-WROOM-1");
Serial.println("=================================");
Serial.println("[INIT] Starting LED startup animation...");
led_driver.begin();
Serial.println("[INIT] Initializing switches...");
switch_driver.begin();
Serial.println("[INIT] Initializing USB MIDI...");
midi_transport.begin();
Serial.println("[INIT] Registering MIDI callbacks...");
controller.begin();
xTaskCreatePinnedToCore(
@@ -51,8 +58,9 @@ void setup() {
Serial.println("=================================");
Serial.println(" All systems ready");
Serial.println(" Waiting for USB connection...");
Serial.println(" Waiting for USB MIDI host...");
Serial.println("=================================");
Serial.flush();
}
void loop() {
+4 -4
View File
@@ -2,7 +2,7 @@
#include <Arduino.h>
static const uint8_t SWITCH_PINS[10] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
2, 3, 4, 5, 6, 7, 15, 16, 17, 18
};
DefaultSwitchStub::DefaultSwitchStub() : initialized(false) {
@@ -21,7 +21,7 @@ void DefaultSwitchStub::begin() {
pinMode(switch_states[i].gpio_pin, INPUT_PULLUP);
}
initialized = true;
Serial.printf("[SW] Initialized %d switches on GPIOs: ", NUM_SWITCHES);
Serial.printf("[SW] %d switches on GPIOs: ", NUM_SWITCHES);
for (int i = 0; i < NUM_SWITCHES; i++) {
Serial.printf("%d ", switch_states[i].gpio_pin);
}
@@ -57,12 +57,12 @@ void DefaultSwitchStub::configure_switch(uint8_t switch_id, uint8_t gpio_pin) {
if (initialized) {
pinMode(gpio_pin, INPUT_PULLUP);
}
Serial.printf("[SW] Switch %d configured to GPIO %d\n", switch_id, gpio_pin);
Serial.printf("[SW] Switch %d -> 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);
Serial.printf("[SW] Debounce: %lu ms\n", time_ms);
}