Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong setting of free_range after reset or restart (#8120) #8253

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tasmota/xdrv_04_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ class LightStateClass {
void setCW(uint8_t c, uint8_t w, bool free_range = false) {
uint16_t max = (w > c) ? w : c; // 0..255
uint16_t sum = c + w;
if (sum <= 257) { free_range = false; } // if we don't allow free range or if sum is below 255 (with tolerance of 2)

if (0 == max) {
_briCT = 0; // brightness set to null
Expand Down Expand Up @@ -721,6 +722,8 @@ class LightStateClass {
AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels (%d %d %d %d %d)",
channels[0], channels[1], channels[2], channels[3], channels[4]);
AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels CT (%d) briRGB (%d) briCT (%d)", _ct, _briRGB, _briCT);
AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels Actuals (%d %d %d %d %d)",
_r, _g, _b, _wc, _ww);
#endif
}

Expand Down Expand Up @@ -975,6 +978,9 @@ public:
(DEFAULT_LIGHT_COMPONENT == Settings.light_color[3]) &&
(DEFAULT_LIGHT_COMPONENT == Settings.light_color[4]) &&
(DEFAULT_LIGHT_DIMMER == Settings.light_dimmer) ) {
if ((LST_COLDWARM == Light.subtype) || (LST_RGBCW == Light.subtype)) {
_state->setCW(255, 0); // avoid having both white channels at 100%, zero second channel (#see 8120)
}
_state->setBriCT(bri);
_state->setBriRGB(bri);
_state->setColorMode(LCM_RGB);
Expand Down