diff --git a/tasmota/support.ino b/tasmota/support.ino index 7523a65a3..e4325f57c 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1211,24 +1211,15 @@ gpio_flag ModuleFlag(void) { gpio_flag flag; -#ifdef ESP8266 if (USER_MODULE == Settings.module) { flag = Settings.user_template.flag; } else { +#ifdef ESP8266 memcpy_P(&flag, &kModules[Settings.module].flag, sizeof(gpio_flag)); - } #else // ESP32 - if (USER_MODULE == Settings.module) { -/* - gpio_flag gpio_adc0; - memcpy_P(&gpio_adc0, &Settings.user_template.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag)); - flag = Settings.user_template.flag.data + gpio_adc0.data; -*/ - memcpy_P(&flag, &Settings.user_template.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag)); - } else { - memcpy_P(&flag, &kModules.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag)); - } + memcpy_P(&flag, &kModules.flag, sizeof(gpio_flag)); #endif // ESP8266 - ESP32 + } return flag; } @@ -1285,12 +1276,14 @@ bool ValidGPIO(uint32_t pin, uint32_t gpio) #endif // ESP8266 - ESP32 } +#ifdef ESP8266 bool ValidAdc(void) { gpio_flag flag = ModuleFlag(); uint32_t template_adc0 = flag.data &15; return (ADC0_USER == template_adc0); } +#endif // ESP8266 #ifdef ESP8266 bool GetUsedInModule(uint32_t val, uint8_t *arr) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index c1f59cc95..d49633939 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1371,6 +1371,7 @@ void GpioInit(void) my_module.io[i] = def_gp.io[i]; // Force Template override } } +#ifdef ESP8266 if ((Settings.my_adc0 >= ADC0_END) && (Settings.my_adc0 < ADC0_USER)) { Settings.my_adc0 = ADC0_NONE; // Fix not supported sensor ids in module } @@ -1382,6 +1383,7 @@ void GpioInit(void) if ((template_adc0 > ADC0_NONE) && (template_adc0 < ADC0_USER)) { my_adc0 = template_adc0; // Force Template override } +#endif #ifdef LEGACY_GPIO_ARRAY InitAllPins(); diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index b552c55c6..ca5a7559b 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -165,7 +165,7 @@ uint8_t devices_present = 0; // Max number of devices supported uint8_t seriallog_level; // Current copy of Settings.seriallog_level uint8_t syslog_level; // Current copy of Settings.syslog_level uint8_t my_module_type; // Current copy of Settings.module or user template type -uint8_t my_adc0; // Active copy of Module ADC0 +uint8_t my_adc0 = 0; // Active copy of Module ADC0 uint8_t last_source = 0; // Last command source uint8_t shutters_present = 0; // Number of actual define shutters uint8_t prepped_loglevel = 0; // Delayed log level message @@ -286,16 +286,17 @@ void setup(void) for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { Settings.my_gp.io[i] = GPIO_NONE; // Reset user defined GPIO disabling sensors } +#ifdef ESP8266 Settings.my_adc0 = ADC0_NONE; // Reset user defined ADC0 disabling sensors +#endif } if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET] +4) { // Restarted 6 times #ifdef ESP8266 Settings.module = SONOFF_BASIC; // Reset module to Sonoff Basic // Settings.last_module = SONOFF_BASIC; -#endif // ESP8266 -#ifdef ESP32 +#else // ESP32 Settings.module = WEMOS; // Reset module to Wemos -#endif // ESP32 +#endif // ESP8266 - ESP32 } AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count); } diff --git a/tasmota/tasmota_template_ESP32_final.h b/tasmota/tasmota_template_ESP32_final.h index bd8063d33..2dc36fb98 100644 --- a/tasmota/tasmota_template_ESP32_final.h +++ b/tasmota/tasmota_template_ESP32_final.h @@ -190,7 +190,6 @@ enum UserSelectablePins { GPIO_HRXL_RX, // Data from MaxBotix HRXL sonar range sensor GPIO_ELECTRIQ_MOODL_TX, // ElectriQ iQ-wifiMOODL Serial TX GPIO_AS3935, -/* ADC0_INPUT, // Analog input ADC0_TEMP, // Thermistor ADC0_LIGHT, // Light sensor @@ -198,7 +197,6 @@ enum UserSelectablePins { ADC0_BUTTON_INV, ADC0_RANGE, // Range ADC0_CT_POWER, // Current -*/ GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -284,13 +282,11 @@ const char kSensorNames[] PROGMEM = D_SENSOR_HRXL_RX "|" D_SENSOR_ELECTRIQ_MOODL "|" D_SENSOR_AS3935 "|" -/* D_ANALOG_INPUT "|" D_TEMPERATURE "|" D_LIGHT "|" D_SENSOR_BUTTON "|" D_SENSOR_BUTTON "i|" D_RANGE "|" D_CT_POWER "|" -*/ ; const char kSensorNamesFixed[] PROGMEM = @@ -583,54 +579,23 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_AS3935), #endif /* - ADC0_INPUT, // Analog input - ADC0_TEMP, // Thermistor - ADC0_LIGHT, // Light sensor - ADC0_BUTTON, // Button - ADC0_BUTTON_INV, - ADC0_RANGE, // Range - ADC0_CT_POWER, // Current +#ifndef USE_ADC_VCC + AGPIO(ADC0_INPUT), // Analog input + AGPIO(ADC0_TEMP), // Thermistor + AGPIO(ADC0_LIGHT), // Light sensor + AGPIO(ADC0_BUTTON), // Button + AGPIO(ADC0_BUTTON_INV), + AGPIO(ADC0_RANGE), // Range + AGPIO(ADC0_CT_POWER), // Current +#endif */ }; //******************************************************************************************** -// User selectable ADC0 functionality -enum UserSelectableAdc0 { - ADC0_NONE, // Not used - ADC0_INPUT, // Analog input - ADC0_TEMP, // Thermistor - ADC0_LIGHT, // Light sensor - ADC0_BUTTON, // Button - ADC0_BUTTON_INV, - ADC0_RANGE, // Range - ADC0_CT_POWER, // Current -// ADC0_SWITCH, // Switch -// ADC0_SWITCH_INV, - ADC0_END }; - -// Programmer selectable ADC0 functionality -enum ProgramSelectableAdc0 { - ADC0_FIX_START = 14, - ADC0_USER, // User configurable needs to be 15 - ADC0_MAX }; - -// Text in webpage Module Parameters and commands ADC -const char kAdc0Names[] PROGMEM = - D_SENSOR_NONE "|" D_ANALOG_INPUT "|" - D_TEMPERATURE "|" D_LIGHT "|" - D_SENSOR_BUTTON "|" D_SENSOR_BUTTON "i|" - D_RANGE "|" - D_CT_POWER "|" -// D_SENSOR_SWITCH "|" D_SENSOR_SWITCH "i|" - ; - -//******************************************************************************************** - #define MAX_GPIO_PIN 40 // Number of supported GPIO #define MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11) #define MAX_USER_PINS 36 // MAX_GPIO_PIN - MIN_FLASH_PINS -#define ADC0_PIN 33 // Pin number of ADC0 #define WEMOS_MODULE 0 // Wemos module // 0 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839 diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 148051be6..0ead68da3 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -228,26 +228,24 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM = "wl(h);"; // Add console command key eventlistener after name has been synced with id (= wl(jd)) const char HTTP_MODULE_TEMPLATE_REPLACE[] PROGMEM = - "}2%d'>%s (%d)}3"; // }2 and }3 are used in below os.replace -const char HTTP_MODULE_TEMPLATE_NO_INDEX_REPLACE[] PROGMEM = - "}2%d'>%s}3"; // }2 and }3 are used in below os.replace + "}2%d'>%s (%d}3"; // }2 and }3 are used in below os.replace const char HTTP_SCRIPT_MODULE_TEMPLATE[] PROGMEM = #ifdef ESP8266 "var os;" "function sk(s,g){" // s = value, g = id and name - "var o=os.replace(/}2/g,\"