Switch from NeoPixel to FastLED for ESP32-S3 LED reliability

FastLED has better ESP32 support and handles timing/RMT properly.
- Use CRGB array instead of Adafruit_NeoPixel
- FastLED.show() is more reliable on ESP32-S3
- probe command now tests all LEDs at max brightness
This commit is contained in:
2026-06-23 13:56:05 +00:00
parent 76dec0d359
commit 5de4de4f1a
4 changed files with 35 additions and 40 deletions
+12 -12
View File
@@ -19,7 +19,7 @@ void DefaultLedStub::set_mux(PixelStompMux* mux) {
}
void DefaultLedStub::begin() {
Serial.println("[LED] Using WS2812C via PixelStomp MUX");
Serial.println("[LED] Using WS2812C via PixelStomp MUX (FastLED)");
initialized = true;
if (!mux_ptr) {
@@ -30,13 +30,13 @@ void DefaultLedStub::begin() {
Serial.println("[LED] Startup animation...");
uint32_t colors[] = {
0xFF0000, // Red
0x00FF00, // Green
0x0000FF, // Blue
0xFFFF00, // Yellow
0xFF00FF, // Magenta
0x00FFFF, // Cyan
0xFFFFFF, // White
0xFF0000,
0x00FF00,
0x0000FF,
0xFFFF00,
0xFF00FF,
0x00FFFF,
0xFFFFFF,
};
int num_colors = sizeof(colors) / sizeof(colors[0]);
@@ -51,7 +51,7 @@ void DefaultLedStub::begin() {
}
mux_ptr->show();
Serial.printf("[LED] Colour %d: R=%d G=%d B=%d\n", c, r, g, b);
delay(200);
delay(300);
}
clear_all();
@@ -71,15 +71,15 @@ void DefaultLedStub::set_led_state(uint8_t note, uint8_t channel, uint8_t veloci
led_states[led_index].timestamp = millis();
if (velocity > 0) {
uint8_t brightness = map(velocity, 1, 127, 30, 255);
uint8_t brightness = map(velocity, 1, 127, 50, 255);
mux_ptr->set_led_color(led_index, brightness, brightness, brightness);
} else {
mux_ptr->set_led_color(led_index, 0, 0, 0);
}
mux_ptr->show();
Serial.printf("[LED] Note %d -> LED %d Ch %d Vel %d (%s)\n",
note, led_index, channel, velocity,
Serial.printf("[LED] Note %d -> LED %d Vel %d (%s)\n",
note, led_index, velocity,
velocity > 0 ? "ON" : "OFF");
} else {
Serial.printf("[LED] Out of range: %d (Note: %d)\n", led_index, note);
+20 -24
View File
@@ -5,7 +5,7 @@
PixelStompMux::PixelStompMux(uint8_t dat, uint8_t ld, uint8_t clk, uint8_t di)
: pin_dat(dat), pin_ld(ld), pin_clk(clk), pin_di(di),
strip(nullptr), last_button_state(0) {
last_button_state(0) {
}
void PixelStompMux::begin() {
@@ -16,15 +16,14 @@ void PixelStompMux::begin() {
digitalWrite(pin_clk, LOW);
digitalWrite(pin_ld, HIGH);
strip = new Adafruit_NeoPixel(NUM_LEDS, pin_dat, NEO_GRB + NEO_KHZ800);
strip->begin();
strip->setBrightness(80);
strip->clear();
strip->show();
FastLED.addLeds<WS2812, 9, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(80);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
Serial.printf("[MUX] Init DAT=%d LD=%d CLK=%d DI=%d\n",
pin_dat, pin_ld, pin_clk, pin_di);
Serial.printf("[MUX] 74HC165 x2 daisy-chain, WS2812C x%d LEDs\n", NUM_LEDS);
Serial.printf("[MUX] 74HC165 x2 daisy-chain, WS2812C x%d LEDs (FastLED)\n", NUM_LEDS);
}
uint8_t PixelStompMux::read_buttons() {
@@ -52,24 +51,22 @@ bool PixelStompMux::is_button_pressed(uint8_t index) {
}
void PixelStompMux::set_led_color(uint8_t index, uint8_t r, uint8_t g, uint8_t b) {
if (index >= NUM_LEDS || !strip) return;
strip->setPixelColor(index, strip->Color(r, g, b));
if (index >= NUM_LEDS) return;
leds[index] = CRGB(r, g, b);
}
void PixelStompMux::set_led_brightness(uint8_t brightness) {
if (strip) strip->setBrightness(brightness);
FastLED.setBrightness(brightness);
}
void PixelStompMux::clear_all() {
if (strip) {
strip->clear();
strip->show();
}
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
Serial.println("[MUX] LEDs cleared");
}
void PixelStompMux::show() {
if (strip) strip->show();
FastLED.show();
}
void PixelStompMux::dump() {
@@ -108,15 +105,14 @@ void PixelStompMux::probe() {
delayMicroseconds(5);
}
Serial.println(" Testing NeoPixel DAT pin...");
if (strip) {
strip->setPixelColor(0, strip->Color(255, 255, 255));
strip->show();
Serial.println(" Set pixel 0 to WHITE - check if it lights up");
delay(1000);
strip->clear();
strip->show();
}
Serial.println(" Testing FastLED DAT pin...");
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.setBrightness(255);
FastLED.show();
Serial.println(" All pixels WHITE (max brightness) - check if they light up");
delay(2000);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
Serial.println("[MUX] === Probe Complete ===");
}