From b622c53cddca428b3098d2734d03c95097468590 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 14 Jun 2021 21:32:07 +0200 Subject: [PATCH] Esp32c3 fix template command and Web UI --- tasmota/support.ino | 3 ++- tasmota/xdrv_01_webserver.ino | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index 21037bea6..159187941 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1533,12 +1533,13 @@ void TemplateGpios(myio *gp) uint32_t j = 0; for (uint32_t i = 0; i < nitems(Settings->user_template.gp.io); i++) { #if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 + dest[i] = src[i]; #else if (6 == i) { j = 9; } if (8 == i) { j = 12; } -#endif dest[j] = src[i]; j++; +#endif } // 11 85 00 85 85 00 00 00 00 00 00 00 15 38 85 00 00 81 diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 8978a473e..e92650fe9 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -147,11 +147,8 @@ const char HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX[] PROGMEM = #if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 const char HTTP_SCRIPT_TEMPLATE2[] PROGMEM = - "j=0;" - "for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Skip GPIO 11-17 - "if(11==i){j=18;}" - "sk(g[i],j);" // Set GPIO - "j++;" + "for(i=0;i<" STR(MAX_USER_PINS) ";i++){" + "sk(g[i],i);" // Set GPIO "}"; #else // Now ESP32 and ESP8266 const char HTTP_SCRIPT_TEMPLATE2[] PROGMEM = @@ -1547,9 +1544,14 @@ void HandleTemplateConfiguration(void) { WSContentBegin(200, CT_PLAIN); WSContentSend_P(PSTR("%s}1"), AnyModuleName(module).c_str()); // NAME: Generic for (uint32_t i = 0; i < nitems(template_gp.io); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 +#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 + // ESP32C3 we always send all GPIOs, Flash are just hidden + WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]); +#else if (!FlashPin(i)) { WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]); } +#endif } WSContentSend_P(PSTR("}1%d}1%d"), flag, Settings->user_template_base); // FLAG: 1 BASE: 17 WSContentEnd(); @@ -1590,11 +1592,20 @@ void HandleTemplateConfiguration(void) { "
")); WSContentSend_P(HTTP_TABLE100); for (uint32_t i = 0; i < MAX_GPIO_PIN; i++) { +#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 + // ESP32C3 all gpios are in the template, flash are hidden + bool hidden = FlashPin(i); + WSContentSend_P(PSTR("" D_GPIO "%d"), + hidden ? PSTR(" hidden") : "", + RedPin(i) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? PSTR(" style='width:146px'") : "", i, i); + WSContentSend_P(PSTR(""), i); +#else if (!FlashPin(i)) { WSContentSend_P(PSTR("" D_GPIO "%d"), RedPin(i) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? PSTR(" style='width:146px'") : "", i, i); WSContentSend_P(PSTR(""), i); } +#endif } WSContentSend_P(PSTR("")); @@ -1632,10 +1643,14 @@ void TemplateSaveSettings(void) { uint32_t j = 0; for (uint32_t i = 0; i < nitems(Settings->user_template.gp.io); i++) { +#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 + snprintf_P(command, sizeof(command), PSTR("%s%s%d"), command, (i>0)?",":"", WebGetGpioArg(i)); +#else if (6 == i) { j = 9; } if (8 == i) { j = 12; } snprintf_P(command, sizeof(command), PSTR("%s%s%d"), command, (i>0)?",":"", WebGetGpioArg(j)); j++; +#endif } uint32_t flag = 0;