Switch from FastLED to Adafruit NeoPixel (more reliable on ESP32-S3 RMT)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <FastLED.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
class PixelStompMux {
|
||||
public:
|
||||
@@ -29,8 +29,6 @@ private:
|
||||
uint8_t pin_clk;
|
||||
uint8_t pin_di;
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
Adafruit_NeoPixel strip;
|
||||
uint8_t last_button_state;
|
||||
|
||||
uint8_t shift_in_74hc165();
|
||||
};
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ framework = arduino
|
||||
|
||||
lib_deps =
|
||||
adafruit/Adafruit TinyUSB Library@^2.0.0
|
||||
fastled/FastLED@^3.9.0
|
||||
adafruit/Adafruit NeoPixel@^1.12.0
|
||||
|
||||
build_flags =
|
||||
-DARDUINO_USB_MODE=1
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ void DefaultLedStub::set_mux(PixelStompMux* mux) {
|
||||
}
|
||||
|
||||
void DefaultLedStub::begin() {
|
||||
Serial.println("[LED] Using WS2812C via PixelStomp MUX (FastLED)");
|
||||
Serial.println("[LED] Using WS2812C via PixelStomp MUX (NeoPixel)");
|
||||
initialized = true;
|
||||
|
||||
if (!mux_ptr) {
|
||||
|
||||
+17
-16
@@ -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 ===");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user