From e1d7416a36062ab832cdee4251ded26c1f02974c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 18 Apr 2020 18:10:41 +0200 Subject: [PATCH] Add features to ESP32 - Decided to support ONLY flash mode DOUT (no software change but allows for RX1/TX1) - Add GPIO9 (RX1) and GPIO10 (TX1) for hardware serial support - Add above two GPIOs to template - Moved basic ADC0 support from GPIO36 to GPIO33 --- tasmota/settings.h | 4 ++-- tasmota/support.ino | 9 --------- tasmota/support_command.ino | 4 ---- tasmota/tasmota_template.h | 7 ++++--- tasmota/tasmota_template_ESP32.h | 4 ++-- tasmota/xdrv_01_webserver.ino | 11 ++--------- 6 files changed, 10 insertions(+), 29 deletions(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index 2c3a22af4..e1b63beff 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -407,9 +407,9 @@ struct SYSCFG { char ex_mqtt_fulltopic[100]; // 558 #else // ESP32 myio my_gp; // 558 - 40 bytes (ESP32) - mytmplt user_template; // 580 - 35 bytes (ESP32) + mytmplt user_template; // 580 - 37 bytes (ESP32) - uint8_t free_esp32_5a3[25]; // 5A3 + uint8_t free_esp32_5a5[23]; // 5A5 #endif // ESP8266 - ESP32 SysBitfield2 flag2; // 5BC diff --git a/tasmota/support.ino b/tasmota/support.ino index 65605abd3..4b9961e94 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1143,12 +1143,8 @@ 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; } -#else // ESP32 - if (6 == i) { j = 12; } -#endif // ESP8266 - ESP32 dest[j] = src[i]; j++; } @@ -1203,12 +1199,7 @@ 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) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 28eae87f1..18ead323a 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1114,12 +1114,8 @@ 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; } -#else // ESP32 - if (6 == i) { j = 12; } -#endif // ESP8266 - 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 f235147bf..6a047f25f 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -713,11 +713,12 @@ const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0"; // esp32 has more pins #define USER_MODULE 255 #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 MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11) +#define ADC0_PIN 33 // Pin number of ADC0 #define WEMOS_MODULE 0 // Wemos module -const char PINS_WEMOS[] PROGMEM = "00TX02RX04050607080910111213141516171819202122232425262728293031A4A5A6A7A03738A3"; +//const char PINS_WEMOS[] PROGMEM = "00TX02RX0405060708R1T11112131415R2T21819202122232425262728293031A4A5A6A7A03738A3"; +const char PINS_WEMOS[] PROGMEM = "I00TX0I02RX0I04I05I06I07I08RX1TX1I11I12I13I14I15RX2TX2I18I19I20I21I22I23I24I25I26I27I28I29I30I31AD4AD5AD6AD7AD0I37I38AD3"; #endif // ESP8266 diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index 967da9400..831532a59 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -68,8 +68,8 @@ const mytmplt kModules PROGMEM = //6 IO GPIO6, Flash CLK //7 IO GPIO7, Flash D0 //8 IO GPIO8, Flash D1 - //9 IO GPIO9, Flash D2 - //10 IO GPIO10, Flash D3 + GPIO_USER, //9 IO GPIO9, Flash D2, U1RXD + GPIO_USER, //10 IO GPIO10, Flash D3, U1TXD //11 IO GPIO11, Flash CMD 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 diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index d2e2e1813..1a54edb76 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -262,12 +262,8 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "g=o.shift().split(',');" // Array separator "j=0;" "for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Supports 13 GPIOs -#ifdef ESP8266 "if(6==i){j=9;}" "if(8==i){j=12;}" -#else // ESP32 - "if(6==i){j=12;}" -#endif // ESP8266 - ESP32 "sk(g[i],j);" // Set GPIO "j++;" "}" @@ -1523,12 +1519,8 @@ void TemplateSaveSettings(void) 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; } -#else // ESP32 - if (6 == i) { j = 12; } -#endif // ESP8266 - ESP32 snprintf_P(webindex, sizeof(webindex), PSTR("g%d"), j); WebGetArg(webindex, tmp, sizeof(tmp)); // GPIO uint8_t gpio = atoi(tmp); @@ -1622,13 +1614,14 @@ void HandleModuleConfiguration(void) WSContentSend_P(HTTP_FORM_MODULE, AnyModuleName(MODULE).c_str()); for (uint32_t i = 0; i < sizeof(cmodule); i++) { if (ValidGPIO(i, cmodule.io[i])) { - snprintf_P(stemp, 3, PINS_WEMOS +i*2); #ifdef ESP8266 + snprintf_P(stemp, 3, PINS_WEMOS +i*2); char sesp8285[40]; snprintf_P(sesp8285, sizeof(sesp8285), PSTR("ESP8285"), WebColor(COL_TEXT_WARNING)); WSContentSend_P(PSTR("%s " D_GPIO "%d %s"), (WEMOS==my_module_type)?stemp:"", i, (0==i)? D_SENSOR_BUTTON "1":(1==i)? D_SERIAL_OUT :(3==i)? D_SERIAL_IN :((9==i)||(10==i))? sesp8285 :(12==i)? D_SENSOR_RELAY "1":(13==i)? D_SENSOR_LED "1i":(14==i)? D_SENSOR :"", i); #else // ESP32 + snprintf_P(stemp, 4, PINS_WEMOS +i*3); WSContentSend_P(PSTR("%s " D_GPIO "%d"), (WEMOS==my_module_type)?stemp:"", i, i); #endif // ESP8266