#pragma once #include "effects/Common.h" #include "effects/AlexaSwipe.h" #include "effects/RandomTwoColorInterpolation.h" #pragma pack(push, 1) struct EffectSwipeAndChangeConfig { EffectAlexaSwipeConfig swipeCfg; EffectRandomTwoColorInterpolationConfig changeCfg; }; #pragma pack(pop) template class EffectSwipeAndChange { public: EffectSwipeAndChange(const EffectSwipeAndChangeConfig &cfg, TLedStrip &ledStrip) : effect1_(cfg.swipeCfg, ledStrip), effect2_(cfg.changeCfg, ledStrip), effectRunning_(0) { } int operator()() { if (!effect1_.finished()) { return effect1_(); } else { if (effectRunning_ == 0) effect2_.begin(); effectRunning_ = 1; return effect2_(); } } private: EffectAlexaSwipe effect1_; EffectRandomTwoColorInterpolation effect2_; int effectRunning_; }; // Traits template <> struct EffectIdToConfig { using type = EffectSwipeAndChangeConfig; }; template <> struct EffectConfigToId { static constexpr auto id = EffectId::SWIPE_AND_CHANGE; }; template struct EffectIdToClass { using type = EffectSwipeAndChange; };