Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (transitionTime == 0 && animation != A_NoAnimation)
- {
- Serial.println("[E] Only A_NoAnimation can be used with a null transition time.");
- return;
- }
- switch (animation)
- {
- case A_Flash:
- // Flash should always be used from full-black.
- for (int i = 0; i < _PIXELS; i++)
- strip.SetPixelColor(i, _BLACK);
- strip.Show();
- for (int i = 0; i < _PIXELS; i++)
- {
- // AnimEaseFunction easing;
- // easing = NeoEase::QuadraticIn;
- AnimUpdateCallback animUpdate = [ = ](const AnimationParam & param)
- {
- RgbColor updatedColor = RgbColor::LinearBlend(_BLACK, targetColor, param.progress);
- strip.SetPixelColor(param.index, updatedColor);
- };
- animations.StartAnimation(i, transitionTime, animUpdate);
- }
- break;
- case A_LinearBlend:
- for (int i = 0; i < _PIXELS; i++)
- {
- RgbColor originalColor = strip.GetPixelColor(i);
- AnimEaseFunction easing;
- easing = NeoEase::QuadraticIn;
- AnimUpdateCallback animUpdate = [ = ](const AnimationParam & param)
- {
- RgbColor updatedColor = RgbColor::LinearBlend(originalColor, targetColor, param.progress);
- strip.SetPixelColor(param.index, updatedColor);
- };
- animations.StartAnimation(i, transitionTime, animUpdate);
- }
- break;
- case A_NoAnimation:
- for (int i = 0; i < _PIXELS; i++)
- {
- strip.SetPixelColor(i, targetColor);
- }
- strip.Show();
- break;
- default:
- Serial.println("[!] No animation type defined.");
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment