1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-27 21:23:48 +00:00

Add constant_brightness property to CWWW/RGBWW lights (#1007)

Fixes https://github.com/esphome/feature-requests/issues/460

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
kroimon
2020-04-08 14:31:23 +02:00
committed by GitHub
parent dea6675c21
commit 8613c02d5c
8 changed files with 41 additions and 16 deletions

View File

@@ -718,19 +718,21 @@ void LightState::current_values_as_rgbw(float *red, float *green, float *blue, f
*blue = gamma_correct(*blue, this->gamma_correct_);
*white = gamma_correct(*white, this->gamma_correct_);
}
void LightState::current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white) {
void LightState::current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white,
bool constant_brightness) {
auto traits = this->get_traits();
this->current_values.as_rgbww(traits.get_min_mireds(), traits.get_max_mireds(), red, green, blue, cold_white,
warm_white);
warm_white, constant_brightness);
*red = gamma_correct(*red, this->gamma_correct_);
*green = gamma_correct(*green, this->gamma_correct_);
*blue = gamma_correct(*blue, this->gamma_correct_);
*cold_white = gamma_correct(*cold_white, this->gamma_correct_);
*warm_white = gamma_correct(*warm_white, this->gamma_correct_);
}
void LightState::current_values_as_cwww(float *cold_white, float *warm_white) {
void LightState::current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness) {
auto traits = this->get_traits();
this->current_values.as_cwww(traits.get_min_mireds(), traits.get_max_mireds(), cold_white, warm_white);
this->current_values.as_cwww(traits.get_min_mireds(), traits.get_max_mireds(), cold_white, warm_white,
constant_brightness);
*cold_white = gamma_correct(*cold_white, this->gamma_correct_);
*warm_white = gamma_correct(*warm_white, this->gamma_correct_);
}