Switch from FastLED to Adafruit NeoPixel (more reliable on ESP32-S3 RMT)

This commit is contained in:
2026-06-23 14:32:19 +00:00
parent 2931571880
commit 5f2ad9ef91
4 changed files with 21 additions and 22 deletions
+17 -16
View File
@@ -5,6 +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(NUM_LEDS, dat, NEO_GRB + NEO_KHZ800),
last_button_state(0) {
}
@@ -18,11 +19,9 @@ void PixelStompMux::begin() {
delay(100);
FastLED.addLeds<WS2812, 9, GRB>(leds, NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
FastLED.setBrightness(128);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
strip.begin();
strip.setBrightness(128);
strip.show();
Serial.printf("[MUX] Init DAT=%d LD=%d CLK=%d DI=%d\n",
pin_dat, pin_ld, pin_clk, pin_di);
@@ -59,21 +58,23 @@ 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) return;
leds[index] = CRGB(r, g, b);
strip.setPixelColor(index, r, g, b);
}
void PixelStompMux::set_led_brightness(uint8_t brightness) {
FastLED.setBrightness(brightness);
strip.setBrightness(brightness);
}
void PixelStompMux::clear_all() {
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
Serial.println("[MUX] LEDs cleared");
}
void PixelStompMux::show() {
FastLED.show();
strip.show();
}
void PixelStompMux::dump() {
@@ -91,7 +92,7 @@ void PixelStompMux::dump() {
}
void PixelStompMux::probe() {
Serial.println("[MUX] === Hardware Probe (BMC Protocol) ===");
Serial.println("[MUX] === Hardware Probe (NeoPixel) ===");
for (int round = 0; round < 5; round++) {
Serial.printf("--- Round %d ---\n", round);
@@ -122,12 +123,12 @@ void PixelStompMux::probe() {
}
Serial.println(" LED test: pixel 0 RED (max brightness)...");
leds[0] = CRGB(255, 0, 0);
FastLED.setBrightness(255);
FastLED.show();
strip.setBrightness(255);
strip.setPixelColor(0, 255, 0, 0);
strip.show();
delay(2000);
leds[0] = CRGB::Black;
FastLED.show();
strip.setPixelColor(0, 0, 0, 0);
strip.show();
Serial.println("[MUX] === Probe Complete ===");
}