These are chat archives for Makuna/NeoPixelBus

Sep 2015
Sep 05 2015 23:41

@makuna i gave up on trying to get dithering to work! but I'm a bit stuck on something else...

I'm designing a kind of animator object class, that allows you to easily create objects and groups of LEDs that are animated.. I've used your lambda function and animator code as a basis, and i've basically got it to work. there is one problem though...

I can't seem to pass variable to the lama function by reference (using the [=] ) , have the lambda function do stuff to them, and then keep them as static variables to work on the next time round!

here is a sample of the code

    for (uint8_t i = 0; i < WS2812_Settings.Effect_Count; i++ ) {

            RgbColor newcolor = Wheel(random(255));

            uint8_t x = random ( 0, 5 ); 
            uint8_t y = random ( 0, 5 ) ; 

            Debugf("Start Pixels %u = (%u,%u) \n", i, x, y );

             ObjectCallback ObjectUpdate = [=]()

                 static uint8_t a, b ; 
                  a = x, b = y; 

                  Debugf("%u Callback (%u,%u) \n", i, a, b ); 

            uint8_t slot = animatedobject->Add(ObjectUpdate);

            Debugf("Started sequence %u \n", slot); 

          }; //

this works in principle, I want to generate random coordinates, feed them into the animatorobject, then have the objectcallback work on these, say add, or subtract but remember where it is so next time it is not just starting from the read only vars passed to it originally. does this make any sense?

but i can't initialise the static vars as being = to anything as i get cxa_guard errors..