diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 2090f4793..bc161c078 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -317,6 +317,7 @@ #define D_CMND_LEDTABLE "LedTable" #define D_CMND_FADE "Fade" #define D_CMND_PIXELS "Pixels" +#define D_CMND_RGBWWTABLE "RGBWWTable" #define D_CMND_ROTATION "Rotation" #define D_CMND_SCHEME "Scheme" #define D_CMND_SPEED "Speed" diff --git a/sonoff/settings.h b/sonoff/settings.h index bf862dd51..978b72b24 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -322,7 +322,9 @@ struct SYSCFG { uint16_t mcp230xx_int_timer; // 718 - byte free_71A[174]; // 71A + uint8_t rgbwwTable[5]; // 71A + + byte free_71F[169]; // 71F unsigned long energy_frequency_calibration; // 7C8 diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 95e6ce367..4116a1c6d 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -624,6 +624,10 @@ void SettingsDefaultSet2() Settings.button_debounce = KEY_DEBOUNCE_TIME; Settings.switch_debounce = SWITCH_DEBOUNCE_TIME; + + for (byte j = 0; j < 5; j++) { + Settings.rgbwwTable[j] = 255; + } } /********************************************************************************************/ @@ -827,6 +831,11 @@ void SettingsDelta() Settings.button_debounce = KEY_DEBOUNCE_TIME; Settings.switch_debounce = SWITCH_DEBOUNCE_TIME; } + if (Settings.version < 0x0602010A) { + for (byte j = 0; j < 5; j++) { + Settings.rgbwwTable[j] = 255; + } + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 4f2b5c0ec..c5765ec38 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x06020109 +#define VERSION 0x0602010A #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index 2a5a15b0c..6c8aa938d 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -55,11 +55,11 @@ enum LightCommands { CMND_COLOR, CMND_COLORTEMPERATURE, CMND_DIMMER, CMND_LED, CMND_LEDTABLE, CMND_FADE, - CMND_PIXELS, CMND_ROTATION, CMND_SCHEME, CMND_SPEED, CMND_WAKEUP, CMND_WAKEUPDURATION, + CMND_PIXELS, CMND_RGBWWTABLE, CMND_ROTATION, CMND_SCHEME, CMND_SPEED, CMND_WAKEUP, CMND_WAKEUPDURATION, CMND_WIDTH, CMND_CHANNEL, CMND_HSBCOLOR, CMND_UNDOCA }; const char kLightCommands[] PROGMEM = D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_LED "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|" - D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|" + D_CMND_PIXELS "|" D_CMND_RGBWWTABLE "|" D_CMND_ROTATION "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|" D_CMND_WIDTH "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR "|UNDOCA" ; struct LRgbColor { @@ -799,7 +799,8 @@ void LightAnimate() light_update = 0; for (byte i = 0; i < light_subtype; i++) { light_last_color[i] = light_new_color[i]; - cur_col[i] = (Settings.light_correction) ? ledTable[light_last_color[i]] : light_last_color[i]; + cur_col[i] = light_last_color[i]*Settings.rgbwwTable[i]/255; + cur_col[i] = (Settings.light_correction) ? ledTable[cur_col[i]] : cur_col[i]; if (light_type < LT_PWM6) { if (pin[GPIO_PWM1 +i] < 99) { if (cur_col[i] > 0xFC) { @@ -1279,6 +1280,33 @@ boolean LightCommand() } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, GetStateText(Settings.light_correction)); } + else if (CMND_RGBWWTABLE == command_code) { + bool validtable = (XdrvMailbox.data_len > 0); + char scolor[25]; + if (validtable) { + uint16_t HSB[3]; + if (strstr(XdrvMailbox.data, ",")) { // Command with up to 5 comma separated parameters + for (int i = 0; i < LST_RGBWC; i++) { + char *substr; + + if (0 == i) { + substr = strtok(XdrvMailbox.data, ","); + } else { + substr = strtok(NULL, ","); + } + if (substr != NULL) { + Settings.rgbwwTable[i] = atoi(substr); + } + } + } + light_update = 1; + } + scolor[0] = '\0'; + for (byte i = 0; i < LST_RGBWC; i++) { + snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", Settings.rgbwwTable[i]); + } + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, scolor); + } else if (CMND_FADE == command_code) { switch (XdrvMailbox.payload) { case 0: // Off