esphome/esphome/components/rgbw/rgbw_light_output.h
peq123 e5d4e12457
RGBWW - added channel interlock for RGB vs white (#1042)
* Update light_color_values.h

* Update light_color_values.h

* Update light_color_values.h

* Update light_color_values.h

* colour relative to white value

* Update light_state.cpp

* Update light_state.cpp

* Update light_state.cpp

* Update light_state.cpp

* Update light_color_values.h

* Update light_state.cpp

* linting

* Update light_state.cpp

* Update light_color_values.h

* more lint

* more lint

* Update light_state.cpp

* Update light_state.cpp

* Update light_state.cpp

* add optional interlock

* Update test1.yaml

* Update light_state.cpp

* Update light_state.h

* interlock

* optional interlock.

* interlock as trait

* color interlock as trait

* optional color interlock....

* optional color interlock

* Update light_color_values.h

* Lint checks....

* making travis happy

* making sure gamma_correct fix is included

* Update light_color_values.h

* making travis happy

* clang-format

* Code tidy

* Update light_color_values.h

* Update light_color_values.h
2020-07-09 20:29:44 -03:00

43 lines
1.4 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/output/float_output.h"
#include "esphome/components/light/light_output.h"
namespace esphome {
namespace rgbw {
class RGBWLightOutput : public light::LightOutput {
public:
void set_red(output::FloatOutput *red) { red_ = red; }
void set_green(output::FloatOutput *green) { green_ = green; }
void set_blue(output::FloatOutput *blue) { blue_ = blue; }
void set_white(output::FloatOutput *white) { white_ = white; }
void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
light::LightTraits get_traits() override {
auto traits = light::LightTraits();
traits.set_supports_brightness(true);
traits.set_supports_color_interlock(this->color_interlock_);
traits.set_supports_rgb(true);
traits.set_supports_rgb_white_value(true);
return traits;
}
void write_state(light::LightState *state) override {
float red, green, blue, white;
state->current_values_as_rgbw(&red, &green, &blue, &white, this->color_interlock_);
this->red_->set_level(red);
this->green_->set_level(green);
this->blue_->set_level(blue);
this->white_->set_level(white);
}
protected:
output::FloatOutput *red_;
output::FloatOutput *green_;
output::FloatOutput *blue_;
output::FloatOutput *white_;
bool color_interlock_{false};
};
} // namespace rgbw
} // namespace esphome