These are chat archives for Makuna/NeoPixelBus

12th
Jun 2015
Michael Miller
@Makuna
Jun 12 2015 07:53
I have published a new branch (NeoPixelAnimations) that refactors the animations and now supports a HslColor along with the RgbColor. While this branch is not ready for prime time (esp8266 only at the moment due to the lack of STL support for AVR), it does expose power animation support. Readme and Examples where updated.
The other nice thing is, it also repro's the first pixel problem consistently from the test sample.
sticilface
@sticilface
Jun 12 2015 10:28
I've been following yours posts looks like you're on the case and finding out what exactly is going on! good work.
I will take a look at your new branch. no doubt i'll have many questions... i've only just got all the other code to work nicely :)
Michael Miller
@Makuna
Jun 12 2015 16:12

The interesting part of the new library is how to define an animation. Its a little more complex but "FAR" more powerfull and flexible.

// in your code to start an animation
            AnimUpdateCallback animUpdate = [=](float progress)
            {
                // progress will start at 0.0 and end at 1.0
                RgbColor updatedColor = RgbColor::LinearBlend(originalColor, RgbColor(0, 0, 0), (uint8_t)(255 * progress));
                strip.SetPixelColor(pixel, updatedColor);
            };
            // start the animation
            animations.StartAnimation(pixel, time, animUpdate);

the first line looks pretty strange, its define a function variable that contains the lamba (function within a function). The interesting thing with the lambda is that it remembers variables you use within it (local or otherwise) to use when it is called.
So the animUpdate remembers the value in the variables originalColor, pixel, and strip in the above example. This lambda is passed to the animations to Start, and it will be called every time "time" moves forward and the animation needs updating. So the lambda calculates the new color and applies it to the strip. This gives you the app developer the ability to define any animation effect you want without needing to manage time.

sticilface
@sticilface
Jun 12 2015 16:33
Sounds very cool. I'll have get into it next week sometime. I'm away this weekend. Right now I've been trying to figure out why my esp seems to crash randomly when it's in AP mode. Quite strange.