ESPHome  2024.11.0
light_effect.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
6 
7 namespace esphome {
8 namespace light {
9 
10 class LightState;
11 
12 class LightEffect {
13  public:
14  explicit LightEffect(std::string name) : name_(std::move(name)) {}
15 
17  virtual void start() {}
18 
19  virtual void start_internal() { this->start(); }
20 
22  virtual void stop() {}
23 
25  virtual void apply() = 0;
26 
27  const std::string &get_name() { return this->name_; }
28 
30  virtual void init() {}
31 
33  this->state_ = state;
34  this->init();
35  }
36 
37  protected:
38  LightState *state_{nullptr};
39  std::string name_;
40 };
41 
42 } // namespace light
43 } // namespace esphome
const char * name
Definition: stm32flash.h:78
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:63
virtual void stop()
Called when this effect is about to be removed.
Definition: light_effect.h:22
virtual void start_internal()
Definition: light_effect.h:19
STL namespace.
LightEffect(std::string name)
Definition: light_effect.h:14
void init_internal(LightState *state)
Definition: light_effect.h:32
const std::string & get_name()
Definition: light_effect.h:27
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
virtual void apply()=0
Apply this effect. Use the provided state for starting transitions, ...
virtual void start()
Initialize this LightEffect. Will be called once after creation.
Definition: light_effect.h:17
virtual void init()
Internal method called by the LightState when this light effect is registered in it.
Definition: light_effect.h:30
bool state
Definition: fan.h:34