49 void setup()
override;
123 const std::vector<LightEffect *> &
get_effects()
const;
126 void add_effects(
const std::vector<LightEffect *> &effects);
135 void current_values_as_rgbw(
float *red,
float *green,
float *blue,
float *white,
bool color_interlock =
false);
138 bool constant_brightness =
false);
141 float *white_brightness);
void current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white, bool constant_brightness=false)
float gamma_correct_
Gamma correction factor for the light.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
ESPPreferenceObject rtc_
Object used to store the persisted values of the light.
void set_flash_transition_length(uint32_t flash_transition_length)
Set the flash transition length.
uint32_t get_flash_transition_length() const
void publish_state()
Publish the currently active state to the frontend.
std::unique_ptr< LightTransformer > transformer_
The currently active transformer for this light (transition/flash).
void set_immediately_(const LightColorValues &target, bool set_remote_values)
Internal method to set the color values to target immediately (with no transition).
uint32_t default_transition_length_
Default transition length for all transitions in ms.
Interface to write LightStates to hardware.
LightColorValues current_values
The current values of the light as outputted to the light.
void set_default_transition_length(uint32_t default_transition_length)
Set the default transition length, i.e. the transition length when no transition is provided...
std::string get_effect_name()
Return the name of the current effect, or if no effect is active "None".
LightCall turn_on()
Make a light state call.
void start_transition_(const LightColorValues &target, uint32_t length, bool set_remote_values)
Internal method to start a transition to the target color with the given length.
float get_gamma_correct() const
void start_effect_(uint32_t effect_index)
Internal method to start an effect with the given index.
LightRestoreMode restore_mode_
Restore mode of the light.
LightOutput * get_output() const
Get the light output associated with this object.
bool supports_effects()
Return whether the light has any effects that meet the trait requirements.
void start_flash_(const LightColorValues &target, uint32_t length, bool set_remote_values)
Internal method to start a flash for the specified amount of time.
void add_new_target_state_reached_callback(std::function< void()> &&send_callback)
The callback is called once the state of current_values and remote_values are equal (when the transit...
void setup() override
Load state from preferences.
void dump_config() override
void current_values_as_binary(bool *binary)
The result of all the current_values_as_* methods have gamma correction applied.
bool next_write_
Whether the light value should be written in the next cycle.
void current_values_as_rgb(float *red, float *green, float *blue, bool color_interlock=false)
uint32_t flash_transition_length_
Transition length to use for flash transitions.
LightState(LightOutput *output)
LightOutput * output_
Store the output to allow effects to have more access.
float gamma_correct(float value, float gamma)
Applies gamma correction of gamma to value.
This class represents the color state for a light object.
void current_values_as_rgbct(float *red, float *green, float *blue, float *color_temperature, float *white_brightness)
LightEffect * get_active_effect_()
Internal method to get the currently active effect.
void add_effects(const std::vector< LightEffect *> &effects)
Add effects for this light state.
void current_values_as_brightness(float *brightness)
uint32_t get_default_transition_length() const
void set_gamma_correct(float gamma_correct)
Set the gamma correction factor.
const std::vector< LightEffect * > & get_effects() const
Get all effects for this light state.
This class represents a requested change in a light state.
std::vector< LightEffect * > effects_
List of effects for this light.
void current_values_as_ct(float *color_temperature, float *white_brightness)
void current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness=false)
bool is_transformer_active_
float get_setup_priority() const override
Shortly after HARDWARE.
CallbackManager< void()> remote_values_callback_
Callback to call when new values for the frontend are available.
This class is used to represent the capabilities of a light.
void add_new_remote_values_callback(std::function< void()> &&send_callback)
This lets front-end components subscribe to light change events.
void set_restore_mode(LightRestoreMode restore_mode)
Set the restore mode of this light.
void save_remote_values_()
Internal method to save the current remote_values to the preferences.
CallbackManager< void()> target_state_reached_callback_
Callback to call when the state of current_values and remote_values are equal This should be called o...
Implementation of SPI Controller mode.
uint32_t active_effect_index_
Value for storing the index of the currently active effect. 0 if no effect is active.
LightColorValues remote_values
The remote color values reported to the frontend.
bool is_transformer_active()
Indicator if a transformer (e.g.
void stop_effect_()
Internal method to stop the current effect (if one is active).
void current_values_as_rgbw(float *red, float *green, float *blue, float *white, bool color_interlock=false)