ESPHome  2024.3.1
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  return traits;
24  }
26  float red, green, blue, white;
27  state->current_values_as_rgbw(&red, &green, &blue, &white, this->color_interlock_);
28  this->red_->set_level(red);
29  this->green_->set_level(green);
30  this->blue_->set_level(blue);
31  this->white_->set_level(white);
32  }
33 
34  protected:
39  bool color_interlock_{false};
40 };
41 
42 } // namespace rgbw
43 } // 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)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
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