ESPHome  2024.10.2
rgbww_light_output.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace rgbww {
9 
11  public:
12  void set_red(output::FloatOutput *red) { red_ = red; }
13  void set_green(output::FloatOutput *green) { green_ = green; }
14  void set_blue(output::FloatOutput *blue) { blue_ = blue; }
15  void set_cold_white(output::FloatOutput *cold_white) { cold_white_ = cold_white; }
16  void set_warm_white(output::FloatOutput *warm_white) { warm_white_ = warm_white; }
17  void set_cold_white_temperature(float cold_white_temperature) { cold_white_temperature_ = cold_white_temperature; }
18  void set_warm_white_temperature(float warm_white_temperature) { warm_white_temperature_ = warm_white_temperature; }
19  void set_constant_brightness(bool constant_brightness) { constant_brightness_ = constant_brightness; }
20  void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
22  auto traits = light::LightTraits();
23  if (this->color_interlock_) {
24  traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLD_WARM_WHITE});
25  } else {
26  traits.set_supported_color_modes({light::ColorMode::RGB_COLD_WARM_WHITE});
27  }
28  traits.set_min_mireds(this->cold_white_temperature_);
29  traits.set_max_mireds(this->warm_white_temperature_);
30  return traits;
31  }
33  float red, green, blue, cwhite, wwhite;
34  state->current_values_as_rgbww(&red, &green, &blue, &cwhite, &wwhite, this->constant_brightness_);
35  this->red_->set_level(red);
36  this->green_->set_level(green);
37  this->blue_->set_level(blue);
38  this->cold_white_->set_level(cwhite);
39  this->warm_white_->set_level(wwhite);
40  }
41 
42  protected:
51  bool color_interlock_{false};
52 };
53 
54 } // namespace rgbww
55 } // namespace esphome
void current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white, bool constant_brightness=false)
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:34
Interface to write LightStates to hardware.
Definition: light_output.h:12
void set_red(output::FloatOutput *red)
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
void set_blue(output::FloatOutput *blue)
void set_warm_white(output::FloatOutput *warm_white)
void set_constant_brightness(bool constant_brightness)
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void set_cold_white(output::FloatOutput *cold_white)
RGB color output, and separate cold and warm white outputs.
light::LightTraits get_traits() override
Brightness of cold and warm white output can be controlled.
void set_warm_white_temperature(float warm_white_temperature)
void set_green(output::FloatOutput *green)
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
void write_state(light::LightState *state) override
void set_cold_white_temperature(float cold_white_temperature)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Color can be controlled using RGB format (includes a brightness control for the color).
void set_color_interlock(bool color_interlock)
bool state
Definition: fan.h:34