added skip led

This commit is contained in:
Daan Meijer 2025-01-24 22:42:22 +01:00
parent 347241bee2
commit ef73f2c7ac
2 changed files with 18 additions and 8 deletions

View File

@ -5,16 +5,23 @@ CRGB led;
CRGB source; CRGB source;
CRGB target; CRGB target;
#ifdef LEVEL_SHIFT_WS2812B
#define SKIP_PIXELS 1
#else
#define SKIP_PIXELS 0
#endif
CRGB strip1[STRIP_LENGTH]; #define NUM_LEDS STRIP_LENGTH + SKIP_PIXELS
CRGB strip2[STRIP_LENGTH];
// Add one black pixel to the front
CRGB strip1[NUM_LEDS];
CRGB strip2[NUM_LEDS];
int fadeStart = 0; int fadeStart = 0;
#ifdef LED_NEOPIXEL_BUS #ifdef LED_NEOPIXEL_BUS
NeoPixelBus<NeoGrbFeature, NeoWs2812xMethod> strip(STRIP_LENGTH, PIN_STRIP1); NeoPixelBus<NeoGrbFeature, NeoWs2812xMethod> strip(STRIP_LENGTH, PIN_STRIP1);
#endif #endif
void fadeTo(const CRGB & dest){ void fadeTo(const CRGB & dest){
@ -40,10 +47,10 @@ void fadeTo(const CRGB & dest){
void displayLed(){ void displayLed(){
#ifdef LED_FASTLED #ifdef LED_FASTLED
for(uint8_t index = 0; index < STRIP_LENGTH; index++){ for(uint8_t index = SKIP_PIXELS; index < NUM_LEDS; index++){
// Serial.printf("Led 1:%02d 0x%02x%02x%02x\n", index, strip1[index].r, strip1[index].g, strip1[index].b); // Serial.printf("Led 1:%02d 0x%02x%02x%02x\n", index, strip1[index].r, strip1[index].g, strip1[index].b);
} }
for(uint8_t index = 0; index < STRIP_LENGTH; index++){ for(uint8_t index = SKIP_PIXELS; index < NUM_LEDS; index++){
// Serial.printf("Led 2:%02d 0x%02x%02x%02x\n", index, strip2[index].r, strip2[index].g, strip2[index].b); // Serial.printf("Led 2:%02d 0x%02x%02x%02x\n", index, strip2[index].r, strip2[index].g, strip2[index].b);
} }
auto before = micros(); auto before = micros();
@ -73,7 +80,7 @@ void jumpTo(const CRGB & dest){
// Serial.printf("FastLED.showColor took %d micros\n", after - before); // Serial.printf("FastLED.showColor took %d micros\n", after - before);
// return; // return;
for(uint8_t index = 0; index < STRIP_LENGTH; index++){ for(uint8_t index = SKIP_PIXELS; index < NUM_LEDS; index++){
strip1[index] = CRGB(dest); strip1[index] = CRGB(dest);
strip2[index] = CRGB(dest); strip2[index] = CRGB(dest);
} }
@ -116,8 +123,10 @@ void Led_setup(){
// analogWriteRange(255); // analogWriteRange(255);
#ifdef LED_FASTLED #ifdef LED_FASTLED
FastLED.addLeds<WS2812B, PIN_STRIP1>(strip2, STRIP_LENGTH); FastLED.addLeds<WS2812B, PIN_STRIP1>(strip2, NUM_LEDS);
FastLED.addLeds<WS2812B, PIN_STRIP2>(strip2, STRIP_LENGTH); FastLED.addLeds<WS2812B, PIN_STRIP2>(strip2, NUM_LEDS);
strip1[0] = CRGB::Black;
strip2[0] = CRGB::Black;
#endif #endif
#ifdef LED_NEOPIXEL_BUS #ifdef LED_NEOPIXEL_BUS

View File

@ -24,6 +24,7 @@
#define PIN_STRIP2 6 #define PIN_STRIP2 6
#define STRIP_LENGTH 46 #define STRIP_LENGTH 46
#define LEVEL_SHIFT_WS2812B
#define FADE_PERIOD 3.0f #define FADE_PERIOD 3.0f