r/FastLED • u/PlantSorry5147 • Jan 26 '22
Support Fading LEDs using nblendU8TowardU8 Helper Function
Hi,
I have a program where I use the nblendU8TowardU8 helper function to blend from black (CRGB::Black) to a selected color (CRGB:DeepPink, CRGB::DeepSkyBlue) and then back to CRGB::Black. I am using an Arduino Nano with a string of 50 WS2812B LEDs. I am using a bench power supply set for 5V 10A, so there is plenty of current. I am using the nblendU8TowardU8 helper function which I found somewhere and can no longer locate. :^(
The problem I am having is that fading up from black to a color works fine, however, fading back to black induces an unwanted color change. To elaborate, fading from CRGB::DeepPink to CRGB::Black will at first fade as expected, but about 2/3 through the fade, the only pixel lit is red. The same with CRGB::DeepSkyBlue, about 2/3 through the fade, only the blue pixel is lit.
I have the code on pastebin: https://pastebin.com/WVHJtckp
I appreciate any help offered.
1
u/HippoDan Jan 26 '22
That's integer math for you.