51 lines
		
	
	
		
			929 B
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			929 B
		
	
	
	
		
			C++
		
	
	
	
| #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>;
 | |
| }; |