ESPHome  2024.10.2
rgbw_light_output.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace rgbw {
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_white(output::FloatOutput *white) { white_ = white; }
16  void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
18  auto traits = light::LightTraits();
19  if (this->color_interlock_) {
20  traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
21  } else {
22  traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
23  }
24  return traits;
25  }
27  float red, green, blue, white;
28  state->current_values_as_rgbw(&red, &green, &blue, &white, this->color_interlock_);
29  this->red_->set_level(red);
30  this->green_->set_level(green);
31  this->blue_->set_level(blue);
32  this->white_->set_level(white);
33  }
34 
35  protected:
40  bool color_interlock_{false};
41 };
42 
43 } // namespace rgbw
44 } // namespace esphome
void set_green(output::FloatOutput *green)
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 write_state(light::LightState *state) override
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
RGB color output and a separate white output.
output::FloatOutput * white_
void set_red(output::FloatOutput *red)
void set_level(float state)
Set the level of this float output, this is called from the front-end.
output::FloatOutput * green_
White output only (use only if the light also has another color mode such as RGB).
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
void set_color_interlock(bool color_interlock)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
light::LightTraits get_traits() override
Color can be controlled using RGB format (includes a brightness control for the color).
void set_blue(output::FloatOutput *blue)
void set_white(output::FloatOutput *white)
void current_values_as_rgbw(float *red, float *green, float *blue, float *white, bool color_interlock=false)
bool state
Definition: fan.h:34