These are chat archives for Makuna/NeoPixelBus

6th
Jun 2016
sticilface
@sticilface
Jun 06 2016 06:06

got another issue if u don't mind... so got rgbw working nicely... and to do it i created an effect cpp and h file and placed it in my /src/effects folder. to add effects to the sketch the user includes #include "effects/whatever.h" in the arduino sketch and adds a line to the setup function. the problem is that even with no #include, or reference to any of the code (that uses 4 color) it is still being compiled... which then breaks as SetPixelColor(pixel, updatedColor); is only accepting 3 color objects not 4.. i tried wrapping

                if (strip->PixelsSize() == 4) {
                    strip->SetPixelColor(pixel, updatedColor);
                }

but as it is template stuff that doesn't work either. any idea have these cpp and h files there so they can be included/excluded if needed by the user? i.e. i want only people who have defined a 4 color strip object to use this effect by including it?

thanks in advance
Michael Miller
@Makuna
Jun 06 2016 07:21
@sticilface I thought the IDE only included everything in the root or src of the sketch folder?
Just a thought exercise, but if the sketch typedef the feature type like NeoPixelBitmap sample does, then you can reference MyColorFeature::ColorObject which will be Rgb or Rgbw color.
sticilface
@sticilface
Jun 06 2016 07:25
It's a bit wierd as platformio builds it fine (and seemly even with white included and strip typedef set as 3 colour object)
I'll need to play more but ran out of laptop battery
sticilface
@sticilface
Jun 06 2016 07:40
mmm
so that didn't work
/Users/amelvin/Dropbox/Sketchbook/libraries/Melvanimate/src/effects/White.cpp:41:46: error: no matching function for call to 'NeoPixelBus<NeoGrbFeature, NeoEsp8266UartMethodBase<NeoEsp8266UartSpeed800Kbps> >::SetPixelColor(const uint16_t&, RgbwColor&)'
      strip->SetPixelColor(pixel, updatedColor);
hang on... i miss understood the second part of your instruction
sticilface
@sticilface
Jun 06 2016 07:52
although I'm not sure it will work, as the function then applies 4 colours to it, so when MyColorFeature::ColorObject is rbg it will fail.. and second... the typedef doesn't seem to work inside the lambda..
here is the whole function anyway..
bool White::Start()
{
    if (animator) {

        delete animator;
        animator = nullptr;
    }



    animator = new NeoPixelAnimator(  ( strip->PixelCount() < MAX_NUMBER_OF_ANIMATIONS) ? strip->PixelCount() : MAX_NUMBER_OF_ANIMATIONS  );


    if (animator) {

        AnimEaseFunction easing = NeoEase::QuadraticInOut;

        for (uint16_t pixel = 0; pixel < strip->PixelCount(); pixel++) {

            //RgbwColor originalColor = strip->GetPixelColor(pixel);
            MyColorFeature::ColorObject originalColor = strip->GetPixelColor(pixel);

            AnimUpdateCallback animUpdate = [ = ](const AnimationParam & param) {
                //float progress = easing(param.progress);
                float progress = param.progress;
                MyColorFeature::ColorObject  updatedColor = RgbwColor::LinearBlend(originalColor, RgbwColor(0, 0, 0, brightness() ), progress);
                if (strip->PixelsSize() == 4) {
                    strip->SetPixelColor(pixel, updatedColor);
                }
            };

            animator->StartAnimation(pixel, 1000, animUpdate);

        }
    }
}
seems odd... as the file should not even be processed!
Charles
@hallard
Jun 06 2016 17:35
@Makuna
I've done some testing about my dual animation problem earlier. Your suggestion was good of course ;-) But I have a problem I spent little time to find out. I didn't found how it's possible to have 2 animations with different time. Let me explain, 2 fade in/fade out; one at 300ms speed other 1000ms speed. Animation.isAnimating() fire the end of "all" animation, so every 1000ms (makes senses) the side effect is the 300ms animation change only every 1000ms not 300ms, except if I missed something ?
Michael Miller
@Makuna
Jun 06 2016 17:49
@hallard Look at the bitmap example, notice that its not using the isAnimating() in the loop; but instead of checking "all animations are done" it checks within the animation update itself if the individual animation is done and restarts it.
Charles
@hallard
Jun 06 2016 17:50
Hey, that is what I needed, check individual animation, I'll take a look, thanks ;-)