From 9e1352f5ef841200374beae4d53825f0f331814b Mon Sep 17 00:00:00 2001 From: Niklas Wagner Date: Thu, 5 Apr 2018 19:00:56 +0200 Subject: [PATCH] Fix color Restore functions --- code/espurna/light.ino | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 7c8e82d4..4f16ec44 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -474,8 +474,16 @@ void _lightProviderUpdate() { // ----------------------------------------------------------------------------- void _lightColorSave() { + + //TODO: Remove this once this code was in a stable release + // This force set ch3 to 0 which could be not zero when you update from a old version + if (_light_use_white) { + setSetting("ch", 3, 0); + } + for (unsigned int i=0; i < _light_channel.size(); i++) { - setSetting("ch", i, _light_channel[i].value); + if (_light_use_white && (i == 3)) continue; //Don't save white channel. + setSetting("ch", i, _getChannel(i)); } setSetting("brightness", _light_brightness); saveSettings(); @@ -485,6 +493,8 @@ void _lightColorRestore() { for (unsigned int i=0; i < _light_channel.size(); i++) { _light_channel[i].value = getSetting("ch", i, i==0 ? 255 : 0).toInt(); } + _setWhite(); + _light_brightness = getSetting("brightness", LIGHT_MAX_BRIGHTNESS).toInt(); lightUpdate(false, false); } @@ -1079,8 +1089,8 @@ void lightSetup() { DEBUG_MSG_P(PSTR("[LIGHT] LIGHT_PROVIDER = %d\n"), LIGHT_PROVIDER); DEBUG_MSG_P(PSTR("[LIGHT] Number of channels: %d\n"), _light_channel.size()); - _lightColorRestore(); _lightConfigure(); + _lightColorRestore(); #if WEB_SUPPORT _lightAPISetup();