From d412c8db5e6033383e264c77abb0843536a9ce95 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 12 Apr 2020 14:32:42 +0200 Subject: [PATCH 01/35] Remove entrys from platformio_override_esp32.ini since the are now supported or not used --- platformio_override_esp32.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini index 47338bd60..60546b094 100644 --- a/platformio_override_esp32.ini +++ b/platformio_override_esp32.ini @@ -100,9 +100,7 @@ lib_extra_dirs = lib_ignore = ESP MQTT - TasmotaMqtt ILI9488 - RA8876 SSD3115 cc1101 FrogmoreScd30 From 274bab2e8156fff5c90373a1291ad913384f1a56 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 12 Apr 2020 14:44:20 +0200 Subject: [PATCH 02/35] Update platformio_override_esp32.ini --- platformio_override_esp32.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini index 60546b094..7f7e18605 100644 --- a/platformio_override_esp32.ini +++ b/platformio_override_esp32.ini @@ -99,9 +99,8 @@ lib_extra_dirs = libesp32 lib_ignore = - ESP MQTT ILI9488 SSD3115 cc1101 - FrogmoreScd30 + FrogmoreScd30 ArduinoNTPd From 471b50446bbf463ba03b73cd1e3011184bf3bfeb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 12 Apr 2020 14:51:58 +0200 Subject: [PATCH 03/35] Update platformio_override_esp32.ini --- platformio_override_esp32.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini index 7f7e18605..5c4afdafa 100644 --- a/platformio_override_esp32.ini +++ b/platformio_override_esp32.ini @@ -102,5 +102,4 @@ lib_ignore = ILI9488 SSD3115 cc1101 - FrogmoreScd30 ArduinoNTPd From 3e517ce9b7f63e00457487b91da6b588f1ab0a8e Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 12 Apr 2020 15:01:45 +0200 Subject: [PATCH 04/35] - Fix prevent multiple pings to run concurrently --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_38_ping.ino | 120 +++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 0bc6a5c85..5098db14f 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -27,6 +27,7 @@ - Add support for an iAQ sensor (#8107) - Add support for Seven Segment display using HT16K33 (#8116) - Add support for AS3935 Lightning Sensor by device111 (#8130) +- Fix prevent multiple pings to run concurrently ### 8.2.0.2 20200328 diff --git a/tasmota/xdrv_38_ping.ino b/tasmota/xdrv_38_ping.ino index c783f3ee9..0156314a7 100644 --- a/tasmota/xdrv_38_ping.ino +++ b/tasmota/xdrv_38_ping.ino @@ -22,7 +22,6 @@ #define XDRV_38 38 #include -#include const char kPingCommands[] PROGMEM = "|" // no prefix D_CMND_PING @@ -35,80 +34,77 @@ void (* const PingCommand[])(void) PROGMEM = { // inspired by https://github.com/dancol90/ESP8266Ping typedef struct Ping_t { - ping_option opt; // extend the ping_option structure with internal values uint16_t total_count; // total count if packets sent uint16_t timeout_count; // time-outs (no responses) uint32_t min_time; // minimum time in ms for a successful response uint32_t max_time; // maximum time in ms for a successful response uint32_t sum_time; // cumulated time in ms for all successful responses (used to compute the average) + bool busy; // is ping on-going bool done; // indicates the ping campaign is finished } Ping_t; -std::vector pings = {}; +ping_option ping_opt; +Ping_t ping; extern "C" { // callbacks for ping // called after a ping response is received or time-out - void ICACHE_RAM_ATTR ping_recv_cb(Ping_t *ping, struct ping_resp *p_resp) { + void ICACHE_RAM_ATTR ping_recv_cb(ping_option *popt, struct ping_resp *p_resp) { // If successful if (p_resp->ping_err >= 0) { uint32_t resp_time = p_resp->resp_time; - ping->sum_time += resp_time; - if (resp_time < ping->min_time) { ping->min_time = resp_time; } - if (resp_time > ping->max_time) { ping->max_time = resp_time; } + ping.sum_time += resp_time; + if (resp_time < ping.min_time) { ping.min_time = resp_time; } + if (resp_time > ping.max_time) { ping.max_time = resp_time; } } } // called after the ping campaign is finished - void ICACHE_RAM_ATTR ping_sent_cb(Ping_t *ping, struct ping_resp *p_resp) { + void ICACHE_RAM_ATTR ping_sent_cb(ping_option *popt, struct ping_resp *p_resp) { // copy counters to build the MQTT response - ping->total_count = p_resp->total_count; - ping->timeout_count = p_resp->timeout_count; - ping->done = true; + ping.total_count = p_resp->total_count; + ping.timeout_count = p_resp->timeout_count; + ping.done = true; } } // Check if any ping requests is completed, and publish the results void PingResponsePoll(void) { - for (auto it = pings.begin(); it != pings.end(); it++) { - Ping_t *ping = *it; - if (ping->done) { - uint32_t success = ping->total_count - ping->timeout_count; - uint32_t ip = ping->opt.ip; + if (ping.done) { + uint32_t success = ping.total_count - ping.timeout_count; + uint32_t ip = ping_opt.ip; - // Serial.printf( - // "DEBUG ping_sent_cb: ping reply\n" - // "\tsuccess_count = %d \n" - // "\ttimeout_count = %d \n" - // "\tmin_time = %d \n" - // "\tmax_time = %d \n" - // "\tavg_time = %d \n", - // success, ping->timeout_count, - // ping->min_time, ping->max_time, - // success ? ping->sum_time / success : 0 - // ); + // Serial.printf( + // "DEBUG ping_sent_cb: ping reply\n" + // "\tsuccess_count = %d \n" + // "\ttimeout_count = %d \n" + // "\tmin_time = %d \n" + // "\tmax_time = %d \n" + // "\tavg_time = %d \n", + // success, ping.timeout_count, + // ping.min_time, ping.max_time, + // success ? ping.sum_time / success : 0 + // ); - Response_P(PSTR("{\"" D_JSON_PING "\":{\"%d.%d.%d.%d\":{" - "\"Reachable\":%s" - ",\"Success\":%d" - ",\"Timeout\":%d" - ",\"MinTime\":%d" - ",\"MaxTime\":%d" - ",\"AvgTime\":%d" - "}}}"), - ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24, - success ? "true" : "false", - success, ping->timeout_count, - ping->min_time, ping->max_time, - success ? ping->sum_time / success : 0 - ); - MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_PING)); - XdrvRulesProcess(); - - pings.erase(it--); // remove from list - delete ping; // free memory allocated - } + Response_P(PSTR("{\"" D_JSON_PING "\":{\"%d.%d.%d.%d\":{" + "\"Reachable\":%s" + ",\"Success\":%d" + ",\"Timeout\":%d" + ",\"MinTime\":%d" + ",\"MaxTime\":%d" + ",\"AvgTime\":%d" + "}}}"), + ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24, + success ? "true" : "false", + success, ping.timeout_count, + ping.min_time, ping.max_time, + success ? ping.sum_time / success : 0 + ); + MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_PING)); + XdrvRulesProcess(); + ping.done = false; + ping.busy = false; } } @@ -117,28 +113,32 @@ void CmndPing(void) { IPAddress ip; RemoveSpace(XdrvMailbox.data); - if (count > 60) { count = 60; } + if (count > 8) { count = 8; } + + if (ping.busy) { + ResponseCmndChar_P(PSTR("Ping busy")); + return; + } if (WiFi.hostByName(XdrvMailbox.data, ip)) { - Ping_t *ping = new Ping_t(); - memset(ping, 0, sizeof(Ping_t )); - ping->min_time = UINT32_MAX; + memset(&ping_opt, 0, sizeof(ping_opt)); + memset(&ping, 0, sizeof(ping)); + ping.min_time = UINT32_MAX; - ping_option &opt = ping->opt; - opt.count = count; - opt.coarse_time = 1; // wait 1 second between messages - opt.ip = ip; + ping_opt.count = count; + ping_opt.coarse_time = 1; // wait 1 second between messages + ping_opt.ip = ip; // callbacks - opt.recv_function = (ping_recv_function) ping_recv_cb; // at each response or time-out - opt.sent_function = (ping_sent_function) ping_sent_cb; // when all packets have been sent and reveived + ping_opt.recv_function = (ping_recv_function) ping_recv_cb; // at each response or time-out + ping_opt.sent_function = (ping_sent_function) ping_sent_cb; // when all packets have been sent and reveived - if (ping_start(&opt)) { - pings.push_back(ping); + ping.busy = true; + if (ping_start(&ping_opt)) { ResponseCmndDone(); } else { ResponseCmndChar_P(PSTR("Unable to send Ping")); - delete ping; + ping.busy = false; } } else { ResponseCmndChar_P(PSTR("Unable to resolve IP address")); From ad1054a6aeece4e3d21013f1763bf857daaebd6d Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 12 Apr 2020 18:17:35 +0200 Subject: [PATCH 05/35] Increase ESP32 compatibility Increase ESP32 compatibility (breaks current ESP32 configuration!) --- tasmota/support.ino | 14 ++++++++++- tasmota/support_command.ino | 5 ++++ tasmota/tasmota_template.h | 12 ++++++--- tasmota/tasmota_template_ESP32.h | 24 +++++++++--------- tasmota/xdrv_01_webserver.ino | 43 ++++++++++++++++++++++++-------- 5 files changed, 71 insertions(+), 27 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index f6ee1b059..9ac48c3fc 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1127,8 +1127,13 @@ void ModuleGpios(myio *gp) uint32_t j = 0; for (uint32_t i = 0; i < sizeof(mycfgio); i++) { +#ifdef ESP8266 if (6 == i) { j = 9; } if (8 == i) { j = 12; } +#endif // ESP8266 +#ifdef ESP32 + if (6 == i) { j = 12; } +#endif // ESP32 dest[j] = src[i]; j++; } @@ -1166,7 +1171,12 @@ void SetModuleType(void) bool FlashPin(uint32_t pin) { +#ifdef ESP8266 return (((pin > 5) && (pin < 9)) || (11 == pin)); +#endif // ESP8266 +#ifdef ESP32 + return ((pin > 5) && (pin < 12)); +#endif // ESP32 } uint8_t ValidPin(uint32_t pin, uint32_t gpio) @@ -1175,12 +1185,14 @@ uint8_t ValidPin(uint32_t pin, uint32_t gpio) return GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11 } +#ifdef ESP8266 // if (!is_8285 && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's if ((WEMOS == Settings.module) && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's if ((pin == 9) || (pin == 10)) { return GPIO_NONE; // Disable possible flash GPIO9 and GPIO10 } } +#endif // ESP8266 return gpio; } @@ -1264,7 +1276,7 @@ bool JsonTemplate(const char* dataBuf) if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks - StaticJsonBuffer<400> jb; // 331 from https://arduinojson.org/v5/assistant/ + StaticJsonBuffer<600> jb; // 331 from https://arduinojson.org/v5/assistant/ JsonObject& obj = jb.parseObject(dataBuf); if (!obj.success()) { return false; } diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 133298010..41a237802 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1087,8 +1087,13 @@ void CmndTemplate(void) SettingsUpdateText(SET_TEMPLATE_NAME, "Merged"); uint32_t j = 0; for (uint32_t i = 0; i < sizeof(mycfgio); i++) { +#ifdef ESP8266 if (6 == i) { j = 9; } if (8 == i) { j = 12; } +#endif // ESP8266 +#ifdef ESP32 + if (6 == i) { j = 12; } +#endif // ESP32 if (my_module.io[j] > GPIO_NONE) { Settings.user_template.gp.io[i] = my_module.io[j]; } diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 6ab153508..f235147bf 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -703,6 +703,8 @@ const char kAdc0Names[] PROGMEM = #define MAX_GPIO_PIN 17 // Number of supported GPIO #define MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11) +#define ADC0_PIN 17 // Pin number of ADC0 +#define WEMOS_MODULE 17 // Wemos module const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0"; @@ -710,13 +712,17 @@ const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0"; // esp32 has more pins #define USER_MODULE 255 -#define MAX_GPIO_PIN 44 // Number of supported GPIO -#define MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11) +#define MAX_GPIO_PIN 40 // Number of supported GPIO +#define MIN_FLASH_PINS 6 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8, 9, 10 and 11) +#define ADC0_PIN 36 // Pin number of ADC0 +#define WEMOS_MODULE 0 // Wemos module -const char PINS_WEMOS[] PROGMEM = "00010203040506070809101112131415161718192021222324252627282930313233343536373839"; +const char PINS_WEMOS[] PROGMEM = "00TX02RX04050607080910111213141516171819202122232425262728293031A4A5A6A7A03738A3"; #endif // ESP8266 +#define MAX_USER_PINS MAX_GPIO_PIN-MIN_FLASH_PINS + /********************************************************************************************/ typedef struct MYIO { diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index 3f1b2b8c6..04e18af17 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -71,12 +71,12 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_USER, //3 IO RXD0 GPIO3, U0RXD, CLK_OUT2 GPIO_USER, //4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER GPIO_USER, //5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK - 0, //6 - 0, //7 - 0, //8 - 0, //9 - 0, //10 - 0, //11 +// 0, //6 +// 0, //7 +// 0, //8 +// 0, //9 +// 0, //10 +// 0, //11 GPIO_USER, //12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.) GPIO_USER, //13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER GPIO_USER, //14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 @@ -113,12 +113,12 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_USER, //3 IO RXD0 GPIO3, U0RXD, CLK_OUT2 GPIO_USER, //4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER GPIO_USER, //5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK - 0, //6 - 0, //7 - 0, //8 - 0, //9 - 0, //10 - 0, //11 +// 0, //6 +// 0, //7 +// 0, //8 +// 0, //9 +// 0, //10 +// 0, //11 GPIO_USER, //12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.) GPIO_USER, //13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER GPIO_USER, //14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index f50f41d3f..0777e15ac 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -261,15 +261,22 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "as=o.shift();" // Complete ADC0 list "g=o.shift().split(',');" // Array separator "j=0;" - "for(i=0;i<13;i++){" // Supports 13 GPIOs +// "for(i=0;i<13;i++){" // Supports 13 GPIOs + "for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Supports 13 GPIOs +#ifdef ESP8266 "if(6==i){j=9;}" "if(8==i){j=12;}" +#endif +#ifdef ESP32 + "if(6==i){j=12;}" +#endif "sk(g[i],j);" // Set GPIO "j++;" "}" "g=o.shift();" // FLAG "os=as;" - "sk(g&15,17);" // Set ADC0 +// "sk(g&15,17);" // Set ADC0 + "sk(g&15," STR(ADC0_PIN) ");" // Set ADC0 "g>>=4;" "for(i=0;i<" STR(GPIO_FLAG_USED) ";i++){" "p=(g>>i)&1;" @@ -288,7 +295,8 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "function x2(a){" "os=a.responseText;" - "sk(17,99);" // 17 = WEMOS +// "sk(17,99);" // 17 = WEMOS + "sk(" STR(WEMOS_MODULE) ",99);" // 17 = WEMOS "st(" STR(USER_MODULE) ");" "}" @@ -313,12 +321,14 @@ const char HTTP_SCRIPT_MODULE2[] PROGMEM = "}" "function x3(a){" // ADC0 "os=a.responseText;" - "sk(%d,17);" +// "sk(%d,17);" + "sk(%d," STR(ADC0_PIN) ");" "}" "function sl(){" "ld('md?m=1',x1);" // ?m related to WebServer->hasArg("m") "ld('md?g=1',x2);" // ?g related to WebServer->hasArg("g") - "if(eb('g17')){" +// "if(eb('g17')){" + "if(eb('g" STR(ADC0_PIN) "')){" "ld('md?a=1',x3);" // ?a related to WebServer->hasArg("a") "}" "}" @@ -1467,7 +1477,8 @@ void HandleTemplateConfiguration(void) WSContentSend_P(PSTR("}1")); // Field separator for (uint32_t i = 0; i < sizeof(cmodule); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 - if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11 +// if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11 + if (!FlashPin(i)) { WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]); } } @@ -1489,13 +1500,16 @@ void HandleTemplateConfiguration(void) "" "
")); WSContentSend_P(HTTP_TABLE100); - for (uint32_t i = 0; i < 17; i++) { - if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11 + for (uint32_t i = 0; i < MAX_GPIO_PIN; i++) { +// if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11 + if (!FlashPin(i)) { WSContentSend_P(PSTR("" D_GPIO "%d"), ((9==i)||(10==i)) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? " style='width:200px'" : "", i); } } +#ifdef ESP8266 WSContentSend_P(PSTR("" D_ADC "0"), WebColor(COL_TEXT)); +#endif WSContentSend_P(PSTR("")); gpio_flag flag = ModuleFlag(); if (flag.data > ADC0_USER) { @@ -1510,15 +1524,20 @@ void TemplateSaveSettings(void) { char tmp[TOPSZ]; // WebGetArg NAME and GPIO/BASE/FLAG byte value char webindex[5]; // WebGetArg name - char svalue[200]; // Template command string + char svalue[300]; // Template command string WebGetArg("s1", tmp, sizeof(tmp)); // NAME snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp); uint32_t j = 0; for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) { +#ifdef ESP8266 if (6 == i) { j = 9; } if (8 == i) { j = 12; } +#endif // ESP8266 +#ifdef ESP32 + if (6 == i) { j = 12; } +#endif // ESP32 snprintf_P(webindex, sizeof(webindex), PSTR("g%d"), j); WebGetArg(webindex, tmp, sizeof(tmp)); // GPIO uint8_t gpio = atoi(tmp); @@ -1526,7 +1545,8 @@ void TemplateSaveSettings(void) j++; } - WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0 +// WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0 + WebGetArg("g" STR(ADC0_PIN), tmp, sizeof(tmp)); // FLAG - ADC0 uint32_t flag = atoi(tmp); for (uint32_t i = 0; i < GPIO_FLAG_USED; i++) { snprintf_P(webindex, sizeof(webindex), PSTR("c%d"), i); @@ -1656,7 +1676,8 @@ void ModuleSaveSettings(void) } } #ifndef USE_ADC_VCC - WebGetArg("g17", tmp, sizeof(tmp)); +// WebGetArg("g17", tmp, sizeof(tmp)); + WebGetArg("g" STR(ADC0_PIN), tmp, sizeof(tmp)); Settings.my_adc0 = (!strlen(tmp)) ? 0 : atoi(tmp); gpios += F(", " D_ADC "0 "); gpios += String(Settings.my_adc0); #endif // USE_ADC_VCC From a5d3974c5684896fb7450eac577ca26614857ca5 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 12 Apr 2020 19:28:19 +0200 Subject: [PATCH 06/35] sendmail ESP32 --- tasmota/WiFiClientSecureLightBearSSL.cpp | 2 +- tasmota/sendemail.h | 9 +++++++++ tasmota/sendemail.ino | 9 +++++++-- tasmota/xdrv_10_scripter.ino | 6 ++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tasmota/WiFiClientSecureLightBearSSL.cpp b/tasmota/WiFiClientSecureLightBearSSL.cpp index 20992a9dd..434522b14 100644 --- a/tasmota/WiFiClientSecureLightBearSSL.cpp +++ b/tasmota/WiFiClientSecureLightBearSSL.cpp @@ -22,7 +22,7 @@ #include "my_user_config.h" //#ifdef USE_MQTT_TLS -#if defined(USE_MQTT_TLS) || defined (USE_SENDMAIL) +#if defined ESP8266 && (defined(USE_MQTT_TLS) || defined (USE_SENDMAIL)) //#define DEBUG_TLS diff --git a/tasmota/sendemail.h b/tasmota/sendemail.h index 2422ad91f..f5a9334ea 100644 --- a/tasmota/sendemail.h +++ b/tasmota/sendemail.h @@ -8,7 +8,11 @@ #include //#include +#ifdef ESP8266 #include "WiFiClientSecureLightBearSSL.h" +#else +#include +#endif class SendEmail { @@ -20,12 +24,17 @@ class SendEmail const int timeout; const bool ssl; const int auth_used; +#ifdef ESP8266 #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) WiFiClient* client; #else // use bear ssl BearSSL::WiFiClientSecure_light *client; #endif +#else + WiFiClient *client; +#endif + String readClient(); void a3_to_a4(unsigned char * a4, unsigned char * a3); int base64_encode(char *output, const char *input, int inputLen); diff --git a/tasmota/sendemail.ino b/tasmota/sendemail.ino index 70571b5d2..8bcddb029 100644 --- a/tasmota/sendemail.ino +++ b/tasmota/sendemail.ino @@ -174,12 +174,17 @@ exit: return status; } +#ifdef ESP8266 void script_send_email_body(BearSSL::WiFiClientSecure_light *client); - - SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) : host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) { } +#else +void script_send_email_body(WiFiClient *client); +SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) : + host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new WiFiClientSecure()) { +} +#endif String SendEmail::readClient() { delay(0); diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index a5f5265b8..e086adedb 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -4720,7 +4720,13 @@ void ScriptWebShow(void) { #ifdef USE_SENDMAIL + +#ifdef ESP8266 void script_send_email_body(BearSSL::WiFiClientSecure_light *client) { +#else +void script_send_email_body(WiFiClient *client) { +#endif + uint8_t msect=Run_Scripter(">m",-2,0); if (msect==99) { char line[128]; From b4f7500a31a96b3579f42ad1095afd8a14ac8e87 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Sun, 12 Apr 2020 23:17:25 -0500 Subject: [PATCH 07/35] Add light palette support --- tasmota/i18n.h | 1 + tasmota/my_user_config.h | 1 + tasmota/xdrv_04_light.ino | 186 +++++++++++++++++++++++++++++++-- tasmota/xdrv_35_pwm_dimmer.ino | 16 +-- 4 files changed, 182 insertions(+), 22 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 4e1b4098f..e03e54a4e 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -389,6 +389,7 @@ #define D_CMND_LED "Led" #define D_CMND_LEDTABLE "LedTable" #define D_CMND_FADE "Fade" +#define D_CMND_PALETTE "Palette" #define D_CMND_PIXELS "Pixels" #define D_CMND_RGBWWTABLE "RGBWWTable" #define D_CMND_ROTATION "Rotation" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 9b03a6a4c..8aaf25d0d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -436,6 +436,7 @@ #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) +#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 240a09417..2e663e9e2 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -131,12 +131,20 @@ const uint8_t LIGHT_COLOR_SIZE = 25; // Char array scolor size const char kLightCommands[] PROGMEM = "|" // No prefix D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_DIMMER_RANGE "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|" D_CMND_RGBWWTABLE "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|" - D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR "|UNDOCA" ; + D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR +#ifdef USE_LIGHT_PALETTE + "|" D_CMND_PALETTE +#endif // USE_LIGHT_PALETTE + "|UNDOCA" ; void (* const LightCommand[])(void) PROGMEM = { &CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndLedTable, &CmndFade, &CmndRgbwwTable, &CmndScheme, &CmndSpeed, &CmndWakeup, &CmndWakeupDuration, - &CmndWhite, &CmndChannel, &CmndHsbColor, &CmndUndocA }; + &CmndWhite, &CmndChannel, &CmndHsbColor, +#ifdef USE_LIGHT_PALETTE + &CmndPalette, +#endif // USE_LIGHT_PALETTE + &CmndUndocA }; // Light color mode, either RGB alone, or white-CT alone, or both only available if ct_rgb_linked is false enum LightColorModes { @@ -276,6 +284,10 @@ struct LIGHT { #ifdef USE_DEVICE_GROUPS bool devgrp_no_channels_out = false; // don't share channels with device group (e.g. if scheme set by other device) #endif // USE_DEVICE_GROUPS +#ifdef USE_LIGHT_PALETTE + uint8_t palette_count = 0; // palette entry count + uint8_t * palette; // dynamically allocated palette color array +#endif // USE_LIGHT_PALETTE uint16_t fade_start_10[LST_MAX] = {0,0,0,0,0}; uint16_t fade_cur_10[LST_MAX]; uint16_t fade_end_10[LST_MAX]; // 10 bits resolution target channel values @@ -1625,6 +1637,22 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = LightState(0); } +#ifdef USE_LIGHT_PALETTE +void LightSetPaletteEntry(void) +{ + uint8_t bri = light_state.getBri(); + uint8_t * palette_entry = &Light.palette[Light.wheel * LST_MAX]; + for (int i = 0; i < LST_MAX; i++) { + Light.new_color[i] = changeUIntScale(palette_entry[i], 0, 255, 0, bri); + } + light_state.setChannelsRaw(Light.new_color); + if (!Light.pwm_multi_channels) { + light_state.setCW(Light.new_color[3], Light.new_color[4], true); + if (Light.new_color[0] || Light.new_color[1] || Light.new_color[2]) light_state.addRGBMode(); + } +} +#endif // USE_LIGHT_PALETTE + void LightCycleColor(int8_t direction) { // if (Light.strip_timer_counter % (Settings.light_speed * 2)) { return; } // Speed 1: 24sec, 2: 48sec, 3: 72sec, etc @@ -1632,6 +1660,22 @@ void LightCycleColor(int8_t direction) if (Light.strip_timer_counter % (Settings.light_speed - 2)) { return; } // Speed 4: 24sec, 5: 36sec, 6: 48sec, etc } +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count) { + if (0 == direction) { + Light.wheel = random(Light.palette_count); + } + else { + Light.wheel += direction; + if (Light.wheel >= Light.palette_count) { + Light.wheel = (direction < 0 ? Light.palette_count - 1 : 0); + } + } + LightSetPaletteEntry(); + return; + } +#endif // USE_LIGHT_PALETTE + if (0 == direction) { if (Light.random == Light.wheel) { Light.random = random(255); @@ -2187,7 +2231,13 @@ void LightHandleDevGroupItem(void) break; case DGR_ITEM_LIGHT_FIXED_COLOR: if (Light.subtype >= LST_RGBW) { +#ifdef USE_LIGHT_PALETTE + value = value % (Light.palette_count ? Light.palette_count : MAX_FIXED_COLOR); + if (Light.palette_count || value) { +#else // USE_LIGHT_PALETTE + value = value % MAX_FIXED_COLOR; if (value) { +#endif // !USE_LIGHT_PALETTE bool save_decimal_text = Settings.flag.decimal_text; char str[16]; LightColorEntry(str, sprintf_P(str, PSTR("%u"), value)); @@ -2323,19 +2373,55 @@ void CmndSupportColor(void) { bool valid_entry = false; bool coldim = false; +#ifdef USE_LIGHT_PALETTE + uint8_t * color_ptr; +#endif // USE_LIGHT_PALETTE if (XdrvMailbox.data_len > 0) { - valid_entry = LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len); +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count) { + if (XdrvMailbox.data_len == 1 && ('+' == XdrvMailbox.data[0] || '-' == XdrvMailbox.data[0])) { + int8_t direction = ('+' == XdrvMailbox.data[0] ? 1 : -1); + Light.wheel += direction; + if (Light.wheel >= Light.palette_count) { + Light.wheel = (direction < 0 ? Light.palette_count - 1 : 0); + } + } + else { + Light.wheel = (atoi(XdrvMailbox.data) - 1); + } + color_ptr = &Light.palette[Light.wheel * LST_MAX]; + valid_entry = true; + } + else { + color_ptr = Light.entry_color; +#endif // USE_LIGHT_PALETTE + valid_entry = LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len); +#ifdef USE_LIGHT_PALETTE + } +#endif // USE_LIGHT_PALETTE if (valid_entry) { if (XdrvMailbox.index <= 2) { // Color(1), 2 - uint32_t old_bri = light_state.getBri(); - // change all channels to specified values - light_controller.changeChannels(Light.entry_color); - if (2 == XdrvMailbox.index) { - // If Color2, set back old brightness - light_controller.changeBri(old_bri); +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count && XdrvMailbox.index == 1) { + LightSetPaletteEntry(); } - + else { +#endif // USE_LIGHT_PALETTE + uint32_t old_bri = light_state.getBri(); + // change all channels to specified values +#ifdef USE_LIGHT_PALETTE + light_controller.changeChannels(color_ptr); +#else // USE_LIGHT_PALETTE + light_controller.changeChannels(Light.entry_color); +#endif // !USE_LIGHT_PALETTE + if (2 == XdrvMailbox.index) { + // If Color2, set back old brightness + light_controller.changeBri(old_bri); + } +#ifdef USE_LIGHT_PALETTE + } +#endif // USE_LIGHT_PALETTE Settings.light_scheme = 0; #ifdef USE_DEVICE_GROUPS LightUpdateScheme(); @@ -2747,6 +2833,86 @@ void CmndWakeupDuration(void) ResponseCmndNumber(Settings.light_wakeup); } +#ifdef USE_LIGHT_PALETTE +void CmndPalette(void) +{ + uint8_t * palette_entry; + char * color; + char * p; + + // Palette Color[ ...] + if (XdrvMailbox.data_len) { + Light.wheel = 0; + if (Light.palette) { + free(Light.palette); + Light.palette = nullptr; + Light.palette_count = 0; + } + if (XdrvMailbox.data_len > 1 || XdrvMailbox.data[0] != '0') { + for (int pass = 0;; pass++) { + Light.palette_count = 0; + color = XdrvMailbox.data; + for (;;) { + p = strchr(color, ' '); + if (p) *p = 0; + color = Trim(color); + if (*color && LightColorEntry(color, strlen(color))) { + if (pass) { + memcpy(palette_entry, Light.entry_color, LST_MAX); + if (!Light.pwm_multi_channels && LST_COLDWARM == Light.subtype) { + palette_entry[3] = palette_entry[0]; + palette_entry[4] = palette_entry[1]; + } + palette_entry += LST_MAX; + } + Light.palette_count++; + } + if (!p) break; + *p = ' '; + color = p + 1; + } + if (pass) break; + if (!(Light.palette = (uint8_t *)malloc(Light.palette_count * LST_MAX))) return; + palette_entry = Light.palette; + } + } + } + + char palette_str[5 * Light.subtype * Light.palette_count + 3]; + const char * fmt; + p = palette_str; + *p++ = '['; + if (Light.palette_count) { + palette_entry = Light.palette; + if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output + for (int entry = 0; entry < Light.palette_count; entry++) { + *p++ = '"'; + for (uint32_t i = 0; i < Light.subtype; i++) { + if (i > 0) *p++ = ','; + p += sprintf_P(p, PSTR("%d"), palette_entry[i]); + } + palette_entry += LST_MAX; + } + *p++ = '"'; + *p++ = ','; + } + else { + for (int entry = 0; entry < Light.palette_count; entry++) { + for (uint32_t i = 0; i < Light.subtype; i++) { + p += sprintf_P(p, PSTR("%02X"), palette_entry[i]); + } + palette_entry += LST_MAX; + } + *p++ = ','; + } + p--; + } + *p++ = ']'; + *p = 0; + ResponseCmndChar(palette_str); +} +#endif // USE_LIGHT_PALETTE + void CmndUndocA(void) { // Theos legacy status diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index 555ccbd4b..1f04db8c6 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -400,18 +400,10 @@ void PWMDimmerHandleButton(void) else #endif // USE_PWM_DIMMER_REMOTE uint8_value = Light.fixed_color_index; - if (is_down_button) { - if (uint8_value) - uint8_value--; - else - uint8_value = MAX_FIXED_COLOR; - } - else { - if (uint8_value < MAX_FIXED_COLOR) - uint8_value++; - else - uint8_value = 0; - } + if (is_down_button) + uint8_value--; + else + uint8_value++; #ifdef USE_PWM_DIMMER_REMOTE if (!active_device_is_local) active_remote_pwm_dimmer->fixed_color_index = uint8_value; From 073f0267f04680f88f6ba86803945f53203af80f Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 13 Apr 2020 11:40:07 +0200 Subject: [PATCH 08/35] Avoid logging AWS IoT shadow when no MQTT connection --- tasmota/xdrv_02_mqtt.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 7c8f0b29a..780d94c98 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -374,7 +374,7 @@ void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retain MqttPublish(stopic, retained); #ifdef USE_MQTT_AWS_IOT - if ((prefix > 0) && (Settings.flag4.awsiot_shadow)) { // placeholder for SetOptionXX + if ((prefix > 0) && (Settings.flag4.awsiot_shadow) && (Mqtt.connected)) { // placeholder for SetOptionXX // compute the target topic char *topic = SettingsText(SET_MQTT_TOPIC); char topic2[strlen(topic)+1]; // save buffer onto stack From baf3b9b66270a726ca3df33c0d17db830c36d32c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:19:16 +0200 Subject: [PATCH 09/35] Add command ``Palette`` Add command ``Palette`` to add the ability to specify a palette of colors (#8150) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/my_user_config.h | 2 +- tasmota/tasmota_configurations.h | 10 +++++++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 640064399..53e4db68c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -78,6 +78,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add command ``DevGroupName`` to specify up to four Device Group Names (#8087) - Add command ``DevGroupSend`` to send an update to a Device Group (#8093) - Add command ``Ping`` (#7176) +- Add command ``Palette`` to add the ability to specify a palette of colors (#8150) - Add support for unreachable (unplugged) Zigbee devices in Philips Hue emulation and Alexa - Add support for 64x48 SSD1306 OLED (#6740) - Add support for Seven Segment display using HT16K33 (#8116) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 5098db14f..c353e54bb 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -22,6 +22,7 @@ - Add command ``DevGroupName`` to specify up to four Device Group Names (#8087) - Add command ``DevGroupSend`` to send an update to a Device Group (#8093) - Add command ``Ping`` (#7176) +- Add command ``Palette`` to add the ability to specify a palette of colors (#8150) - Add quick wifi reconnect using saved AP parameters when ``SetOption56 0`` (#3189) - Add more accuracy to GPS NTP server (#8088) - Add support for an iAQ sensor (#8107) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 8aaf25d0d..63bcf615d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -436,7 +436,7 @@ #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) -#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) +#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 218a83c7d..efe02c05d 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -70,6 +70,7 @@ #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) #define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices @@ -332,7 +333,8 @@ #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) #undef USE_ENERGY_SENSOR // Disable energy sensors (-14k code) #undef USE_PZEM004T // Disable PZEM004T energy sensor @@ -444,7 +446,8 @@ #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -563,7 +566,8 @@ #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller +#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices From 5337d84063b5632bf0e6b2ef938f67b209c5bd43 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:27:53 +0200 Subject: [PATCH 10/35] Add SetOption41 to my_user_config.h --- tasmota/my_user_config.h | 1 + tasmota/settings.ino | 1 + 2 files changed, 2 insertions(+) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 63bcf615d..f6ec92670 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -70,6 +70,7 @@ #define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if wifi fails to connect (default option: 4 - WIFI_RETRY) // (WIFI_RESTART, WIFI_MANAGER, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY) // The configuration can be changed after first setup using WifiConfig 0, 2, 4, 5, 6 and 7. +#define WIFI_ARP_INTERVAL 0 // [SetOption41] Send gratuitous ARP interval #define WIFI_SCAN_AT_RESTART false // [SetOption56] Scan wifi network at restart for configured AP's #define WIFI_SCAN_REGULARLY false // [SetOption57] Scan wifi network every 44 minutes for configured AP's diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 8d27b4db9..9426c9b04 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -731,6 +731,7 @@ void SettingsDefaultSet2(void) Settings.flag3.use_wifi_scan = WIFI_SCAN_AT_RESTART; Settings.flag3.use_wifi_rescan = WIFI_SCAN_REGULARLY; Settings.wifi_output_power = 170; + Settings.param[P_ARP_GRATUITOUS] = WIFI_ARP_INTERVAL; ParseIp(&Settings.ip_address[0], WIFI_IP_ADDRESS); ParseIp(&Settings.ip_address[1], WIFI_GATEWAY); ParseIp(&Settings.ip_address[2], WIFI_SUBNETMASK); From f345cc78b23d6d9150cde971270ae46ee418f9e3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:32:53 +0200 Subject: [PATCH 11/35] Fix compile error --- tasmota/support_flash_log.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/support_flash_log.ino b/tasmota/support_flash_log.ino index 162ea1f0b..9aa8ecc05 100644 --- a/tasmota/support_flash_log.ino +++ b/tasmota/support_flash_log.ino @@ -400,7 +400,7 @@ void FLOG::stopRecording(void){ if(k%128 == 0){ // give control to the system every x iteration, TODO: This will fail, when record/entry-size is not 8 // DEBUG_SENSOR_LOG(PSTR("FLOG: now loop(), %u bytes left"), Flog->bytes_left); OsWatchLoop(); - delay(sleep); + delay(ssleep); } k+=size; if(bytes_left>7){ @@ -419,7 +419,7 @@ void FLOG::stopRecording(void){ _readSector(next_sector); bytes_left = sector.header.buf_pointer - sizeof(sector.header); OsWatchLoop(); - delay(sleep); + delay(ssleep); } running_download = false; // Callback 3: create a footer or simply finish the download with an empty payload From 16ca5cb10364e7b9f987f7f2f02b3971f083c3c6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 13:01:54 +0200 Subject: [PATCH 12/35] Increase ESP32 compatibility --- tasmota/support.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index 9ac48c3fc..bb4432d2d 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1276,7 +1276,11 @@ bool JsonTemplate(const char* dataBuf) if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks - StaticJsonBuffer<600> jb; // 331 from https://arduinojson.org/v5/assistant/ +#ifdef ESP8266 + StaticJsonBuffer<400> jb; // 331 from https://arduinojson.org/v5/assistant/ +#else + StaticJsonBuffer<800> jb; // 654 from https://arduinojson.org/v5/assistant/ +#endif JsonObject& obj = jb.parseObject(dataBuf); if (!obj.success()) { return false; } From 20c9a9cadfe0b3b30a3c35a4042e36a128979ea1 Mon Sep 17 00:00:00 2001 From: device111 <48546979+device111@users.noreply.github.com> Date: Mon, 13 Apr 2020 13:26:49 +0200 Subject: [PATCH 13/35] Add change global hum and temp with command --- tasmota/i18n.h | 2 ++ tasmota/support_command.ino | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index e03e54a4e..35a840acf 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -308,6 +308,8 @@ #define D_JSON_BASE "BASE" #define D_CMND_TEMPOFFSET "TempOffset" #define D_CMND_HUMOFFSET "HumOffset" +#define D_CMND_GLOBAL_TEMP "GlobalTemp" +#define D_CMND_GLOBAL_HUM "GlobalHum" // Commands xdrv_01_mqtt.ino #define D_CMND_MQTTLOG "MqttLog" diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 41a237802..4efde90ce 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -27,7 +27,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix D_CMND_SERIALDELIMITER "|" D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|" D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|" D_CMND_INTERLOCK "|" D_CMND_TELEPERIOD "|" D_CMND_RESET "|" D_CMND_TIME "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|" D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" D_CMND_LEDMASK "|" D_CMND_WIFIPOWER "|" D_CMND_TEMPOFFSET "|" D_CMND_HUMOFFSET "|" - D_CMND_SPEEDUNIT "|" + D_CMND_SPEEDUNIT "|" D_CMND_GLOBAL_TEMP "|" D_CMND_GLOBAL_HUM "|" #ifdef USE_I2C D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|" #endif @@ -50,7 +50,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = { &CmndSerialDelimiter, &CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig, &CmndFriendlyname, &CmndSwitchMode, &CmndInterlock, &CmndTeleperiod, &CmndReset, &CmndTime, &CmndTimezone, &CmndTimeStd, &CmndTimeDst, &CmndAltitude, &CmndLedPower, &CmndLedState, &CmndLedMask, &CmndWifiPower, &CmndTempOffset, &CmndHumOffset, - &CmndSpeedUnit, + &CmndSpeedUnit, &CmndGlobalTemp, &CmndGlobalHum, #ifdef USE_I2C &CmndI2cScan, CmndI2cDriver, #endif @@ -576,6 +576,28 @@ void CmndHumOffset(void) ResponseCmndFloat((float)(Settings.hum_comp) / 10, 1); } +void CmndGlobalTemp(void) +{ + if (XdrvMailbox.data_len > 0) { + int value = (int)(CharToFloat(XdrvMailbox.data) * 10); + if ((value > -401) && (value < 801)) { + ConvertTemp(value); + } + } + ResponseCmndFloat((float)(global_temperature) / 10, 1); +} + +void CmndGlobalHum(void) +{ + if (XdrvMailbox.data_len > 0) { + int value = (int)(CharToFloat(XdrvMailbox.data) * 10); + if ((value > -10) && (value < 999)) { + ConvertHumidity(value); + } + } + ResponseCmndFloat((float)(global_humidity) / 10, 1); +} + void CmndSleep(void) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 251)) { From 5db2ac1955028229b3e8ebd094fba950cf321913 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 14:40:29 +0200 Subject: [PATCH 14/35] Add commands ``GlobalTemp`` and ``GlobalHum`` Add commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 53e4db68c..81b066e38 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -69,6 +69,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add Zigbee command ``ZbConfig`` and configuration in Settings - Add commands ``CounterDebounceLow`` and ``CounterDebounceHigh`` to control debouncing (#8021) - Add commands ``NrfPage``, ``NrfIgnore``, ``NrfScan`` and ``NrfBeacon`` to NRF24 Bluetooth driver (#8075) +- Add commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152) - Add command ``SetOption41 `` to force sending gratuitous ARP every seconds - Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044) - Add command ``SetOption91 1`` to enable fading at startup / power on diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index c353e54bb..cc54af1f8 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -23,6 +23,7 @@ - Add command ``DevGroupSend`` to send an update to a Device Group (#8093) - Add command ``Ping`` (#7176) - Add command ``Palette`` to add the ability to specify a palette of colors (#8150) +- Add commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152) - Add quick wifi reconnect using saved AP parameters when ``SetOption56 0`` (#3189) - Add more accuracy to GPS NTP server (#8088) - Add support for an iAQ sensor (#8107) From 5588d1dda06c9328c5347312e32eca7955cd1f15 Mon Sep 17 00:00:00 2001 From: Staars Date: Mon, 13 Apr 2020 16:20:49 +0200 Subject: [PATCH 15/35] adapt GPS-stuff for ESP32 --- lib/ArduinoNTPd/NTPServer.cpp | 2 +- platformio_override_esp32.ini | 1 - tasmota/support_flash_log.ino | 2 ++ tasmota/xsns_60_GPS.ino | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/ArduinoNTPd/NTPServer.cpp b/lib/ArduinoNTPd/NTPServer.cpp index a5d0515d0..860ccc79d 100644 --- a/lib/ArduinoNTPd/NTPServer.cpp +++ b/lib/ArduinoNTPd/NTPServer.cpp @@ -87,7 +87,7 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs) packet.swapEndian(); timeServerPort_.beginPacket(timeServerPort_.remoteIP(), timeServerPort_.remotePort()); - timeServerPort_.write(packet.packet(), NtpPacket::PACKET_SIZE); + timeServerPort_.write((const uint8_t *)packet.packet(), NtpPacket::PACKET_SIZE); timeServerPort_.endPacket(); processed = true; diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini index 5c4afdafa..babc261cc 100644 --- a/platformio_override_esp32.ini +++ b/platformio_override_esp32.ini @@ -102,4 +102,3 @@ lib_ignore = ILI9488 SSD3115 cc1101 - ArduinoNTPd diff --git a/tasmota/support_flash_log.ino b/tasmota/support_flash_log.ino index 9aa8ecc05..cf64de6d5 100644 --- a/tasmota/support_flash_log.ino +++ b/tasmota/support_flash_log.ino @@ -37,6 +37,7 @@ \*********************************************************************************************/ #ifdef USE_FLOG +#ifdef ESP8266 class FLOG @@ -429,4 +430,5 @@ void FLOG::stopRecording(void){ _initBuffer(); } + #endif // ESP8266 #endif // USE_FLOG \ No newline at end of file diff --git a/tasmota/xsns_60_GPS.ino b/tasmota/xsns_60_GPS.ino index 69b13aedd..966b3a609 100644 --- a/tasmota/xsns_60_GPS.ino +++ b/tasmota/xsns_60_GPS.ino @@ -18,6 +18,10 @@ */ #ifdef USE_GPS +#if defined(ESP32) && defined(USE_FLOG) + #undef USE_FLOG + #warning FLOG deactivated on ESP32 +#endif //ESP32 /*********************************************************************************************\ -------------------------------------------------------------------------------------------- Version Date Action Description @@ -115,6 +119,10 @@ rule3 on tele-FLOG#sec do DisplayText [f0c1l4]SAV:%value% endon on tele-FLOG#r #include "NTPServer.h" #include "NTPPacket.h" +#ifdef ESP32 +#include +#endif + /*********************************************************************************************\ * constants \*********************************************************************************************/ @@ -291,7 +299,11 @@ enum UBXMsgType { #ifdef USE_FLOG FLOG *Flog = nullptr; #endif //USE_FLOG +#ifdef ESP8266 TasmotaSerial *UBXSerial; +#else +HardwareSerial *UBXSerial; +#endif NtpServer timeServer(PortUdp); @@ -351,13 +363,21 @@ void UBXDetect(void) { UBX.mode.init = 0; if ((pin[GPIO_GPS_RX] < 99) && (pin[GPIO_GPS_TX] < 99)) { +#ifdef ESP8266 UBXSerial = new TasmotaSerial(pin[GPIO_GPS_RX], pin[GPIO_GPS_TX], 1, 0, UBX_SERIAL_BUFFER_SIZE); // 64 byte buffer is NOT enough if (UBXSerial->begin(9600)) { +#else + UBXSerial = new HardwareSerial(2); + UBXSerial->begin(9600,SERIAL_8N1,pin[GPIO_GPS_RX], pin[GPIO_GPS_TX]); + { +#endif DEBUG_SENSOR_LOG(PSTR("UBX: started serial")); +#ifdef ESP8266 if (UBXSerial->hardwareSerial()) { ClaimSerial(); DEBUG_SENSOR_LOG(PSTR("UBX: claim HW")); } +#endif } } else { From 2bfc70f565da4254ca32919c898b6eb6cc3a912b Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 13 Apr 2020 16:47:27 +0200 Subject: [PATCH 16/35] Fix Scheme 2-4 brightness when SetOption68 1 (#8058) --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index cc54af1f8..3b1e9afcc 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -30,6 +30,7 @@ - Add support for Seven Segment display using HT16K33 (#8116) - Add support for AS3935 Lightning Sensor by device111 (#8130) - Fix prevent multiple pings to run concurrently +- Fix Scheme 2-4 brightness when SetOption68 1 (#8058) ### 8.2.0.2 20200328 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 2e663e9e2..7eb293bb4 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1299,6 +1299,7 @@ void LightInit(void) light_controller.setSubType(Light.subtype); light_controller.loadSettings(); light_controller.setAlexaCTRange(Settings.flag4.alexa_ct_range); + light_controller.calcLevels(); // calculate the initial values (#8058) if (LST_SINGLE == Light.subtype) { Settings.light_color[0] = 255; // One channel only supports Dimmer but needs max color @@ -1465,7 +1466,9 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value) // convert channels to string, use Option 17 to foce decimal, unless force_hex char* LightGetColor(char* scolor, boolean force_hex = false) { - light_controller.calcLevels(); + if ((0 == Settings.light_scheme) || (!Light.pwm_multi_channels)) { + light_controller.calcLevels(); // recalculate levels only if Scheme 0, otherwise we mess up levels + } scolor[0] = '\0'; for (uint32_t i = 0; i < Light.subtype; i++) { if (!force_hex && Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output @@ -1698,9 +1701,14 @@ void LightCycleColor(int8_t direction) // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue); + if (!Light.pwm_multi_channels) { uint8_t sat; light_state.getHSB(nullptr, &sat, nullptr); // Allow user control over Saturation light_state.setHS(hue, sat); + } else { + light_state.setHS(hue, 255); + light_state.setBri(255); // If multi-channel, force bri to max, it will be later dimmed to correct value + } light_controller.calcLevels(Light.new_color); } @@ -1808,13 +1816,20 @@ void LightAnimate(void) } break; case LS_CYCLEUP: - LightCycleColor(1); - break; case LS_CYCLEDN: - LightCycleColor(-1); - break; case LS_RANDOM: + if (LS_CYCLEUP == Settings.light_scheme) { + LightCycleColor(1); + } else if (LS_CYCLEDN == Settings.light_scheme) { + LightCycleColor(-1); + } else { LightCycleColor(0); + } + if (Light.pwm_multi_channels) { // See #8058 + Light.new_color[0] = changeUIntScale(Light.new_color[0], 0, 255, 0, Settings.light_color[0]); + Light.new_color[1] = changeUIntScale(Light.new_color[1], 0, 255, 0, Settings.light_color[1]); + Light.new_color[2] = changeUIntScale(Light.new_color[2], 0, 255, 0, Settings.light_color[2]); + } break; default: XlgtCall(FUNC_SET_SCHEME); From 11117ccc50625c3ab09152f8f94b977d095a5df3 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 13 Apr 2020 16:49:09 +0200 Subject: [PATCH 17/35] Fix Scheme 2-4 brightness when SetOption68 1 (#8058) --- tasmota/xdrv_04_light.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 7eb293bb4..b85c2373b 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1819,11 +1819,11 @@ void LightAnimate(void) case LS_CYCLEDN: case LS_RANDOM: if (LS_CYCLEUP == Settings.light_scheme) { - LightCycleColor(1); + LightCycleColor(1); } else if (LS_CYCLEDN == Settings.light_scheme) { - LightCycleColor(-1); + LightCycleColor(-1); } else { - LightCycleColor(0); + LightCycleColor(0); } if (Light.pwm_multi_channels) { // See #8058 Light.new_color[0] = changeUIntScale(Light.new_color[0], 0, 255, 0, Settings.light_color[0]); From e8f3d1d9862af8f3d2129a3a45f8714719074c09 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 13 Apr 2020 17:45:06 +0200 Subject: [PATCH 18/35] Increase ESP32 compatibility Increase ESP32 compatibility (breaks current ESP32 configuration again!) --- .../src/esp8266toEsp32.cpp | 29 +++++++++++++++---- .../src/esp8266toEsp32.h | 5 +++- tasmota/support.ino | 8 +++++ tasmota/support_command.ino | 6 ++-- tasmota/support_rtc.ino | 2 +- tasmota/support_tasmota.ino | 17 +++++++---- tasmota/support_wifi.ino | 2 +- tasmota/tasmota.h | 12 ++++---- tasmota/tasmota.ino | 4 +-- tasmota/tasmota_compat.h | 7 +++-- tasmota/tasmota_globals.h | 13 ++++++++- tasmota/xdrv_01_webserver.ino | 8 ++--- tasmota/xdrv_12_home_assistant.ino | 24 +++++++-------- tasmota/xdrv_20_hue.ino | 6 ++-- tasmota/xdrv_21_wemo.ino | 2 +- 15 files changed, 97 insertions(+), 48 deletions(-) diff --git a/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp b/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp index 0490991c4..f4a17f368 100644 --- a/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp +++ b/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp @@ -34,9 +34,9 @@ String ESP_getResetInfo(void) return String(PSTR("0")); } -String ESP_getBootVersion(void) +uint32_t ESP_getBootVersion(void) { - return String(PSTR("Unknown")); + return 1; } bool ESP_rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size) @@ -59,15 +59,32 @@ uint32_t ESP_getFlashChipId() return 0; } +uint32_t ESP_getChipId() +{ + uint32_t id = 0; + for (uint32_t i = 0; i < 17; i = i +8) { + id |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i; + } + return id; +} + String String_ESP_getChipId() { uint64_t mac = ESP.getEfuseMac(); return String(uint32_t(mac >> 32)) + String(uint32_t(mac)); } -/* -uint64_t ESP_getChipId() +uint32_t ESP_getFlashChipRealSize() { - return ESP.getEfuseMac(); + return ESP.getFlashChipSize(); +} + +uint32_t ESP_getSketchSize(void) +{ + static uint32_t sketchsize = 0; + + if (!sketchsize) { + sketchsize = ESP.getSketchSize(); // This takes almost 2 seconds on an ESP32 + } + return sketchsize; } -*/ diff --git a/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index 1071bfbd1..8a30da55d 100644 --- a/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -34,13 +34,16 @@ #define ESP_flashReadHeader(offset, data, size) ESP32_flashRead(offset, data, size) #define ESP_flashRead(offset, data, size) ESP32_flashRead(offset, data, size) String ESP_getResetReason(void); -String ESP_getBootVersion(void); +uint32_t ESP_getBootVersion(void); bool ESP_rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size); bool ESP_rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size); void ESP_reset(); String ESP_getResetInfo(void); uint32_t ESP_getFlashChipId(); +uint32_t ESP_getChipId(); String String_ESP_getChipId(); +uint32_t ESP_getFlashChipRealSize(); +uint32_t ESP_getSketchSize(); // Analog inline void analogWrite(uint8_t pin, int val) diff --git a/tasmota/support.ino b/tasmota/support.ino index bb4432d2d..9c720c996 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -562,6 +562,7 @@ char* GetPowerDevice(char* dest, uint32_t idx, size_t size) void GetEspHardwareType(void) { +#ifdef ESP8266 // esptool.py get_efuses uint32_t efuse1 = *(uint32_t*)(0x3FF00050); uint32_t efuse2 = *(uint32_t*)(0x3FF00054); @@ -572,16 +573,23 @@ void GetEspHardwareType(void) if (is_8285 && (ESP.getFlashChipRealSize() > 1048576)) { is_8285 = false; // ESP8285 can only have 1M flash } +#else + is_8285 = false; // ESP8285 can only have 1M flash +#endif } String GetDeviceHardware(void) { char buff[10]; +#ifdef ESP8266 if (is_8285) { strcpy_P(buff, PSTR("ESP8285")); } else { strcpy_P(buff, PSTR("ESP8266EX")); } +#else + strcpy_P(buff, PSTR("ESP32")); +#endif return String(buff); } diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 4efde90ce..383e8d7b5 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -422,7 +422,7 @@ void CmndStatus(void) if ((0 == payload) || (2 == payload)) { Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS2_FIRMWARE "\":{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\",\"" - D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"," + D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_CORE_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"," "\"Hardware\":\"%s\"" "%s}}"), my_version, my_image, GetBuildDateAndTime().c_str(), @@ -447,8 +447,8 @@ void CmndStatus(void) Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\"" D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHCHIPID "\":\"%06X\",\"" D_JSON_FLASHMODE "\":%d,\"" D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"), - ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, - ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(), + ESP_getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, + ESP.getFlashChipSize()/1024, ESP_getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(), LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, feature6); XsnsDriverState(); ResponseAppend_P(PSTR(",\"Sensors\":")); diff --git a/tasmota/support_rtc.ino b/tasmota/support_rtc.ino index 3b7da8e37..0b2249ec2 100644 --- a/tasmota/support_rtc.ino +++ b/tasmota/support_rtc.ino @@ -367,7 +367,7 @@ void RtcSecond(void) if ((Rtc.ntp_sync_minute > 59) && (uptime_minute > 2)) { Rtc.ntp_sync_minute = 1; // If sync prepare for a new cycle } - uint8_t offset = (uptime < 30) ? RtcTime.second : (((ESP.getChipId() & 0xF) * 3) + 3) ; // First try ASAP to sync. If fails try once every 60 seconds based on chip id + uint8_t offset = (uptime < 30) ? RtcTime.second : (((ESP_getChipId() & 0xF) * 3) + 3) ; // First try ASAP to sync. If fails try once every 60 seconds based on chip id if ( (((offset == RtcTime.second) && ( (RtcTime.year < 2016) || // Never synced (Rtc.ntp_sync_minute == uptime_minute))) || // Re-sync every hour ntp_force_sync ) ) { // Forced sync diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 44954ca26..f33f35b3d 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -39,14 +39,14 @@ char* Format(char* output, const char* input, int size) char tmp[size]; if (strchr(token, 'd')) { snprintf_P(tmp, size, PSTR("%s%c0%dd"), output, '%', digits); - snprintf_P(output, size, tmp, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname + snprintf_P(output, size, tmp, ESP_getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname } else { snprintf_P(tmp, size, PSTR("%s%c0%dX"), output, '%', digits); - snprintf_P(output, size, tmp, ESP.getChipId()); // %06X - full chip ID in hex + snprintf_P(output, size, tmp, ESP_getChipId()); // %06X - full chip ID in hex } } else { if (strchr(token, 'd')) { - snprintf_P(output, size, PSTR("%s%d"), output, ESP.getChipId()); // %d - full chip ID in dec + snprintf_P(output, size, PSTR("%s%d"), output, ESP_getChipId()); // %d - full chip ID in dec digits = 8; } } @@ -61,10 +61,10 @@ char* Format(char* output, const char* input, int size) char* GetOtaUrl(char *otaurl, size_t otaurl_size) { if (strstr(SettingsText(SET_OTAURL), "%04d") != nullptr) { // OTA url contains placeholder for chip ID - snprintf(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP.getChipId() & 0x1fff); + snprintf(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP_getChipId() & 0x1fff); } else if (strstr(SettingsText(SET_OTAURL), "%d") != nullptr) { // OTA url contains placeholder for chip ID - snprintf_P(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP.getChipId()); + snprintf_P(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP_getChipId()); } else { strlcpy(otaurl, SettingsText(SET_OTAURL), otaurl_size); @@ -824,6 +824,13 @@ void PerformEverySecond(void) // Wifi keep alive to send Gratuitous ARP wifiKeepAlive(); #endif // ARDUINO_ESP8266_RELEASE_2_3_0 + + +#ifdef ESP32 + if (11 == uptime) { // Perform one-time ESP32 houskeeping + ESP_getSketchSize(); // Init sketchsize as it can take up to 2 seconds + } +#endif } /*-------------------------------------------------------------------------------------------*\ diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index dc4016b59..18c026562 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -655,7 +655,7 @@ void WifiConnect(void) WifiSetOutputPower(); WiFi.persistent(false); // Solve possible wifi init errors Wifi.status = 0; - Wifi.retry_init = WIFI_RETRY_OFFSET_SEC + (ESP.getChipId() & 0xF); // Add extra delay to stop overrun by simultanous re-connects + Wifi.retry_init = WIFI_RETRY_OFFSET_SEC + (ESP_getChipId() & 0xF); // Add extra delay to stop overrun by simultanous re-connects Wifi.retry = Wifi.retry_init; Wifi.counter = 1; diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index e6861ee97..042f1b1d4 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -41,14 +41,14 @@ * Power Type \*********************************************************************************************/ -#ifdef ESP8266 +//#ifdef ESP8266 typedef unsigned long power_t; // Power (Relay) type const uint32_t POWER_MASK = 0xffffffffUL; // Power (Relay) full mask -#endif // ESP8266 -#ifdef ESP32 -typedef uint64_t power_t; // Power (Relay) type -const uint64_t POWER_MASK = 0xffffffffffffffffull; // Power (Relay) full mask -#endif // ESP32 +//#endif // ESP8266 +//#ifdef ESP32 +//typedef uint64_t power_t; // Power (Relay) type +//const uint64_t POWER_MASK = 0xffffffffffffffffull; // Power (Relay) full mask +//#endif // ESP32 /*********************************************************************************************\ * Constants diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 22e33ce72..1a7c250ae 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -276,7 +276,7 @@ void setup(void) Format(mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(mqtt_topic)); if (strstr(SettingsText(SET_HOSTNAME), "%") != nullptr) { SettingsUpdateText(SET_HOSTNAME, WIFI_HOSTNAME); - snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME), mqtt_topic, ESP.getChipId() & 0x1FFF); + snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME), mqtt_topic, ESP_getChipId() & 0x1FFF); } else { snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME)); } @@ -290,7 +290,7 @@ void setup(void) SetPowerOnState(); - AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), PROJECT, SettingsText(SET_FRIENDLYNAME1), my_version, my_image); + AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE), PROJECT, SettingsText(SET_FRIENDLYNAME1), my_version, my_image); #ifdef FIRMWARE_MINIMAL AddLog_P2(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION)); #endif // FIRMWARE_MINIMAL diff --git a/tasmota/tasmota_compat.h b/tasmota/tasmota_compat.h index 97777c566..6571d0f34 100644 --- a/tasmota/tasmota_compat.h +++ b/tasmota/tasmota_compat.h @@ -6,7 +6,7 @@ // Modul #undef MODULE #define MODULE WEMOS // [Module] Select default model -#endif +#endif // ESP32 #ifdef ESP8266 // ESP8266 @@ -17,6 +17,9 @@ #define ESP_reset() ESP.reset() #define ESP_getBootVersion() ESP.getBootVersion() #define ESP_getFlashChipId() ESP.getFlashChipId() +#define ESP_getFlashChipRealSize() ESP.getFlashChipRealSize() +#define ESP_getSketchSize() ESP.getSketchSize() +#define ESP_getChipId() ESP.getChipId() // // we need different ESP_flashRead for ESP32 // @@ -28,4 +31,4 @@ // // Serial minimal type to hold the config #define SerConfu8 uint8_t -#endif // ESP32 +#endif // ESP8266 diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index d05db0efd..9c5cbd8c3 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -117,8 +117,19 @@ extern "C" void resetPins(); #define MESSZ (MQTT_MAX_PACKET_SIZE -TOPSZ -7) // Max number of characters in JSON message string #endif +#ifdef ESP8266 #ifndef ARDUINO_ESP8266_RELEASE -#define ARDUINO_ESP8266_RELEASE "STAGE" +#define ARDUINO_CORE_RELEASE "STAGE" +#else +#define ARDUINO_CORE_RELEASE ARDUINO_ESP8266_RELEASE +#endif +#endif +#ifdef ESP32 +#ifndef ARDUINO_ESP32_RELEASE +#define ARDUINO_CORE_RELEASE "STAGE" +#else +#define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE +#endif #endif #ifdef USE_PWM_DIMMER_REMOTE diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 0777e15ac..5206b701d 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2120,7 +2120,7 @@ void HandleInformation(void) WSContentSend_P(PSTR("
")); WSContentSend_P(PSTR(D_PROGRAM_VERSION "}2%s%s"), my_version, my_image); WSContentSend_P(PSTR("}1" D_BUILD_DATE_AND_TIME "}2%s"), GetBuildDateAndTime().c_str()); - WSContentSend_P(PSTR("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_ESP8266_RELEASE "/%s"), ESP.getSdkVersion()); + WSContentSend_P(PSTR("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_CORE_RELEASE "/%s"), ESP.getSdkVersion()); WSContentSend_P(PSTR("}1" D_UPTIME "}2%s"), GetUptime().c_str()); WSContentSend_P(PSTR("}1" D_FLASH_WRITE_COUNT "}2%d at 0x%X"), Settings.save_flag, GetSettingsAddress()); WSContentSend_P(PSTR("}1" D_BOOT_COUNT "}2%d"), Settings.bootcount); @@ -2195,11 +2195,11 @@ void HandleInformation(void) #endif // USE_DISCOVERY WSContentSend_P(PSTR("}1}2 ")); // Empty line - WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP.getChipId()); + WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP_getChipId()); WSContentSend_P(PSTR("}1" D_FLASH_CHIP_ID "}20x%06X"), ESP_getFlashChipId()); - WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP.getFlashChipRealSize() / 1024); + WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP_getFlashChipRealSize() / 1024); WSContentSend_P(PSTR("}1" D_PROGRAM_FLASH_SIZE "}2%dkB"), ESP.getFlashChipSize() / 1024); - WSContentSend_P(PSTR("}1" D_PROGRAM_SIZE "}2%dkB"), ESP.getSketchSize() / 1024); + WSContentSend_P(PSTR("}1" D_PROGRAM_SIZE "}2%dkB"), ESP_getSketchSize() / 1024); WSContentSend_P(PSTR("}1" D_FREE_PROGRAM_SPACE "}2%dkB"), ESP.getFreeSketchSpace() / 1024); WSContentSend_P(PSTR("}1" D_FREE_MEMORY "}2%dkB"), freeMem / 1024); WSContentSend_P(PSTR("
")); diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 3794ba072..f33d6ffde 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -180,12 +180,12 @@ void HAssAnnounceRelayLight(void) mqtt_data[0] = '\0'; // Clear retained message // Clear "other" topic first in case the device has been reconfigured from light to switch or vice versa - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP.getChipId(), (is_topic_light) ? "RL" : "LI", i); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP_getChipId(), (is_topic_light) ? "RL" : "LI", i); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s/config"), (is_topic_light) ? "switch" : "light", unique_id); MqttPublish(stopic, true); // Clear or Set topic - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP.getChipId(), (is_topic_light) ? "LI" : "RL", i); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP_getChipId(), (is_topic_light) ? "LI" : "RL", i); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s/config"), (is_topic_light) ? "light" : "switch", unique_id); @@ -210,7 +210,7 @@ void HAssAnnounceRelayLight(void) Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic); TryResponseAppend_P(HASS_DISCOVER_RELAY, command_topic, value_template, SettingsText(SET_STATE_TXT1), SettingsText(SET_STATE_TXT2)); - TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId()); + TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); #ifdef USE_LIGHT if (is_light @@ -270,7 +270,7 @@ void HAssAnnouncerTriggers(uint8_t device, uint8_t present, uint8_t key, uint8_t mqtt_data[0] = '\0'; // Clear retained message for (uint8_t i = 2; i <= 3; i++) { - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d_%s"), ESP.getChipId(), key ? "SW" : "BTN", device + 1, GetStateText(i)); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d_%s"), ESP_getChipId(), key ? "SW" : "BTN", device + 1, GetStateText(i)); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/device_automation/%s/config"), unique_id); if (Settings.flag.hass_discovery && present) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59) @@ -294,7 +294,7 @@ void HAssAnnouncerTriggers(uint8_t device, uint8_t present, uint8_t key, uint8_t if (i == 3) { pload = hold; } GetTextIndexed(param, sizeof(param), pload, kHAssTriggerType); snprintf_P(subtype, sizeof(subtype), PSTR("%s_%d"), key ? "switch" : "button", device + 1); - Response_P(HASS_TRIGGER_TYPE, state_topic, GetStateText(i), param, subtype, ESP.getChipId()); + Response_P(HASS_TRIGGER_TYPE, state_topic, GetStateText(i), param, subtype, ESP_getChipId()); } else { mqtt_data[0] = '\0'; } // Need to be cleaned again to avoid duplicate. } MqttPublish(stopic, true); @@ -310,7 +310,7 @@ void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint mqtt_data[0] = '\0'; // Clear retained message - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SW_%d"), ESP.getChipId(), device + 1); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SW_%d"), ESP_getChipId(), device + 1); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/binary_sensor/%s/config"), unique_id); @@ -335,7 +335,7 @@ void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint } else { TryResponseAppend_P(HASS_DISCOVER_BIN_PIR, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2)); } - TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId()); + TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); TryResponseAppend_P(PSTR("}")); } } @@ -491,7 +491,7 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const // Clear or Set topic NoAlNumToUnderscore(subname, MultiSubName); //Replace all non alphaumeric characters to '_' to avoid topic name issues - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP.getChipId(), sensorname, subname); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP_getChipId(), sensorname, subname); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id); if (Settings.flag.hass_discovery) @@ -506,7 +506,7 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT); Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic); - TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId()); + TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); char jname[32]; @@ -632,7 +632,7 @@ void HAssAnnounceStatusSensor(void) mqtt_data[0] = '\0'; // Clear retained message // Clear or Set topic - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_status"), ESP.getChipId()); + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_status"), ESP_getChipId()); snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id); if (Settings.flag.hass_discovery) @@ -648,7 +648,7 @@ void HAssAnnounceStatusSensor(void) Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic); TryResponseAppend_P(HASS_DISCOVER_SENSOR_HASS_STATUS, state_topic); - TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP.getChipId(), SettingsText(SET_FRIENDLYNAME1), + TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP_getChipId(), SettingsText(SET_FRIENDLYNAME1), ModuleName().c_str(), my_version, my_image); TryResponseAppend_P(PSTR("}")); } @@ -658,7 +658,7 @@ void HAssAnnounceStatusSensor(void) void HAssPublishStatus(void) { Response_P(PSTR("{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\"," - "\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"," + "\"" D_JSON_COREVERSION "\":\"" ARDUINO_CORE_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"," "\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_RESTARTREASON "\":\"%s\",\"" D_JSON_UPTIME "\":\"%s\"," "\"WiFi " D_JSON_LINK_COUNT "\":%d,\"WiFi " D_JSON_DOWNTIME "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d," "\"" D_JSON_BOOTCOUNT "\":%d,\"" D_JSON_SAVECOUNT "\":%d,\"" D_CMND_IPADDRESS "\":\"%s\"," diff --git a/tasmota/xdrv_20_hue.ino b/tasmota/xdrv_20_hue.ino index c816eed02..32a852b50 100644 --- a/tasmota/xdrv_20_hue.ino +++ b/tasmota/xdrv_20_hue.ino @@ -192,7 +192,7 @@ String GetHueUserId(void) { char userid[7]; - snprintf_P(userid, sizeof(userid), PSTR("%03x"), ESP.getChipId()); + snprintf_P(userid, sizeof(userid), PSTR("%03x"), ESP_getChipId()); return String(userid); } @@ -786,7 +786,7 @@ void HueGroups(String *path) String response = "{}"; uint8_t maxhue = (devices_present > MAX_HUE_DEVICES) ? MAX_HUE_DEVICES : devices_present; //AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups (%s)"), path->c_str()); - + if (path->endsWith("/0")) { response = FPSTR(HUE_GROUP0_STATUS_JSON); String lights = F("\"1\""); @@ -795,7 +795,7 @@ void HueGroups(String *path) lights += EncodeLightId(i); lights += "\""; } - + #ifdef USE_ZIGBEE ZigbeeHueGroups(&response); #endif // USE_ZIGBEE diff --git a/tasmota/xdrv_21_wemo.ino b/tasmota/xdrv_21_wemo.ino index 85d462876..cb3566f89 100644 --- a/tasmota/xdrv_21_wemo.ino +++ b/tasmota/xdrv_21_wemo.ino @@ -42,7 +42,7 @@ String WemoSerialnumber(void) { char serial[16]; - snprintf_P(serial, sizeof(serial), PSTR("201612K%08X"), ESP.getChipId()); + snprintf_P(serial, sizeof(serial), PSTR("201612K%08X"), ESP_getChipId()); return String(serial); } From 1054abcfe49dc0f8662055c1259896e51c455bd4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:48:01 +0200 Subject: [PATCH 19/35] Delete platformio_override_esp32.ini --- platformio_override_esp32.ini | 104 ---------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 platformio_override_esp32.ini diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini deleted file mode 100644 index babc261cc..000000000 --- a/platformio_override_esp32.ini +++ /dev/null @@ -1,104 +0,0 @@ -; -; Example PlatformIO Project Configuration Override for ESP32 *** -; Changes done here override settings in platformio.ini *** -; -; to build Tasmota ESP32 copy to platformio_override.ini *** -; -; Please visit documentation for the options and examples -; http://docs.platformio.org/en/stable/projectconf.html -; - - -[platformio] -; *** Build/upload environment -;monitor_port = COM5 -default_envs = -; *** Uncomment the line(s) below to select version(s) - tasmota - tasmota32 -; tasmota32-minimal -; tasmota32-lite -; tasmota32-knx -; tasmota32-sensors -; tasmota32-display -; tasmota32-ir -; tasmota32-ircustom -; tasmota32-DE -; tasmota32-NL - -[env32] -; uncomment this for all other tasmota32 builds -[env:tasmota32] -framework = ${common.framework} -platform = ${common32.platform} -platform_packages = ${common32.platform_packages} -board = ${common32.board} -board_build.ldscript = ${common32.board_build.ldscript} -board_build.flash_mode = ${common32.board_build.flash_mode} -board_build.f_cpu = ${common32.board_build.f_cpu} -build_unflags = ${common32.build_unflags} -build_flags = ${common32.build_flags} -monitor_speed = ${common32.monitor_speed} -upload_port = ${common32.upload_port} -upload_resetmethod = ${common32.upload_resetmethod} -upload_speed = ${common32.upload_speed} -extra_scripts = ${common32.extra_scripts} -lib_extra_dirs = ${common32.lib_extra_dirs} -lib_ignore = ${common32.lib_ignore} - -; uncomment this for all other tasmota32 builds -;[env:tasmota32] - -[env:tasmota32-minimal] -build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL -[env:tasmota32-lite] -build_flags = ${common.build_flags} -DFIRMWARE_LITE -[env:tasmota32-knx] -build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION -[env:tasmota32-sensors] -build_flags = ${common.build_flags} -DFIRMWARE_SENSORS -[env:tasmota32-display] -build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS -[env:tasmota32-ir] -build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR -[env:tasmota32-ircustom] -build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -[env:tasmota32-DE] -build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE -[env:tasmota32-NL] -build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL - -[common32] -platform = espressif32@1.12.0 -platform_packages = -board = wemos_d1_mini32 -board_build.ldscript = esp32_out.ld -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = 921600 -extra_scripts = ${common.extra_scripts} - -build_flags = - -D BUFFER_LENGTH=128 - -D MQTT_MAX_PACKET_SIZE=1200 - -D uint32=uint32_t - -D uint16=uint16_t - -D uint8=uint8_t - -D sint8_t=int8_t - -D sint32_t=int32_t - -D sint16_t=int16_t - -D memcpy_P=memcpy - -D memcmp_P=memcmp -; -D USE_CONFIG_OVERRIDE - -lib_extra_dirs = - libesp32 - -lib_ignore = - ILI9488 - SSD3115 - cc1101 From 81627bbf0e7a56febcb5595ffa413faa3fb39bd0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:49:10 +0200 Subject: [PATCH 20/35] Update platformio.ini --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 6a3820d02..e419aa810 100755 --- a/platformio.ini +++ b/platformio.ini @@ -12,6 +12,7 @@ src_dir = tasmota build_dir = .pioenvs build_cache_dir = .cache extra_configs = platformio_tasmota_env.ini + platformio_tasmota_env32.ini platformio_override.ini ; *** Build/upload environment From 1bf133078854abc9071f088f3363601ff6fdb8a7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:49:54 +0200 Subject: [PATCH 21/35] Add files via upload --- platformio_override_esp32.ini | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 platformio_override_esp32.ini diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini new file mode 100644 index 000000000..5c4afdafa --- /dev/null +++ b/platformio_override_esp32.ini @@ -0,0 +1,105 @@ +; +; Example PlatformIO Project Configuration Override for ESP32 *** +; Changes done here override settings in platformio.ini *** +; +; to build Tasmota ESP32 copy to platformio_override.ini *** +; +; Please visit documentation for the options and examples +; http://docs.platformio.org/en/stable/projectconf.html +; + + +[platformio] +; *** Build/upload environment +;monitor_port = COM5 +default_envs = +; *** Uncomment the line(s) below to select version(s) + tasmota + tasmota32 +; tasmota32-minimal +; tasmota32-lite +; tasmota32-knx +; tasmota32-sensors +; tasmota32-display +; tasmota32-ir +; tasmota32-ircustom +; tasmota32-DE +; tasmota32-NL + +[env32] +; uncomment this for all other tasmota32 builds +[env:tasmota32] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} + +; uncomment this for all other tasmota32 builds +;[env:tasmota32] + +[env:tasmota32-minimal] +build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL +[env:tasmota32-lite] +build_flags = ${common.build_flags} -DFIRMWARE_LITE +[env:tasmota32-knx] +build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION +[env:tasmota32-sensors] +build_flags = ${common.build_flags} -DFIRMWARE_SENSORS +[env:tasmota32-display] +build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS +[env:tasmota32-ir] +build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR +[env:tasmota32-ircustom] +build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} +[env:tasmota32-DE] +build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE +[env:tasmota32-NL] +build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL + +[common32] +platform = espressif32@1.12.0 +platform_packages = +board = wemos_d1_mini32 +board_build.ldscript = esp32_out.ld +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = 921600 +extra_scripts = ${common.extra_scripts} + +build_flags = + -D BUFFER_LENGTH=128 + -D MQTT_MAX_PACKET_SIZE=1200 + -D uint32=uint32_t + -D uint16=uint16_t + -D uint8=uint8_t + -D sint8_t=int8_t + -D sint32_t=int32_t + -D sint16_t=int16_t + -D memcpy_P=memcpy + -D memcmp_P=memcmp +; -D USE_CONFIG_OVERRIDE + +lib_extra_dirs = + libesp32 + +lib_ignore = + ILI9488 + SSD3115 + cc1101 + ArduinoNTPd From 10a1269c32ccb38ba295314d520db5c62766607c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:53:33 +0200 Subject: [PATCH 22/35] Update platformio_override_sample.ini --- platformio_override_sample.ini | 95 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 70be7c34e..03e49883f 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -24,6 +24,14 @@ default_envs = ; tasmota-sensors ; tasmota-display ; tasmota-ir +; tasmota32 +; tasmota32-minimal +; tasmota32-lite +; tasmota32-knx +; tasmota32-sensors +; tasmota32-display +; tasmota32-ir +; tasmota32-ircustom [common] @@ -70,9 +78,6 @@ extra_scripts = ${scripts_defaults.extra_scripts} [core_active] ; Select one core set for platform and build_flags -;platform = ${core_2_6_1.platform} -;platform_packages = ${core_2_6_1.platform_packages} -;build_flags = ${core_2_6_1.build_flags} ;platform = ${core_2_6_3.platform} ;platform_packages = ${core_2_6_3.platform_packages} @@ -87,51 +92,6 @@ build_flags = ${tasmota_feature_stage.build_flags} ;build_flags = ${core_stage.build_flags} -[core_2_6_1] -; *** Esp8266 core for Arduino version 2.6.1 -platform = espressif8266@2.3.0 -platform_packages = -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Teagle.flash.1m.ld - -DBEARSSL_SSL_BASIC -; NONOSDK221 -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK221 -; NONOSDK22x_190313 -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190313 -; NONOSDK22x_190703 = 2.2.1+100-dev(38a443e) (Tasmota default) (Firmware 2K smaller than NONOSDK22x_191105) - -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703 -; NONOSDK22x_191024 = 2.2.1+111-dev(5ab15d1) -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191024 -; NONOSDK22x_191105 = 2.2.1+113-dev(bb83b9b) -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191105 -; NONOSDK3V0 (known issues) -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -; lwIP 2 - Low Memory -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -; lwIP 2 - Higher Bandwidth -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -; lwIP 2 - Higher Bandwidth Low Memory no Features -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH -; lwIP 2 - Higher Bandwidth no Features (Tasmota default) - -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -; lwIP 2 - Higher Bandwidth IPv6 (use ONLY if you need IPv6, experimental!) -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH -; VTABLES in Flash (Tasmota default) - -DVTABLES_IN_FLASH -; VTABLES in Heap -; -DVTABLES_IN_DRAM -; VTABLES in IRAM -; -DVTABLES_IN_IRAM -; enable one option set -> No exception recommended -; No exception code in firmware - -fno-exceptions - -lstdc++ -; Exception code in firmware /needs much space! 90k -; -fexceptions -; -lstdc++-exc - [core_2_6_3] ; *** Esp8266 core for Arduino version 2.6.3 platform = espressif8266@2.4.0 @@ -268,3 +228,42 @@ build_flags = ${esp82xx_defaults.build_flags} ; *** Debug version used for PlatformIO Home Project Inspection [env:tasmota-debug] build_type = debug + + +; *** Experimental ESP32 Tasmota version *** +; *** expect the unexpected. Many features not working!!! *** + +[common32] +platform = espressif32@1.12.0 +platform_packages = +board = wemos_d1_mini32 +board_build.ldscript = esp32_out.ld +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = 921600 +extra_scripts = ${common.extra_scripts} + +build_flags = + -D BUFFER_LENGTH=128 + -D MQTT_MAX_PACKET_SIZE=1200 + -D uint32=uint32_t + -D uint16=uint16_t + -D uint8=uint8_t + -D sint8_t=int8_t + -D sint32_t=int32_t + -D sint16_t=int16_t + -D memcpy_P=memcpy + -D memcmp_P=memcmp +; -D USE_CONFIG_OVERRIDE + +lib_extra_dirs = + libesp32 + +lib_ignore = + ILI9488 + SSD3115 + cc1101 From a7074c667f02b877edf076deefe2df8b4dea1674 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:59:05 +0200 Subject: [PATCH 23/35] Delete platformio_override_esp32.ini --- platformio_override_esp32.ini | 105 ---------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 platformio_override_esp32.ini diff --git a/platformio_override_esp32.ini b/platformio_override_esp32.ini deleted file mode 100644 index 5c4afdafa..000000000 --- a/platformio_override_esp32.ini +++ /dev/null @@ -1,105 +0,0 @@ -; -; Example PlatformIO Project Configuration Override for ESP32 *** -; Changes done here override settings in platformio.ini *** -; -; to build Tasmota ESP32 copy to platformio_override.ini *** -; -; Please visit documentation for the options and examples -; http://docs.platformio.org/en/stable/projectconf.html -; - - -[platformio] -; *** Build/upload environment -;monitor_port = COM5 -default_envs = -; *** Uncomment the line(s) below to select version(s) - tasmota - tasmota32 -; tasmota32-minimal -; tasmota32-lite -; tasmota32-knx -; tasmota32-sensors -; tasmota32-display -; tasmota32-ir -; tasmota32-ircustom -; tasmota32-DE -; tasmota32-NL - -[env32] -; uncomment this for all other tasmota32 builds -[env:tasmota32] -framework = ${common.framework} -platform = ${common32.platform} -platform_packages = ${common32.platform_packages} -board = ${common32.board} -board_build.ldscript = ${common32.board_build.ldscript} -board_build.flash_mode = ${common32.board_build.flash_mode} -board_build.f_cpu = ${common32.board_build.f_cpu} -build_unflags = ${common32.build_unflags} -build_flags = ${common32.build_flags} -monitor_speed = ${common32.monitor_speed} -upload_port = ${common32.upload_port} -upload_resetmethod = ${common32.upload_resetmethod} -upload_speed = ${common32.upload_speed} -extra_scripts = ${common32.extra_scripts} -lib_extra_dirs = ${common32.lib_extra_dirs} -lib_ignore = ${common32.lib_ignore} - -; uncomment this for all other tasmota32 builds -;[env:tasmota32] - -[env:tasmota32-minimal] -build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL -[env:tasmota32-lite] -build_flags = ${common.build_flags} -DFIRMWARE_LITE -[env:tasmota32-knx] -build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION -[env:tasmota32-sensors] -build_flags = ${common.build_flags} -DFIRMWARE_SENSORS -[env:tasmota32-display] -build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS -[env:tasmota32-ir] -build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR -[env:tasmota32-ircustom] -build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -[env:tasmota32-DE] -build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE -[env:tasmota32-NL] -build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL - -[common32] -platform = espressif32@1.12.0 -platform_packages = -board = wemos_d1_mini32 -board_build.ldscript = esp32_out.ld -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = 921600 -extra_scripts = ${common.extra_scripts} - -build_flags = - -D BUFFER_LENGTH=128 - -D MQTT_MAX_PACKET_SIZE=1200 - -D uint32=uint32_t - -D uint16=uint16_t - -D uint8=uint8_t - -D sint8_t=int8_t - -D sint32_t=int32_t - -D sint16_t=int16_t - -D memcpy_P=memcpy - -D memcmp_P=memcmp -; -D USE_CONFIG_OVERRIDE - -lib_extra_dirs = - libesp32 - -lib_ignore = - ILI9488 - SSD3115 - cc1101 - ArduinoNTPd From f8a63c3a7c2c654c5dee1f66492dff11876fc471 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 20:00:55 +0200 Subject: [PATCH 24/35] Add files via upload --- platformio_tasmota_env32.ini | 539 +++++++++++++++++++++++++++++++++++ 1 file changed, 539 insertions(+) create mode 100644 platformio_tasmota_env32.ini diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini new file mode 100644 index 000000000..fb280f1bc --- /dev/null +++ b/platformio_tasmota_env32.ini @@ -0,0 +1,539 @@ +[env:tasmota32] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} + +[env:tasmota32-minimal] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DFIRMWARE_MINIMAL + +[env:tasmota32-lite] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DFIRMWARE_LITE + +[env:tasmota32-knx] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DFIRMWARE_KNX_NO_EMULATION + +[env:tasmota32-sensors] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DFIRMWARE_SENSORS + +[env:tasmota32-display] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DFIRMWARE_DISPLAYS + +[env:tasmota32-ir] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR + +[env:tasmota32-ircustom] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} ${irremoteesp8266_full.build_flags} + +[env:tasmota32-BG] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=bg-BG + +[env:tasmota32-BR] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=pt-BR + +[env:tasmota32-CN] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=zh-CN + +[env:tasmota32-CZ] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=cs-CZ + +[env:tasmota32-DE] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=de-DE + +[env:tasmota32-ES] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=es-ES + +[env:tasmota32-FR] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=fr-FR + +[env:tasmota32-GR] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=el-GR + +[env:tasmota32-HE] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=he-HE + +[env:tasmota32-HU] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=hu-HU + +[env:tasmota32-IT] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=it-IT + +[env:tasmota32-KO] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=ko-KO + +[env:tasmota32-NL] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=nl-NL + +[env:tasmota32-PL] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=pl-PL + +[env:tasmota32-PT] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=pt-PT + +[env:tasmota32-RO] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=ro-RO + +[env:tasmota32-RU] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=ru-RU + +[env:tasmota32-SE] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=sv-SE + +[env:tasmota32-SK] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=sk-SK + +[env:tasmota32-TR] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=tr-TR + +[env:tasmota32-TW] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=zh-TW + +[env:tasmota32-UK] +framework = ${common.framework} +platform = ${common32.platform} +platform_packages = ${common32.platform_packages} +board = ${common32.board} +board_build.ldscript = ${common32.board_build.ldscript} +board_build.flash_mode = ${common32.board_build.flash_mode} +board_build.f_cpu = ${common32.board_build.f_cpu} +monitor_speed = ${common32.monitor_speed} +upload_port = ${common32.upload_port} +upload_resetmethod = ${common32.upload_resetmethod} +upload_speed = ${common32.upload_speed} +extra_scripts = ${common32.extra_scripts} +lib_extra_dirs = ${common32.lib_extra_dirs} +lib_ignore = ${common32.lib_ignore} +build_unflags = ${common32.build_unflags} +build_flags = ${common32.build_flags} -DMY_LANGUAGE=uk-UA From 375cf778eae7a4181ae03d3b1d03f50683e15586 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 13 Apr 2020 20:28:01 +0200 Subject: [PATCH 25/35] Removed not needed options to compile... firmware variants --- platformio_override_sample.ini | 9 --------- 1 file changed, 9 deletions(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 03e49883f..925374b66 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -41,15 +41,6 @@ build_flags = ${core_active.build_flags} ; *** Use settings from file user_config_override.h -DUSE_CONFIG_OVERRIDE -; *** Optional Firmware configurations -; -DFIRMWARE_MINIMAL -; -DFIRMWARE_SENSORS -; -DFIRMWARE_LITE -; -DFIRMWARE_KNX_NO_EMULATION -; -DFIRMWARE_DISPLAYS -; -DFIRMWARE_IR -; -DFIRMWARE_IR_CUSTOM - ; *** Optional Debug messages ; -DDEBUG_TASMOTA_CORE ; -DDEBUG_TASMOTA_DRIVER From cb0f6dd3ebdb79f29e10e154640a4af6730f7b4c Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 13 Apr 2020 21:00:52 +0200 Subject: [PATCH 26/35] Add ``DimmerRange`` for PWM lights (#8120) --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 3b1e9afcc..ede692fb4 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -31,6 +31,7 @@ - Add support for AS3935 Lightning Sensor by device111 (#8130) - Fix prevent multiple pings to run concurrently - Fix Scheme 2-4 brightness when SetOption68 1 (#8058) +- Add ``DimmerRange`` for PWM lights (#8120) ### 8.2.0.2 20200328 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index b85c2373b..37db1002e 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -293,6 +293,9 @@ struct LIGHT { uint16_t fade_end_10[LST_MAX]; // 10 bits resolution target channel values uint16_t fade_duration = 0; // duration of fade in milliseconds uint32_t fade_start = 0; // fade start time in milliseconds, compared to millis() + + uint16_t pwm_min = 0; // minimum value for PWM, from DimmerRange, 0..1023 + uint16_t pwm_max = 1023; // maxumum value for PWM, from DimmerRange, 0..1023 } Light; power_t LightPower(void) @@ -1270,6 +1273,25 @@ bool LightModuleInit(void) return (light_type > LT_BASIC); } +// compute actual PWM min/max values from DimmerRange +// must be called when DimmerRange is changed or LedTable +void LightCalcPWMRange(void) { + uint16_t pwm_min, pwm_max; + + pwm_min = change8to10(LightStateClass::DimmerToBri(Settings.dimmer_hw_min)); // default 0 + pwm_max = change8to10(LightStateClass::DimmerToBri(Settings.dimmer_hw_max)); // default 100 + if (Settings.light_correction) { + pwm_min = ledGamma10_10(pwm_min); // apply gamma correction + pwm_max = ledGamma10_10(pwm_max); // 0..1023 + } + pwm_min = pwm_min > 0 ? changeUIntScale(pwm_min, 1, 1023, 1, Settings.pwm_range) : 0; // adapt range but keep zero and non-zero values + pwm_max = changeUIntScale(pwm_max, 1, 1023, 1, Settings.pwm_range); // pwm_max cannot be zero + + Light.pwm_min = pwm_min; + Light.pwm_max = pwm_max; + //AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max); +} + void LightInit(void) { Light.device = devices_present; @@ -1291,6 +1313,7 @@ void LightInit(void) // if RGBW or RGBCW, and SetOption37 >= 128, we manage RGB and W separately Light.device--; // we take the last two devices as lights } + LightCalcPWMRange(); #ifdef DEBUG_LIGHT AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d devices_present=%d", Light.pwm_multi_channels, Light.subtype, Light.device, devices_present); @@ -1904,13 +1927,9 @@ void LightAnimate(void) } // final adjusments for PMW, post-gamma correction - uint16_t min = 1; -#ifdef USE_PWM_DIMMER - if (PWM_DIMMER == my_module_type) min = Settings.dimmer_hw_min; -#endif // USE_PWM_DIMMER for (uint32_t i = 0; i < LST_MAX; i++) { // scale from 0..1023 to 0..pwm_range, but keep any non-zero value to at least 1 - cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, min, Settings.pwm_range) : 0; + cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, 1, Settings.pwm_range) : 0; } // apply port remapping on both 8 bits and 10 bits versions @@ -2085,7 +2104,9 @@ void LightSetOutputs(const uint16_t *cur_col_10) { for (uint32_t i = 0; i < (Light.subtype - Light.pwm_offset); i++) { if (pin[GPIO_PWM1 +i] < 99) { //AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d"), i, cur_col_10[i]); - analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - cur_col_10[(i + Light.pwm_offset)] : cur_col_10[(i + Light.pwm_offset)]); + uint16_t cur_col = cur_col_10[i + Light.pwm_offset]; + cur_col = cur_col > 0 ? changeUIntScale(cur_col, 0, Settings.pwm_range, Light.pwm_min, Light.pwm_max) : 0; // shrink to the range of pwm_min..pwm_max + analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - cur_col : cur_col); } } } @@ -2742,9 +2763,8 @@ void CmndDimmerRange(void) Settings.dimmer_hw_min = parm[1]; Settings.dimmer_hw_max = parm[0]; } -#ifdef ESP8266 - if (PWM_DIMMER != my_module_type) restart_flag = 2; -#endif // ESP8266 + LightCalcPWMRange(); + Light.update = true; } Response_P(PSTR("{\"" D_CMND_DIMMER_RANGE "\":{\"Min\":%d,\"Max\":%d}}"), Settings.dimmer_hw_min, Settings.dimmer_hw_max); } @@ -2765,6 +2785,7 @@ void CmndLedTable(void) Settings.light_correction ^= 1; break; } + LightCalcPWMRange(); Light.update = true; } ResponseCmndStateText(Settings.light_correction); From 2224e56e1b8aec6ca82d3e73f84e6ae55f66350e Mon Sep 17 00:00:00 2001 From: Barbudor Date: Mon, 13 Apr 2020 23:05:12 +0200 Subject: [PATCH 27/35] Added %utctime% as rules variable Was in the docs but not implemented --- tasmota/xdrv_10_rules.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 2509d6f6f..4146fa382 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -476,6 +476,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) RulesVarReplace(commands, stemp, SettingsText(SET_MEM1 +i)); } RulesVarReplace(commands, F("%TIME%"), String(MinutesPastMidnight())); + RulesVarReplace(commands, F("%UTCTIME%"), String(UtcTime())); RulesVarReplace(commands, F("%UPTIME%"), String(MinutesUptime())); RulesVarReplace(commands, F("%TIMESTAMP%"), GetDateAndTime(DT_LOCAL)); RulesVarReplace(commands, F("%TOPIC%"), SettingsText(SET_MQTT_TOPIC)); From 2124d03f53830fc4ea20c3fed9701504c27e1866 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Mon, 13 Apr 2020 23:18:05 +0200 Subject: [PATCH 28/35] Added *.code-workspace to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 500f720ec..caa3d240b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ platformio_override.ini .vscode/c_cpp_properties.json .vscode/launch.json *.bak +*.code-workspace \ No newline at end of file From f7d5e2d018f0633e107e3beb8d1a4d560e411ca1 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Mon, 13 Apr 2020 17:55:12 -0500 Subject: [PATCH 29/35] Fix Color<1,2> with palette --- tasmota/my_user_config.h | 2 +- tasmota/xdrv_04_light.ino | 153 +++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 84 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index f6ec92670..97476820f 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -437,7 +437,7 @@ #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) -#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) +#define USE_LIGHT_PALETTE // Add support for color palette (+0k7 code) // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 37db1002e..eda02eafb 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1694,7 +1694,8 @@ void LightCycleColor(int8_t direction) else { Light.wheel += direction; if (Light.wheel >= Light.palette_count) { - Light.wheel = (direction < 0 ? Light.palette_count - 1 : 0); + Light.wheel = 0; + if (direction < 0) Light.wheel = Light.palette_count - 1; } } LightSetPaletteEntry(); @@ -2267,13 +2268,16 @@ void LightHandleDevGroupItem(void) break; case DGR_ITEM_LIGHT_FIXED_COLOR: if (Light.subtype >= LST_RGBW) { + send_state = true; #ifdef USE_LIGHT_PALETTE - value = value % (Light.palette_count ? Light.palette_count : MAX_FIXED_COLOR); - if (Light.palette_count || value) { -#else // USE_LIGHT_PALETTE + if (Light.palette_count) { + Light.wheel = value % Light.palette_count; + LightSetPaletteEntry(); + break; + } +#endif // !USE_LIGHT_PALETTE value = value % MAX_FIXED_COLOR; if (value) { -#endif // !USE_LIGHT_PALETTE bool save_decimal_text = Settings.flag.decimal_text; char str[16]; LightColorEntry(str, sprintf_P(str, PSTR("%u"), value)); @@ -2292,7 +2296,6 @@ void LightHandleDevGroupItem(void) Light.power = 0xff; restore_power = true; } - send_state = true; } break; case DGR_ITEM_LIGHT_FADE: @@ -2338,6 +2341,9 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length) char *str; uint32_t entry_type = 0; // Invalid uint8_t value = Light.fixed_color_index; +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count) value = Light.wheel; +#endif // USE_LIGHT_PALETTE if (buffer[0] == '#') { // Optional hexadecimal entry buffer++; @@ -2346,14 +2352,32 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length) if (Light.subtype >= LST_RGB) { char option = (1 == buffer_length) ? buffer[0] : '\0'; - if (('+' == option) && (Light.fixed_color_index < MAX_FIXED_COLOR)) { - value++; + if ('+' == option) { +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count || Light.fixed_color_index < MAX_FIXED_COLOR) { +#else // USE_LIGHT_PALETTE + if (Light.fixed_color_index < MAX_FIXED_COLOR) { +#endif // !USE_LIGHT_PALETTE + value++; + } } - else if (('-' == option) && (Light.fixed_color_index > 1)) { - value--; + else if ('-' == option) { +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count || Light.fixed_color_index > 1) { +#else // USE_LIGHT_PALETTE + if (Light.fixed_color_index > 1) { +#endif // !USE_LIGHT_PALETTE + value--; + } } else { value = atoi(buffer); +#ifdef USE_LIGHT_PALETTE + value--; +#endif // USE_LIGHT_PALETTE } +#ifdef USE_LIGHT_PALETTE + if (Light.palette_count) value = value % Light.palette_count; +#endif // USE_LIGHT_PALETTE } memset(&Light.entry_color, 0x00, sizeof(Light.entry_color)); @@ -2378,6 +2402,13 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length) } entry_type = 1; // Hexadecimal } +#ifdef USE_LIGHT_PALETTE + else if (Light.palette_count) { + Light.wheel = value; + memcpy_P(&Light.entry_color, &Light.palette[value * LST_MAX], LST_MAX); + entry_type = 1; // Hexadecimal + } +#endif // USE_LIGHT_PALETTE else if ((Light.subtype >= LST_RGB) && (value > 0) && (value <= MAX_FIXED_COLOR)) { Light.fixed_color_index = value; memcpy_P(&Light.entry_color, &kFixedColor[value -1], 3); @@ -2409,48 +2440,20 @@ void CmndSupportColor(void) { bool valid_entry = false; bool coldim = false; -#ifdef USE_LIGHT_PALETTE - uint8_t * color_ptr; -#endif // USE_LIGHT_PALETTE if (XdrvMailbox.data_len > 0) { -#ifdef USE_LIGHT_PALETTE - if (Light.palette_count) { - if (XdrvMailbox.data_len == 1 && ('+' == XdrvMailbox.data[0] || '-' == XdrvMailbox.data[0])) { - int8_t direction = ('+' == XdrvMailbox.data[0] ? 1 : -1); - Light.wheel += direction; - if (Light.wheel >= Light.palette_count) { - Light.wheel = (direction < 0 ? Light.palette_count - 1 : 0); - } - } - else { - Light.wheel = (atoi(XdrvMailbox.data) - 1); - } - color_ptr = &Light.palette[Light.wheel * LST_MAX]; - valid_entry = true; - } - else { - color_ptr = Light.entry_color; -#endif // USE_LIGHT_PALETTE - valid_entry = LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len); -#ifdef USE_LIGHT_PALETTE - } -#endif // USE_LIGHT_PALETTE + valid_entry = LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len); if (valid_entry) { if (XdrvMailbox.index <= 2) { // Color(1), 2 #ifdef USE_LIGHT_PALETTE - if (Light.palette_count && XdrvMailbox.index == 1) { + if (Light.palette_count && XdrvMailbox.index == 2) { LightSetPaletteEntry(); } else { #endif // USE_LIGHT_PALETTE uint32_t old_bri = light_state.getBri(); // change all channels to specified values -#ifdef USE_LIGHT_PALETTE - light_controller.changeChannels(color_ptr); -#else // USE_LIGHT_PALETTE light_controller.changeChannels(Light.entry_color); -#endif // !USE_LIGHT_PALETTE if (2 == XdrvMailbox.index) { // If Color2, set back old brightness light_controller.changeBri(old_bri); @@ -2626,6 +2629,9 @@ void CmndScheme(void) uint32_t parm[2]; if (ParseParameters(2, parm) > 1) { Light.wheel = parm[1]; +#ifdef USE_LIGHT_PALETTE + Light.wheel--; +#endif // USE_LIGHT_PALETTE } Settings.light_scheme = XdrvMailbox.payload; #ifdef USE_DEVICE_GROUPS @@ -2873,71 +2879,52 @@ void CmndWakeupDuration(void) void CmndPalette(void) { uint8_t * palette_entry; - char * color; char * p; // Palette Color[ ...] if (XdrvMailbox.data_len) { Light.wheel = 0; + Light.palette_count = 0; if (Light.palette) { free(Light.palette); Light.palette = nullptr; - Light.palette_count = 0; } if (XdrvMailbox.data_len > 1 || XdrvMailbox.data[0] != '0') { - for (int pass = 0;; pass++) { - Light.palette_count = 0; - color = XdrvMailbox.data; - for (;;) { - p = strchr(color, ' '); - if (p) *p = 0; - color = Trim(color); - if (*color && LightColorEntry(color, strlen(color))) { - if (pass) { - memcpy(palette_entry, Light.entry_color, LST_MAX); - if (!Light.pwm_multi_channels && LST_COLDWARM == Light.subtype) { - palette_entry[3] = palette_entry[0]; - palette_entry[4] = palette_entry[1]; - } - palette_entry += LST_MAX; - } - Light.palette_count++; - } - if (!p) break; - *p = ' '; - color = p + 1; + uint8_t palette_count = 0; + char * color = XdrvMailbox.data; + if (!(Light.palette = (uint8_t *)malloc(255 * Light.subtype))) return; + palette_entry = Light.palette; + for (;;) { + p = strchr(color, ' '); + if (p) *p = 0; + color = Trim(color); + if (*color && LightColorEntry(color, strlen(color))) { + memcpy(palette_entry, Light.entry_color, Light.subtype); + palette_entry += Light.subtype; + palette_count++; } - if (pass) break; - if (!(Light.palette = (uint8_t *)malloc(Light.palette_count * LST_MAX))) return; - palette_entry = Light.palette; + if (!p) break; + color = p + 1; } + if (!(Light.palette = (uint8_t *)realloc(Light.palette, palette_count * Light.subtype))) return; + Light.palette_count = palette_count; } } char palette_str[5 * Light.subtype * Light.palette_count + 3]; - const char * fmt; p = palette_str; *p++ = '['; if (Light.palette_count) { palette_entry = Light.palette; - if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output - for (int entry = 0; entry < Light.palette_count; entry++) { + for (int entry = 0; entry < Light.palette_count; entry++) { + if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output *p++ = '"'; - for (uint32_t i = 0; i < Light.subtype; i++) { - if (i > 0) *p++ = ','; - p += sprintf_P(p, PSTR("%d"), palette_entry[i]); - } - palette_entry += LST_MAX; } - *p++ = '"'; - *p++ = ','; - } - else { - for (int entry = 0; entry < Light.palette_count; entry++) { - for (uint32_t i = 0; i < Light.subtype; i++) { - p += sprintf_P(p, PSTR("%02X"), palette_entry[i]); - } - palette_entry += LST_MAX; + memcpy(Light.current_color, palette_entry, Light.subtype); + LightGetColor(p); + p += strlen(p); + if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output + *p++ = '"'; } *p++ = ','; } From 9bebc969367d1f61dfae7417c67eba2ffa308f25 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 14 Apr 2020 10:52:10 +0200 Subject: [PATCH 30/35] Update platformio.ini --- platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index e419aa810..6a3820d02 100755 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,6 @@ src_dir = tasmota build_dir = .pioenvs build_cache_dir = .cache extra_configs = platformio_tasmota_env.ini - platformio_tasmota_env32.ini platformio_override.ini ; *** Build/upload environment From 3820999747dbaff7dc1f9798f7121b1ce3d647e4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 14 Apr 2020 10:55:00 +0200 Subject: [PATCH 31/35] Better placing of ESP32 env... will be only activated when platformio_override is active --- platformio_override_sample.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 925374b66..aa979497a 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -11,6 +11,7 @@ [platformio] +extra_configs = platformio_tasmota_env32.ini ; *** Build/upload environment default_envs = From 35782c41aa652cc03bd3f0091bdac29fd01d35b6 Mon Sep 17 00:00:00 2001 From: Mickael Gaillard Date: Tue, 14 Apr 2020 11:02:36 +0200 Subject: [PATCH 32/35] Add APDS-9960 chip A8 sensor support Signed-off-by: Mickael Gaillard --- tasmota/xsns_27_apds9960.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/xsns_27_apds9960.ino b/tasmota/xsns_27_apds9960.ino index cdb390c73..1751eb947 100644 --- a/tasmota/xsns_27_apds9960.ino +++ b/tasmota/xsns_27_apds9960.ino @@ -56,6 +56,7 @@ #define APDS9960_CHIPID_1 0xAB #define APDS9960_CHIPID_2 0x9C +#define APDS9960_CHIPID_3 0xA8 #define APDS9930_CHIPID_1 0x12 // we will check, if someone got an incorrect sensor #define APDS9930_CHIPID_2 0x39 // there are case reports about "accidentially bought" 9930's @@ -1884,7 +1885,7 @@ void APDS9960_detect(void) if (APDS9960type || I2cActive(APDS9960_I2C_ADDR)) { return; } APDS9960type = I2cRead8(APDS9960_I2C_ADDR, APDS9960_ID); - if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2) { + if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2 || APDS9960type == APDS9960_CHIPID_3) { if (APDS9960_init()) { I2cSetActiveFound(APDS9960_I2C_ADDR, APDS9960stype); From ba01cb2046aa19dc21b1749c1ecae5722c271aee Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 14 Apr 2020 11:58:24 +0200 Subject: [PATCH 33/35] Fix GlobalTemp and GlobalHum Fix GlobalTemp and GlobalHum (#8156) --- BUILDS.md | 2 ++ tasmota/support_command.ino | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/BUILDS.md b/BUILDS.md index 04711b1c6..36a0bb48a 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -117,6 +117,8 @@ | USE_AHT1x | - | - | - | - | - | - | - | | USE_HDC1080 | - | - | - | - | - | - | - | | USE_WEMOS_MOTOR_V1 | - | - | - | - | x | - | - | +| USE_IAQ | - | - | - | - | x | - | - | +| USE_AS3935 | - | - | - | - | x | - | - | | | | | | | | | | | Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks | USE_SPI | - | - | - | - | - | - | x | diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 383e8d7b5..bfbd38078 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -579,23 +579,28 @@ void CmndHumOffset(void) void CmndGlobalTemp(void) { if (XdrvMailbox.data_len > 0) { - int value = (int)(CharToFloat(XdrvMailbox.data) * 10); - if ((value > -401) && (value < 801)) { - ConvertTemp(value); + float temperature = CharToFloat(XdrvMailbox.data); + if (!isnan(temperature) && Settings.flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit + temperature = (temperature - 32) / 1.8; // Celsius + } + if ((temperature >= -50.0) && (temperature <= 100.0)) { + ConvertTemp(temperature); + global_update = 1; // Keep global values just entered valid } } - ResponseCmndFloat((float)(global_temperature) / 10, 1); + ResponseCmndFloat(global_temperature, 1); } void CmndGlobalHum(void) { if (XdrvMailbox.data_len > 0) { - int value = (int)(CharToFloat(XdrvMailbox.data) * 10); - if ((value > -10) && (value < 999)) { - ConvertHumidity(value); + float humidity = CharToFloat(XdrvMailbox.data); + if ((humidity >= 0.0) && (humidity <= 100.0)) { + ConvertHumidity(humidity); + global_update = 1; // Keep global values just entered valid } } - ResponseCmndFloat((float)(global_humidity) / 10, 1); + ResponseCmndFloat(global_humidity, 1); } void CmndSleep(void) From f3b149787511972ff7c6c0105e1564ef8e3c76f6 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 14 Apr 2020 12:11:15 +0200 Subject: [PATCH 34/35] update scripter script size on esp32 --- tasmota/xdrv_10_scripter.ino | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index e086adedb..fb8aa3706 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -65,6 +65,31 @@ keywords if then else endif, or, and are better readable for beginners (others m uint32_t EncodeLightId(uint8_t relay_id); uint32_t DecodeLightId(uint32_t hue_id); +#ifdef ESP32 + +#include "FS.h" +#include "SPIFFS.h" +void SaveFile(char *name,const uint8_t *buf,uint32_t len) { + File file = SPIFFS.open(name, FILE_WRITE); + if (!file) return; + file.write(buf, len); + file.close(); +} + +#define FORMAT_SPIFFS_IF_FAILED true + +void LoadFile(char *name,uint8_t *buf,uint32_t len) { + + if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){ + return; + } + File file = SPIFFS.open(name); + if (!file) return; + file.read(buf, len); + file.close(); +} +#endif + // offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution #define EPOCH_OFFSET 1546300800 @@ -3597,6 +3622,15 @@ void ScriptSaveSettings(void) { } #endif +#ifndef ESP32_SCRIPT_SIZE +#define ESP32_SCRIPT_SIZE 8192 +#endif + +#if defined(ESP32) && !defined(USE_24C256) && !defined(USE_SCRIPT_FATFS) + if (glob_script_mem.flags&1) { + SaveFile("/script.txt",(uint8_t*)glob_script_mem.script_ram,ESP32_SCRIPT_SIZE); + } +#endif } if (glob_script_mem.script_mem) { @@ -4820,6 +4854,7 @@ bool Xdrv10(uint8_t function) switch (function) { case FUNC_PRE_INIT: + //webcam_setup(); // set defaults to rules memory glob_script_mem.script_ram=Settings.rules[0]; glob_script_mem.script_size=MAX_SCRIPT_SIZE; @@ -4889,6 +4924,21 @@ bool Xdrv10(uint8_t function) } #endif + +#if defined(ESP32) && !defined(USE_24C256) && !defined(USE_SCRIPT_FATFS) + char *script; + script=(char*)calloc(ESP32_SCRIPT_SIZE+4,1); + if (!script) break; + LoadFile("/script.txt",(uint8_t*)script,ESP32_SCRIPT_SIZE); + glob_script_mem.script_ram=script; + glob_script_mem.script_size=ESP32_SCRIPT_SIZE; + script[ESP32_SCRIPT_SIZE-1]=0; + // use rules storage for permanent vars + glob_script_mem.script_pram=(uint8_t*)Settings.rules[0]; + glob_script_mem.script_pram_size=MAX_SCRIPT_SIZE; + glob_script_mem.flags=1; +#endif + // assure permanent memory is 4 byte aligned { uint32_t ptr=(uint32_t)glob_script_mem.script_pram; ptr&=0xfffffffc; From 07ce4315381cb9984d5139d22a380c88b1ec659c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 14 Apr 2020 12:25:21 +0200 Subject: [PATCH 35/35] Move ESP32 info --- ESP32README.md => libesp32/ESP32README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ESP32README.md => libesp32/ESP32README.md (100%) diff --git a/ESP32README.md b/libesp32/ESP32README.md similarity index 100% rename from ESP32README.md rename to libesp32/ESP32README.md