ESPHome  2022.6.3
rgb_light_output.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace rgb {
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 
17  auto traits = light::LightTraits();
18  traits.set_supported_color_modes({light::ColorMode::RGB});
19  return traits;
20  }
22  float red, green, blue;
23  state->current_values_as_rgb(&red, &green, &blue, false);
24  this->red_->set_level(red);
25  this->green_->set_level(green);
26  this->blue_->set_level(blue);
27  }
28 
29  protected:
33 };
34 
35 } // namespace rgb
36 } // namespace esphome
output::FloatOutput * green_
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:32
output::FloatOutput * red_
Interface to write LightStates to hardware.
Definition: light_output.h:12
void write_state(light::LightState *state) override
light::LightTraits get_traits() override
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
void set_red(output::FloatOutput *red)
void set_blue(output::FloatOutput *blue)
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void current_values_as_rgb(float *red, float *green, float *blue, bool color_interlock=false)
output::FloatOutput * blue_
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
Definition: a4988.cpp:4
Color can be controlled using RGB format (includes a brightness control for the color).
bool state
Definition: fan.h:34