mirror of
https://github.com/esphome/esphome.git
synced 2024-11-17 10:55:36 +01:00
Apply color brightness to addressable light effects (#2321)
This commit is contained in:
parent
e3ffecefc0
commit
d180aee57f
@ -27,7 +27,7 @@ std::unique_ptr<LightTransformer> AddressableLight::create_default_transition()
|
||||
return make_unique<AddressableLightTransformer>(*this);
|
||||
}
|
||||
|
||||
Color esp_color_from_light_color_values(LightColorValues val) {
|
||||
Color color_from_light_color_values(LightColorValues val) {
|
||||
auto r = to_uint8_scale(val.get_color_brightness() * val.get_red());
|
||||
auto g = to_uint8_scale(val.get_color_brightness() * val.get_green());
|
||||
auto b = to_uint8_scale(val.get_color_brightness() * val.get_blue());
|
||||
@ -44,7 +44,7 @@ void AddressableLight::update_state(LightState *state) {
|
||||
return;
|
||||
|
||||
// don't use LightState helper, gamma correction+brightness is handled by ESPColorView
|
||||
this->all() = esp_color_from_light_color_values(val);
|
||||
this->all() = color_from_light_color_values(val);
|
||||
this->schedule_show();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void AddressableLightTransformer::start() {
|
||||
return;
|
||||
|
||||
auto end_values = this->target_values_;
|
||||
this->target_color_ = esp_color_from_light_color_values(end_values);
|
||||
this->target_color_ = color_from_light_color_values(end_values);
|
||||
|
||||
// our transition will handle brightness, disable brightness in correction.
|
||||
this->light_.correction_.set_local_brightness(255);
|
||||
|
@ -19,6 +19,9 @@ namespace light {
|
||||
|
||||
using ESPColor ESPDEPRECATED("esphome::light::ESPColor is deprecated, use esphome::Color instead.", "v1.21") = Color;
|
||||
|
||||
/// Convert the color information from a `LightColorValues` object to a `Color` object (does not apply brightness).
|
||||
Color color_from_light_color_values(LightColorValues val);
|
||||
|
||||
class AddressableLight : public LightOutput, public Component {
|
||||
public:
|
||||
virtual int32_t size() const = 0;
|
||||
|
@ -38,11 +38,8 @@ class AddressableLightEffect : public LightEffect {
|
||||
void stop() override { this->get_addressable_()->set_effect_active(false); }
|
||||
virtual void apply(AddressableLight &it, const Color ¤t_color) = 0;
|
||||
void apply() override {
|
||||
LightColorValues color = this->state_->remote_values;
|
||||
// not using any color correction etc. that will be handled by the addressable layer
|
||||
Color current_color =
|
||||
Color(static_cast<uint8_t>(color.get_red() * 255), static_cast<uint8_t>(color.get_green() * 255),
|
||||
static_cast<uint8_t>(color.get_blue() * 255), static_cast<uint8_t>(color.get_white() * 255));
|
||||
// not using any color correction etc. that will be handled by the addressable layer through ESPColorCorrection
|
||||
Color current_color = color_from_light_color_values(this->state_->remote_values);
|
||||
this->apply(*this->get_addressable_(), current_color);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user