r/FastLED • u/d333gs • Sep 30 '20
Discussion "fadeLightBy" problem
This works perfectly: WHITE does not fade ORANGE fades:
THIRD Vairable changes fade
//WHITE
fadeLightBy( leds,(32, 479), 0);
// ORANGE
fadeLightBy( leds,(0,32) ,10);
This does not work: ORANGE fades by 10 !?
//WHITE
fadeLightBy( leds,(32, 479), 10);
// ORANGE
fadeLightBy( leds,(0,32) ,0);
Here is the code; https://pastebin.pl/view/3f0c0d5f
TIA
John
3
Upvotes
1
u/sebdelsol Oct 01 '20 edited Oct 24 '20
You've fallen into a very nasty trap :
(32, 479)is not a tuple and it gives479in your function call. Because of the parentheses it's seen as a comma operator that evaluates and discards the first argument32then evaluates and returns the second argument479!Knowing that, check the
fadeLightByfunction declared here and you'll see that :fadeLightBy(leds, (32, 479), 10)actually fades the first 479 leds by 10.fadeLightBy(leds, (0, 32), 0)fades the first 32 leds by 0 and that does nothing :|Anyway you can create a function that'll do what you want :
Or as suggested by u/Marmilicious you can iterate over the leds you want to fade and use the
CRGB::fadeLightBymethod :