Hey, I’ve been playing with FastLED the past couple of days and really love how great it makes my WS2811 pixels look. I really like how the code here looks:
I’ve modified that example and defined some of my own color palettes.
The project I’m working on is a tree, covered with about 1000 pixels. I’d like to run the code above in the background, but also overlay some spatial effects like snow falling and a spinning candy cane.
For snow falling, I’ve already split the pixels up into about 20 rows. The idea would be to fade the whole row to white then back to the base color, while preserving the twinkle effect from that code example. Then repeat in succession down the whole tree.
I’m trying to wrap my head around how to overlay multiple effects. So far, I’ve tried creating two sets of current and target palettes. The second set copies the current palette then sets the target to white, using nblendPaletteTowardPalette(). Then specific LEDs get updated to the second palette instead of the first for a certain period of time.
I don’t think that’s quite right, however. Or at least, I haven’t been able to get it to fade as desired.
Could anyone point me in the right direction? You don’t need to write new code, but any examples already out there or ideas would help a lot.
You might be better running each animation separately into their own array, then blend the two together to make the final output array. This will use 3 times the memory, which might be an issue given the number of LEDs, but would be much simpler to code once you have it setup.
Most of the snowfall overlay happens in the function FillLEDsFromPaletteColors(). The LEDs are spatially mapped in horizontal bands (positions defined in verticalMap[][]).
The FastLED nblend() function is used to blend the main color palette (i.e. the background palette) with a snow palette. You can see an example of this in line 280 of the code sample.
So the snowfall is relatively smooth, there is always one row that is fading in to snow, one full snow, and one fading back to the background palette. That’s what’s happening in lines 279-287.