Cleaned up repository
- only moving files around
This commit is contained in:
64
esp-firmware/lib/ledtl/effects/SwipeAndChange.h
Normal file
64
esp-firmware/lib/ledtl/effects/SwipeAndChange.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#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 <typename TLedStrip>
|
||||
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<TLedStrip> effect1_;
|
||||
EffectRandomTwoColorInterpolation<TLedStrip> effect2_;
|
||||
int effectRunning_;
|
||||
};
|
||||
|
||||
// Traits
|
||||
template <>
|
||||
struct EffectIdToConfig<EffectId::SWIPE_AND_CHANGE>
|
||||
{
|
||||
using type = EffectSwipeAndChangeConfig;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct EffectConfigToId<EffectSwipeAndChangeConfig>
|
||||
{
|
||||
static constexpr auto id = EffectId::SWIPE_AND_CHANGE;
|
||||
};
|
||||
|
||||
template <typename TLedStrip>
|
||||
struct EffectIdToClass<EffectId::SWIPE_AND_CHANGE, TLedStrip>
|
||||
{
|
||||
using type = EffectSwipeAndChange<TLedStrip>;
|
||||
};
|
||||
Reference in New Issue
Block a user