From 57e62b1e68a337ae78a6a1543e242cfec0bcccc5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 2 Nov 2019 13:25:23 +0100 Subject: [PATCH] Bump version 7.0.0.2 Add command WebColor19 to control color of Module and Name (#6811) --- tasmota/_changelog.ino | 3 +++ tasmota/settings.h | 11 +++++++---- tasmota/settings.ino | 4 ++++ tasmota/support.ino | 25 +++++++++++++++++++++---- tasmota/tasmota_version.h | 2 +- tasmota/xdrv_01_webserver.ino | 2 +- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/tasmota/_changelog.ino b/tasmota/_changelog.ino index 055d01a52..f609f4c89 100644 --- a/tasmota/_changelog.ino +++ b/tasmota/_changelog.ino @@ -1,4 +1,7 @@ /*********************************************************************************************\ + * 7.0.0.2 20191102 + * Add command WebColor19 to control color of Module and Name (#6811) + * * 7.0.0.1 20191027 * Remove references to versions before 6.0 * Change default GUI to dark theme diff --git a/tasmota/settings.h b/tasmota/settings.h index 4f95e62b9..1eed62771 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -432,10 +432,13 @@ struct SYSCFG { uint16_t dimmer_hw_max; // E92 uint32_t deepsleep; // E94 uint16_t energy_power_delta; // E98 - uint8_t shutter_motordelay[MAX_SHUTTERS]; // E9A - uint8_t free_e9e[342]; // E9E - uint8_t web_color2[1][3]; // FF4 - uint8_t free_ff7 ; // FF7 + uint8_t shutter_motordelay[MAX_SHUTTERS]; // E9A + + uint8_t free_e9e[2]; // E9E + + uint8_t web_color2[2][3]; // EA0 - Needs to be on integer distance / 3 from web_color + + uint8_t free_ea4[338]; // EA6 uint32_t cfg_timestamp; // FF8 uint32_t cfg_crc32; // FFC diff --git a/tasmota/settings.ino b/tasmota/settings.ino index a9f686e50..b3baee256 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -1115,6 +1115,10 @@ void SettingsDelta(void) } } + if (Settings.version < 0x07000002) { + char scolor[10]; + WebHexCode(18, GetTextIndexed(scolor, sizeof(scolor), 18, kWebColors)); + } Settings.version = VERSION; SettingsSave(1); } diff --git a/tasmota/support.ino b/tasmota/support.ino index 51147f502..2358d7f34 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -883,8 +883,9 @@ void WebHexCode(uint32_t i, const char* code) color = w | (w << 4); // 00112233 } */ - uint32_t j = sizeof(Settings.web_color)/3; // First area contains j=18 colors - if (i < j) { + uint32_t j = sizeof(Settings.web_color) / 3; // First area contains j = 18 colors +/* + if (i < j) { Settings.web_color[i][0] = (color >> 16) & 0xFF; // Red Settings.web_color[i][1] = (color >> 8) & 0xFF; // Green Settings.web_color[i][2] = color & 0xFF; // Blue @@ -892,14 +893,30 @@ void WebHexCode(uint32_t i, const char* code) Settings.web_color2[i-j][0] = (color >> 16) & 0xFF; // Red Settings.web_color2[i-j][1] = (color >> 8) & 0xFF; // Green Settings.web_color2[i-j][2] = color & 0xFF; // Blue - } + } +*/ + if (i >= j) { + // Calculate i to index in Settings.web_color2 - Dirty(!) but saves 128 bytes code + i += ((((uint8_t*)&Settings.web_color2 - (uint8_t*)&Settings.web_color) / 3) - j); + } + Settings.web_color[i][0] = (color >> 16) & 0xFF; // Red + Settings.web_color[i][1] = (color >> 8) & 0xFF; // Green + Settings.web_color[i][2] = color & 0xFF; // Blue } uint32_t WebColor(uint32_t i) { - uint32_t j = sizeof(Settings.web_color)/3; // First area contains j=18 colors + uint32_t j = sizeof(Settings.web_color) / 3; // First area contains j = 18 colors +/* uint32_t tcolor = (i= j) { + // Calculate i to index in Settings.web_color2 - Dirty(!) but saves 128 bytes code + i += ((((uint8_t*)&Settings.web_color2 - (uint8_t*)&Settings.web_color) / 3) - j); + } + uint32_t tcolor = (Settings.web_color[i][0] << 16) | (Settings.web_color[i][1] << 8) | Settings.web_color[i][2]; + return tcolor; } diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index 12fa83147..892ebeba7 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x07000001; +const uint32_t VERSION = 0x07000002; #endif // _TASMOTA_VERSION_H_ diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 0b2f1fdb3..c4e647d66 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2579,7 +2579,7 @@ bool JsonWebColor(const char* dataBuf) // Default (light) // {"WebColor":["#000000","#ffffff","#f2f2f2","#000000","#ffffff","#000000","#ffffff","#ff0000","#008000","#ffffff","#1fa3ec","#0e70a4","#d43535","#931f1f","#47c266","#5aaf6f","#ffffff","#999999","#000000"]} // Alternative (Dark) - // {"webcolor":["#eeeeee","#181818","#4f4f4f","#000000","#dddddd","#008000","#222222","#ff0000","#008000","#ffffff","#1fa3ec","#0e70a4","#d43535","#931f1f","#47c266","#5aaf6f","#ffffff","#999999","#000000"]} + // {"Webcolor":["#eeeeee","#181818","#4f4f4f","#000000","#dddddd","#6a9955","#1e1e1e","#ff0000","#008000","#ffffff","#1fa3ec","#0e70a4","#d43535","#931f1f","#47c266","#5aaf6f","#ffffff","#999999","#eeeeee"]} char dataBufLc[strlen(dataBuf) +1]; LowerCase(dataBufLc, dataBuf);