Cleaned up repository
- only moving files around
This commit is contained in:
63
esp-firmware/lib/ledtl/effects/Static.h
Normal file
63
esp-firmware/lib/ledtl/effects/Static.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "effects/Common.h"
|
||||
#include "helpers/ColorRGBW.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct EffectStaticConfig
|
||||
{
|
||||
EffectStaticConfig(const ColorRGBW &c = ColorRGBW{0, 0, 0, 0}, uint16_t beg = 0, uint16_t en = 0)
|
||||
: color(c), begin(beg), end(en) {}
|
||||
|
||||
ColorRGBW color;
|
||||
uint16_t begin = 0;
|
||||
uint16_t end = 0;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
template <typename TLedStrip>
|
||||
class EffectStatic
|
||||
{
|
||||
public:
|
||||
static constexpr auto NUM_LEDS = numLeds<TLedStrip>();
|
||||
using ConfigType = EffectStaticConfig;
|
||||
|
||||
EffectStatic(const EffectStaticConfig &cfg, TLedStrip &ledStrip)
|
||||
: config_(cfg),
|
||||
ledStrip_(ledStrip)
|
||||
{
|
||||
}
|
||||
|
||||
int operator()()
|
||||
{
|
||||
if (config_.begin == config_.end)
|
||||
setLedRGBW(ledStrip_, 0, NUM_LEDS, config_.color);
|
||||
else
|
||||
setLedRGBW(ledStrip_, config_.begin, config_.end, config_.color);
|
||||
|
||||
return 10000; // nothing changing, return some large time to sleep
|
||||
}
|
||||
|
||||
private:
|
||||
EffectStaticConfig config_;
|
||||
TLedStrip &ledStrip_;
|
||||
};
|
||||
|
||||
// Traits
|
||||
template <>
|
||||
struct EffectIdToConfig<EffectId::STATIC>
|
||||
{
|
||||
using type = EffectStaticConfig;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct EffectConfigToId<EffectStaticConfig>
|
||||
{
|
||||
static constexpr auto id = EffectId::STATIC;
|
||||
};
|
||||
|
||||
template <typename TLedStrip>
|
||||
struct EffectIdToClass<EffectId::STATIC, TLedStrip>
|
||||
{
|
||||
using type = EffectStatic<TLedStrip>;
|
||||
};
|
||||
Reference in New Issue
Block a user