Skip to content

Commit

Permalink
Fix wrong setting of free_range after reset or restart (arendst#8120)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger committed Apr 22, 2020
1 parent 14e19b7 commit a948a8f
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit a948a8f

Please sign in to comment.