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
+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 ===");
}