Fix esphome/issues#947 - RGBW(W) white brightness (#925)

This commit is contained in:
Paul Nicholls 2020-03-12 13:17:29 +13:00 committed by GitHub
parent 854d735ab3
commit 11069085e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -185,7 +185,7 @@ class LightColorValues {
/// Convert these light color values to an RGBW representation and write them to red, green, blue, white.
void as_rgbw(float *red, float *green, float *blue, float *white) const {
this->as_rgb(red, green, blue);
*white = this->state_ * this->white_;
*white = this->state_ * this->brightness_ * this->white_;
}
/// Convert these light color values to an RGBWW representation with the given parameters.
@ -196,8 +196,8 @@ class LightColorValues {
const float ww_fraction = (color_temp - color_temperature_cw) / (color_temperature_ww - color_temperature_cw);
const float cw_fraction = 1.0f - ww_fraction;
const float max_cw_ww = std::max(ww_fraction, cw_fraction);
*cold_white = this->state_ * this->white_ * (cw_fraction / max_cw_ww);
*warm_white = this->state_ * this->white_ * (ww_fraction / max_cw_ww);
*cold_white = this->state_ * this->brightness_ * this->white_ * (cw_fraction / max_cw_ww);
*warm_white = this->state_ * this->brightness_ * this->white_ * (ww_fraction / max_cw_ww);
}
/// Convert these light color values to an CWWW representation with the given parameters.