Separate FreeRTOS task for LED
This commit is contained in:
@@ -17,6 +17,7 @@ class EffectCircular
|
||||
public:
|
||||
static constexpr auto NUM_LEDS = numLeds<TLedStrip>();
|
||||
static constexpr int DELAY_MS = 10;
|
||||
using ConfigType = EffectCircularConfig;
|
||||
|
||||
EffectCircular(const EffectCircularConfig &cfg, TLedStrip &ledStrip)
|
||||
: config_(cfg),
|
||||
@@ -72,3 +73,22 @@ private:
|
||||
int widthInLeds_;
|
||||
float invWidth_;
|
||||
};
|
||||
|
||||
// Traits
|
||||
template <>
|
||||
struct EffectIdToConfig<EffectId::CIRCULAR>
|
||||
{
|
||||
using type = EffectCircularConfig;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct EffectConfigToId<EffectCircularConfig>
|
||||
{
|
||||
static constexpr auto id = EffectId::CIRCULAR;
|
||||
};
|
||||
|
||||
template <typename TLedStrip>
|
||||
struct EffectIdToClass<EffectId::CIRCULAR, TLedStrip>
|
||||
{
|
||||
using type = EffectCircular<TLedStrip>;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
enum class EffectID
|
||||
enum class EffectId
|
||||
{
|
||||
OFF,
|
||||
STATIC,
|
||||
CIRCULAR,
|
||||
CIRCLE_WAVE,
|
||||
@@ -9,9 +9,17 @@ enum class EffectID
|
||||
RAINBOW_FADE,
|
||||
};
|
||||
|
||||
template <typename TLedStrip>
|
||||
class AbstractEffect
|
||||
template <EffectId id>
|
||||
struct EffectIdToConfig
|
||||
{
|
||||
};
|
||||
|
||||
template <typename EffectConfig>
|
||||
struct EffectConfigToId
|
||||
{
|
||||
};
|
||||
|
||||
template <EffectId id, typename TLedStrip>
|
||||
struct EffectIdToClass
|
||||
{
|
||||
public:
|
||||
virtual int operator()(TLedStrip &s) = 0;
|
||||
};
|
||||
51
espmusicmouse/lib/ledtl/effects/Static.h
Normal file
51
espmusicmouse/lib/ledtl/effects/Static.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "effects/Common.h"
|
||||
#include "helpers/ColorRGBW.h"
|
||||
|
||||
struct EffectStaticConfig
|
||||
{
|
||||
ColorRGBW color;
|
||||
};
|
||||
|
||||
template <typename TLedStrip>
|
||||
class EffectStatic
|
||||
{
|
||||
public:
|
||||
static constexpr auto NUM_LEDS = numLeds<TLedStrip>();
|
||||
|
||||
EffectStatic(const EffectStaticConfig &cfg, TLedStrip &ledStrip)
|
||||
: config_(cfg),
|
||||
ledStrip_(ledStrip)
|
||||
{
|
||||
}
|
||||
|
||||
int operator()()
|
||||
{
|
||||
setLedRGBW(ledStrip_, 0, NUM_LEDS, 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