diff --git a/include/pixel_stomp_mux.h b/include/pixel_stomp_mux.h index 6a51561..d981028 100644 --- a/include/pixel_stomp_mux.h +++ b/include/pixel_stomp_mux.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include 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(); }; diff --git a/platformio.ini b/platformio.ini index 9ea2aee..55a86ec 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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 diff --git a/src/led_stub.cpp b/src/led_stub.cpp index 5dde6d8..6efdb65 100644 --- a/src/led_stub.cpp +++ b/src/led_stub.cpp @@ -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) { diff --git a/src/pixel_stomp_mux.cpp b/src/pixel_stomp_mux.cpp index 883aa8c..ec62629 100644 --- a/src/pixel_stomp_mux.cpp +++ b/src/pixel_stomp_mux.cpp @@ -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(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 ==="); }