Changing NUM_LEDS breaks my patterns. I just cut a strip of WS2812B’s from 300 to 144, and noticed that after changing NUM_LEDS to 144 my patterns have all gone crazy, flickering and jittering wildly as if the timing is way off. Changing NUM_LEDS back to 300 returns the behavior to normal, even though there are actually 144 LEDs in the strip, which makes me believe it is a software problem. Putting in intermediate values, like 200, make the patterns flicker and misbehave less than a lower value does. The variable NUM_LEDS is the only reference to the number of LEDs in the strip, 300 or 144 isn’t hard coded in anywhere. Any ideas on what the issue could be? I’ve included a link to the code in case anyone wants to see.
https://github.com/dlovinger/HyperCube
Could I suggest
That you add FastLED.delay(delayFPS) and replace you the timing of the every_n_milisescond(delayFPS) with another value. Larger than 8ms
My guess is that as the show for 144 will take a bit more that 4ms there is a conflict between the refresh rate of the leds themselves and the fact that your delayFPS is a bit more than 8ms
Line 208 seems to be dependant on the number of LEDs.
What happens if you connect 144 LEDs but declare 300?
Are the 144 led strip and the 300 led strip exactly the same? It sounds like there could be faulty led(s) on the 144 strip…
Which MCU are you using?
@Yves_BAZIN Sorry for the delay, I’ve been busy with other work, but thank you for the great suggestion. I started typing out a long response about how it still wasn’t working, then tried one more fix and got it! Using FastLED.delay was indeed the solution, but it turns out that FastLED.delay must come AFTER FastLED.show(). Not sure why, but if it comes before the strip misbehaves…
Delay works even with 120 FPS, but I’m still not sure why using EVERY_N doesn’t work with 144 but does with 300. Oh well, the button is still responsive with delay, so everything is well. Thank you again for the help.
@Jeremy_Spencer Thanks for pointing out that line. It wasn’t the main issue, but it was causing a crash whenever that pattern was called. It was the same strip, the 300 cut to 144 LEDs. The problem was occurring when declaring NUM_LEDS = 144 on the 144 LED strip (I did count, the number is right), but when declaring NUM_LEDS = 300 on the 144 LED strip it worked fine. Seems to be working now though!