Fix RGBW color-interlock control (#1325)

This commit is contained in:
Marvin Gaube 2020-10-15 14:48:12 +02:00 committed by Guillermo Ruffino
parent 540c62061d
commit 2c71ee7853

View File

@ -399,13 +399,13 @@ LightColorValues LightCall::validate_() {
// sets RGB to 100% if only White specified // sets RGB to 100% if only White specified
if (this->white_.has_value()) { if (this->white_.has_value()) {
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
this->red_ = optional<float>(1.0f);
this->green_ = optional<float>(1.0f);
this->blue_ = optional<float>(1.0f);
}
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
if (traits.get_supports_color_interlock()) { if (traits.get_supports_color_interlock()) {
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
this->red_ = optional<float>(1.0f);
this->green_ = optional<float>(1.0f);
this->blue_ = optional<float>(1.0f);
}
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
if (*this->white_ > 0.0f) { if (*this->white_ > 0.0f) {
this->white_ = optional<float>(1.0f); this->white_ = optional<float>(1.0f);
} else { } else {
@ -415,11 +415,13 @@ LightColorValues LightCall::validate_() {
} }
// White to 0% if (exclusively) setting any RGB value that isn't 255,255,255 // White to 0% if (exclusively) setting any RGB value that isn't 255,255,255
else if (this->red_.has_value() || this->green_.has_value() || this->blue_.has_value()) { else if (this->red_.has_value() || this->green_.has_value() || this->blue_.has_value()) {
if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f && traits.get_supports_rgb_white_value() && if (traits.get_supports_color_interlock()) {
traits.get_supports_color_interlock()) { if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f &&
this->white_ = optional<float>(1.0f); traits.get_supports_rgb_white_value() && traits.get_supports_color_interlock()) {
} else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) { this->white_ = optional<float>(1.0f);
this->white_ = optional<float>(0.0f); } else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) {
this->white_ = optional<float>(0.0f);
}
} }
} }
// if changing Kelvin alone, change to white light // if changing Kelvin alone, change to white light