diff --git a/tasmota/settings.h b/tasmota/settings.h index ccf3e44ed..e5c9800fd 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -358,8 +358,17 @@ struct { SysBitfield3 flag3; // 3A0 uint8_t switchmode[MAX_SWITCHES]; // 3A4 (6.0.0b - moved from 0x4CA) +#ifdef ESP8266 char ex_friendlyname[4][33]; // 3AC char ex_switch_topic[33]; // 430 +#else // ESP32 +#ifdef FINAL_ESP32 + myio my_gp; // 3AC - 2 x 40 bytes (ESP32) + mytmplt user_template; // 3FC - 2 x 37 bytes (ESP32) + + uint8_t free_esp32_446[11]; // 446 +#endif +#endif // ESP8266 - ESP32 char serial_delimiter; // 451 uint8_t seriallog_level; // 452 @@ -406,10 +415,12 @@ struct { #ifdef ESP8266 char ex_mqtt_fulltopic[100]; // 558 #else // ESP32 +#ifndef FINAL_ESP32 myio my_gp; // 558 - 40 bytes (ESP32) mytmplt user_template; // 580 - 37 bytes (ESP32) uint8_t free_esp32_5a5[23]; // 5A5 +#endif #endif // ESP8266 - ESP32 SysBitfield2 flag2; // 5BC diff --git a/tasmota/support.ino b/tasmota/support.ino index 1bcdb9015..02d17af98 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1081,19 +1081,23 @@ uint32_t Pin(uint32_t gpio, uint32_t index = 0); uint32_t Pin(uint32_t gpio, uint32_t index) { #ifdef LEGACY_GPIO_ARRAY return pin[gpio + index]; // Pin number configured for gpio or 99 if not used -#else -//#ifdef ESP8266 +#else // No LEGACY_GPIO_ARRAY +#ifdef ESP8266 uint16_t real_gpio = gpio + index; -//#else -// uint16_t real_gpio = (gpio << 5) + index; -//endif +#else // ESP32 +#ifndef FINAL_ESP32 + uint16_t real_gpio = gpio + index; +#else // FINAL_ESP32 + uint16_t real_gpio = (gpio << 5) + index; +#endif // FINAL_ESP32 +#endif // ESP8266 - ESP32 for (uint32_t i = 0; i < ARRAY_SIZE(pin); i++) { if (pin[i] == real_gpio) { return i; // Pin number configured for gpio } } return 99; // No pin used for gpio -#endif +#endif // No LEGACY_GPIO_ARRAY } boolean PinUsed(uint32_t gpio, uint32_t index = 0); @@ -1164,13 +1168,18 @@ String ModuleName(void) void ModuleGpios(myio *gp) { -//#ifdef ESP8266 +#ifdef ESP8266 uint8_t *dest = (uint8_t *)gp; uint8_t src[ARRAY_SIZE(Settings.user_template.gp.io)]; -//#else -// uint16_t *dest = (uint16_t *)gp; -// uint16_t src[ARRAY_SIZE(Settings.user_template.gp.io)]; -//#endif +#else // ESP32 +#ifndef FINAL_ESP32 + uint8_t *dest = (uint8_t *)gp; + uint8_t src[ARRAY_SIZE(Settings.user_template.gp.io)]; +#else // FINAL_ESP32 + uint16_t *dest = (uint16_t *)gp; + uint16_t src[ARRAY_SIZE(Settings.user_template.gp.io)]; +#endif +#endif // ESP8266 - ESP32 memset(dest, GPIO_NONE, sizeof(myio)); if (USER_MODULE == Settings.module) { @@ -1275,11 +1284,15 @@ bool ValidAdc(void) return (ADC0_USER == template_adc0); } -//#ifdef ESP8266 +#ifdef ESP8266 bool GetUsedInModule(uint32_t val, uint8_t *arr) -//#else -//bool GetUsedInModule(uint32_t val, uint16_t *arr) -//#endif +#else // ESP32 +#ifndef FINAL_ESP32 +bool GetUsedInModule(uint32_t val, uint8_t *arr) +#else // FINAL_ESP32 +bool GetUsedInModule(uint32_t val, uint16_t *arr) +#endif // FINAL_ESP32 +#endif // ESP8266 - ESP32 { int offset = 0; diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index aae4df24c..a1a3cb473 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -41,14 +41,8 @@ * Power Type \*********************************************************************************************/ -//#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 /*********************************************************************************************\ * Constants diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 4f84832ac..8af7285ad 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -118,9 +118,13 @@ uint16_t tele_period = 9999; // Tele period timer uint16_t blink_counter = 0; // Number of blink cycles uint16_t seriallog_timer = 0; // Timer to disable Seriallog uint16_t syslog_timer = 0; // Timer to re-enable syslog_level -//#ifdef ESP32 -//uint16_t pin[MAX_GPIO_PIN] = { 0 }; // Possible pin configurations -//#endif + +#ifdef ESP32 +#ifdef FINAL_ESP32 +uint16_t pin[MAX_GPIO_PIN] = { 0 }; // Possible pin configurations +#endif // FINAL_ESP32 +#endif // ESP32 + int16_t save_data_counter; // Counter and flag for config save to Flash RulesBitfield rules_flag; // Rule state flags (16 bits) uint8_t mqtt_cmnd_blocked = 0; // Ignore flag for publish command @@ -129,13 +133,23 @@ uint8_t state_250mS = 0; // State 250msecond per second flag uint8_t latching_relay_pulse = 0; // Latching relay pulse timer uint8_t ssleep; // Current copy of Settings.sleep uint8_t blinkspeed = 1; // LED blink rate -//#ifdef ESP8266 + +#ifdef ESP8266 #ifdef LEGACY_GPIO_ARRAY uint8_t pin[GPIO_MAX]; // Possible pin configurations -#else +#else // No LEGACY_GPIO_ARRAY uint8_t pin[MAX_GPIO_PIN] = { 0 }; // Possible pin configurations -#endif -//#endif +#endif // LEGACY_GPIO_ARRAY +#else // ESP32 +#ifndef FINAL_ESP32 +#ifdef LEGACY_GPIO_ARRAY +uint8_t pin[GPIO_MAX]; // Possible pin configurations +#else // No LEGACY_GPIO_ARRAY +uint8_t pin[MAX_GPIO_PIN] = { 0 }; // Possible pin configurations +#endif // LEGACY_GPIO_ARRAY +#endif // No FINAL_ESP32 +#endif // ESP8266 - ESP32 + uint8_t active_device = 1; // Active device in ExecuteCommandPower uint8_t leds_present = 0; // Max number of LED supported uint8_t led_inverted = 0; // LED inverted flag (1 = (0 = On, 1 = Off)) diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 8881f8334..178cf3c24 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -50,10 +50,19 @@ extern "C" void resetPins(); #include "tasmota_configurations.h" // Preconfigured configurations /*********************************************************************************************\ - * Mandatory defines satisfying disabled defines + * Theo transition defines - DO NOT TOUCH \*********************************************************************************************/ -//#define LEGACY_GPIO_ARRAY +//#define LEGACY_GPIO_ARRAY // Uncomment to use legacy GPIO array instead of new PIN array + +//#define FINAL_ESP32 // Uncomment for ESP32 16-bits PIN array +#ifdef FINAL_ESP32 +#undef LEGACY_GPIO_ARRAY +#endif + +/*********************************************************************************************\ + * Mandatory defines satisfying disabled defines +\*********************************************************************************************/ #ifndef MODULE #define MODULE SONOFF_BASIC // [Module] Select default model diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index ae95705c7..5f9c23b7c 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -20,6 +20,8 @@ #ifndef _TASMOTA_TEMPLATE_H_ #define _TASMOTA_TEMPLATE_H_ +#ifdef ESP8266 + // User selectable GPIO functionality // ATTENTION: Only add at the end of this list just before GPIO_SENSOR_END // Then add the same name(s) in a nice location in array kGpioNiceList @@ -699,31 +701,14 @@ const char kAdc0Names[] PROGMEM = /********************************************************************************************/ -#ifdef ESP8266 - #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 MAX_USER_PINS 13 // MAX_GPIO_PIN - MIN_FLASH_PINS #define ADC0_PIN 17 // Pin number of ADC0 #define WEMOS_MODULE 17 // Wemos module const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0"; -#else // ESP32 - -// esp32 has more pins -#define USER_MODULE 255 -#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 ADC0_PIN 33 // Pin number of ADC0 -#define WEMOS_MODULE 0 // Wemos module - -// 0 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839 -const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOflashcFLFLolIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOA6A7A0IoIoA3"; - -#endif // ESP8266 - -#define MAX_USER_PINS MAX_GPIO_PIN-MIN_FLASH_PINS - /********************************************************************************************/ typedef struct MYIO { @@ -758,10 +743,8 @@ typedef struct MYTMPLT { } mytmplt; /********************************************************************************************/ - -#ifdef ESP8266 - // Supported hardware modules + enum SupportedModules { SONOFF_BASIC, SONOFF_RF, SONOFF_SV, SONOFF_TH, SONOFF_DUAL, SONOFF_POW, SONOFF_4CH, SONOFF_S2X, SLAMPHER, SONOFF_TOUCH, SONOFF_LED, CH1, CH4, MOTOR, ELECTRODRAGON, EXS_RELAY, WION, WEMOS, SONOFF_DEV, H801, diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index 831532a59..4dfd9dd90 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -21,6 +21,7 @@ #define _TASMOTA_TEMPLATE_ESP32_H_ #ifdef ESP32 +#ifndef FINAL_ESP32 // Hardware has no ESP32 #undef USE_TUYA_DIMMER @@ -42,12 +43,738 @@ #undef USE_TUYA_MCU #undef USE_PS_16_DZ +// User selectable GPIO functionality +// ATTENTION: Only add at the end of this list just before GPIO_SENSOR_END +// Then add the same name(s) in a nice location in array kGpioNiceList +enum UserSelectablePins { + GPIO_NONE, // Not used + GPIO_DHT11, // DHT11 + GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_SI7021, // iTead SI7021 + GPIO_DSB, // Single wire DS18B20 or DS18S20 + GPIO_I2C_SCL, // I2C SCL + GPIO_I2C_SDA, // I2C SDA + GPIO_WS2812, // WS2812 Led string + GPIO_IRSEND, // IR remote + GPIO_SWT1, // User connected external switches + GPIO_SWT2, + GPIO_SWT3, + GPIO_SWT4, + GPIO_SWT5, + GPIO_SWT6, + GPIO_SWT7, + GPIO_SWT8, + GPIO_KEY1, // Button usually connected to GPIO0 + GPIO_KEY2, + GPIO_KEY3, + GPIO_KEY4, + GPIO_REL1, // Relays + GPIO_REL2, + GPIO_REL3, + GPIO_REL4, + GPIO_REL5, + GPIO_REL6, + GPIO_REL7, + GPIO_REL8, + GPIO_REL1_INV, + GPIO_REL2_INV, + GPIO_REL3_INV, + GPIO_REL4_INV, + GPIO_REL5_INV, + GPIO_REL6_INV, + GPIO_REL7_INV, + GPIO_REL8_INV, + GPIO_PWM1, // RGB Red or C Cold White + GPIO_PWM2, // RGB Green or CW Warm White + GPIO_PWM3, // RGB Blue + GPIO_PWM4, // RGBW (Cold) White + GPIO_PWM5, // RGBCW Warm White + GPIO_CNTR1, + GPIO_CNTR2, + GPIO_CNTR3, + GPIO_CNTR4, + GPIO_PWM1_INV, // RGB Red or C Cold White + GPIO_PWM2_INV, // RGB Green or CW Warm White + GPIO_PWM3_INV, // RGB Blue + GPIO_PWM4_INV, // RGBW (Cold) White + GPIO_PWM5_INV, // RGBCW Warm White + GPIO_IRRECV, // IR receiver + GPIO_LED1, // Leds + GPIO_LED2, + GPIO_LED3, + GPIO_LED4, + GPIO_LED1_INV, + GPIO_LED2_INV, + GPIO_LED3_INV, + GPIO_LED4_INV, + GPIO_MHZ_TXD, // MH-Z19 Serial interface + GPIO_MHZ_RXD, // MH-Z19 Serial interface + GPIO_PZEM0XX_TX, // PZEM0XX Serial interface + GPIO_PZEM004_RX, // PZEM004T Serial interface + GPIO_SAIR_TX, // SenseAir Serial interface + GPIO_SAIR_RX, // SenseAir Serial interface + GPIO_SPI_CS, // SPI Chip Select + GPIO_SPI_DC, // SPI Data Direction + GPIO_BACKLIGHT, // Display backlight control + GPIO_PMS5003_RX, // Plantower PMS5003 Serial interface + GPIO_SDS0X1_RX, // Nova Fitness SDS011 Serial interface + GPIO_SBR_TX, // Serial Bridge Serial interface + GPIO_SBR_RX, // Serial Bridge Serial interface + GPIO_SR04_TRIG, // SR04 Trigger/TX pin + GPIO_SR04_ECHO, // SR04 Echo/RX pin + GPIO_SDM120_TX, // SDM120 Serial interface + GPIO_SDM120_RX, // SDM120 Serial interface + GPIO_SDM630_TX, // SDM630 Serial interface + GPIO_SDM630_RX, // SDM630 Serial interface + GPIO_TM16CLK, // TM1638 Clock + GPIO_TM16DIO, // TM1638 Data I/O + GPIO_TM16STB, // TM1638 Strobe + GPIO_SWT1_NP, // User connected external switches + GPIO_SWT2_NP, + GPIO_SWT3_NP, + GPIO_SWT4_NP, + GPIO_SWT5_NP, + GPIO_SWT6_NP, + GPIO_SWT7_NP, + GPIO_SWT8_NP, + GPIO_KEY1_NP, // Button usually connected to GPIO0 + GPIO_KEY2_NP, + GPIO_KEY3_NP, + GPIO_KEY4_NP, + GPIO_CNTR1_NP, + GPIO_CNTR2_NP, + GPIO_CNTR3_NP, + GPIO_CNTR4_NP, + GPIO_PZEM016_RX, // PZEM-014,016 Serial Modbus interface + GPIO_PZEM017_RX, // PZEM-003,017 Serial Modbus interface + GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player + GPIO_SDS0X1_TX, // Nova Fitness SDS011 Serial interface + GPIO_HX711_SCK, // HX711 Load Cell clock + GPIO_HX711_DAT, // HX711 Load Cell data + GPIO_TX2X_TXD_BLACK, // TX20/TX23 Transmission Pin + GPIO_RFSEND, // RF transmitter + GPIO_RFRECV, // RF receiver + GPIO_TUYA_TX, // Tuya Serial interface + GPIO_TUYA_RX, // Tuya Serial interface + GPIO_MGC3130_XFER, // MGC3130 Transfer + GPIO_MGC3130_RESET, // MGC3130 Reset + GPIO_SSPI_MISO, // Software SPI Master Input Slave Output + GPIO_SSPI_MOSI, // Software SPI Master Output Slave Input + GPIO_SSPI_SCLK, // Software SPI Serial Clock + GPIO_SSPI_CS, // Software SPI Chip Select + GPIO_SSPI_DC, // Software SPI Data or Command + GPIO_RF_SENSOR, // Rf receiver with sensor decoding + GPIO_AZ_TXD, // AZ-Instrument 7798 Serial interface + GPIO_AZ_RXD, // AZ-Instrument 7798 Serial interface + GPIO_MAX31855CS, // MAX31855 Serial interface + GPIO_MAX31855CLK, // MAX31855 Serial interface + GPIO_MAX31855DO, // MAX31855 Serial interface + GPIO_KEY1_INV, // Inverted buttons + GPIO_KEY2_INV, + GPIO_KEY3_INV, + GPIO_KEY4_INV, + GPIO_KEY1_INV_NP, // Inverted buttons without pull-up + GPIO_KEY2_INV_NP, + GPIO_KEY3_INV_NP, + GPIO_KEY4_INV_NP, + GPIO_NRG_SEL, // HLW8012/HLJ-01 Sel output (1 = Voltage) + GPIO_NRG_SEL_INV, // HLW8012/HLJ-01 Sel output (0 = Voltage) + GPIO_NRG_CF1, // HLW8012/HLJ-01 CF1 voltage / current + GPIO_HLW_CF, // HLW8012 CF power + GPIO_HJL_CF, // HJL-01/BL0937 CF power + GPIO_MCP39F5_TX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RST, // MCP39F501 Reset (Shelly2) + GPIO_PN532_TXD, // PN532 NFC Serial Tx + GPIO_PN532_RXD, // PN532 NFC Serial Rx + GPIO_SM16716_CLK, // SM16716 CLOCK + GPIO_SM16716_DAT, // SM16716 DATA + GPIO_SM16716_SEL, // SM16716 SELECT + GPIO_DI, // my92x1 PWM input + GPIO_DCKI, // my92x1 CLK input + GPIO_CSE7766_TX, // CSE7766 Serial interface (S31 and Pow R2) - Not used anymore 20200121 + GPIO_CSE7766_RX, // CSE7766 Serial interface (S31 and Pow R2) + GPIO_ARIRFRCV, // AriLux RF Receive input + GPIO_TXD, // Serial interface + GPIO_RXD, // Serial interface + GPIO_ROT1A, // Rotary switch1 A Pin + GPIO_ROT1B, // Rotary switch1 B Pin + GPIO_ROT2A, // Rotary switch2 A Pin + GPIO_ROT2B, // Rotary switch2 B Pin + GPIO_HRE_CLOCK, // Clock/Power line for HR-E Water Meter + GPIO_HRE_DATA, // Data line for HR-E Water Meter + GPIO_ADE7953_IRQ, // ADE7953 IRQ + GPIO_LEDLNK, // Link led + GPIO_LEDLNK_INV, // Inverted link led + GPIO_ARIRFSEL, // Arilux RF Receive input selected + GPIO_BUZZER, // Buzzer + GPIO_BUZZER_INV, // Inverted buzzer + GPIO_OLED_RESET, // OLED Display Reset + GPIO_SOLAXX1_TX, // Solax Inverter tx pin + GPIO_SOLAXX1_RX, // Solax Inverter rx pin + GPIO_ZIGBEE_TX, // Zigbee Serial interface + GPIO_ZIGBEE_RX, // Zigbee Serial interface + GPIO_RDM6300_RX, // RDM6300 RX + GPIO_IBEACON_TX, // HM17 IBEACON TX + GPIO_IBEACON_RX, // HM17 IBEACON RX + GPIO_A4988_DIR, // A4988 direction pin + GPIO_A4988_STP, // A4988 step pin + GPIO_A4988_ENA, // A4988 enabled pin + GPIO_A4988_MS1, // A4988 microstep pin1 + GPIO_A4988_MS2, // A4988 microstep pin2 + GPIO_A4988_MS3, // A4988 microstep pin3 + GPIO_DDS2382_TX, // DDS2382 Serial interface + GPIO_DDS2382_RX, // DDS2382 Serial interface + GPIO_DDSU666_TX, // DDSU666 Serial interface + GPIO_DDSU666_RX, // DDSU666 Serial interface + GPIO_SM2135_CLK, // SM2135 Clk + GPIO_SM2135_DAT, // SM2135 Dat + GPIO_DEEPSLEEP, // Kill switch for deepsleep + GPIO_EXS_ENABLE, // EXS MCU Enable + GPIO_TASMOTASLAVE_TXD, // Slave TX + GPIO_TASMOTASLAVE_RXD, // Slave RX + GPIO_TASMOTASLAVE_RST, // Slave Reset Pin + GPIO_TASMOTASLAVE_RST_INV, // Slave Reset Inverted + GPIO_HPMA_RX, // Honeywell HPMA115S0 Serial interface + GPIO_HPMA_TX, // Honeywell HPMA115S0 Serial interface + GPIO_GPS_RX, // GPS serial interface + GPIO_GPS_TX, // GPS serial interface + GPIO_DSB_OUT, // Pseudo Single wire DS18B20 or DS18S20 + GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_HM10_RX, // HM10-BLE-Mijia-bridge serial interface + GPIO_HM10_TX, // HM10-BLE-Mijia-bridge serial interface + GPIO_LE01MR_RX, // F&F LE-01MR energy meter + GPIO_LE01MR_TX, // F&F LE-01MR energy meter + GPIO_CC1101_GDO0, // CC1101 pin for RX + GPIO_CC1101_GDO2, // CC1101 pin for RX + GPIO_HRXL_RX, // Data from MaxBotix HRXL sonar range sensor + GPIO_ELECTRIQ_MOODL_TX, // ElectriQ iQ-wifiMOODL Serial TX + GPIO_AS3935, + GPIO_PMS5003_TX, // Plantower PMS5003 Serial interface + GPIO_SENSOR_END }; + +// Programmer selectable GPIO functionality +enum ProgramSelectablePins { + GPIO_FIX_START = 251, + GPIO_SPI_MISO, // SPI MISO library fixed pin GPIO12 + GPIO_SPI_MOSI, // SPI MOSI library fixed pin GPIO13 + GPIO_SPI_CLK, // SPI Clk library fixed pin GPIO14 + GPIO_USER, // User configurable needs to be 255 + GPIO_MAX }; + +// Text in webpage Module Parameters and commands GPIOS and GPIO +const char kSensorNames[] PROGMEM = + D_SENSOR_NONE "|" + D_SENSOR_DHT11 "|" D_SENSOR_AM2301 "|" D_SENSOR_SI7021 "|" + D_SENSOR_DS18X20 "|" + D_SENSOR_I2C_SCL "|" D_SENSOR_I2C_SDA "|" + D_SENSOR_WS2812 "|" + D_SENSOR_IRSEND "|" + D_SENSOR_SWITCH "1|" D_SENSOR_SWITCH "2|" D_SENSOR_SWITCH "3|" D_SENSOR_SWITCH "4|" D_SENSOR_SWITCH "5|" D_SENSOR_SWITCH "6|" D_SENSOR_SWITCH "7|" D_SENSOR_SWITCH "8|" + D_SENSOR_BUTTON "1|" D_SENSOR_BUTTON "2|" D_SENSOR_BUTTON "3|" D_SENSOR_BUTTON "4|" + D_SENSOR_RELAY "1|" D_SENSOR_RELAY "2|" D_SENSOR_RELAY "3|" D_SENSOR_RELAY "4|" D_SENSOR_RELAY "5|" D_SENSOR_RELAY "6|" D_SENSOR_RELAY "7|" D_SENSOR_RELAY "8|" + D_SENSOR_RELAY "1i|" D_SENSOR_RELAY "2i|" D_SENSOR_RELAY "3i|" D_SENSOR_RELAY "4i|" D_SENSOR_RELAY "5i|" D_SENSOR_RELAY "6i|" D_SENSOR_RELAY "7i|" D_SENSOR_RELAY "8i|" + D_SENSOR_PWM "1|" D_SENSOR_PWM "2|" D_SENSOR_PWM "3|" D_SENSOR_PWM "4|" D_SENSOR_PWM "5|" + D_SENSOR_COUNTER "1|" D_SENSOR_COUNTER "2|" D_SENSOR_COUNTER "3|" D_SENSOR_COUNTER "4|" + D_SENSOR_PWM "1i|" D_SENSOR_PWM "2i|" D_SENSOR_PWM "3i|" D_SENSOR_PWM "4i|" D_SENSOR_PWM "5i|" + D_SENSOR_IRRECV "|" + D_SENSOR_LED "1|" D_SENSOR_LED "2|" D_SENSOR_LED "3|" D_SENSOR_LED "4|" + D_SENSOR_LED "1i|" D_SENSOR_LED "2i|" D_SENSOR_LED "3i|" D_SENSOR_LED "4i|" + D_SENSOR_MHZ_TX "|" D_SENSOR_MHZ_RX "|" + D_SENSOR_PZEM0XX_TX "|" D_SENSOR_PZEM004_RX "|" + D_SENSOR_SAIR_TX "|" D_SENSOR_SAIR_RX "|" + D_SENSOR_SPI_CS "|" D_SENSOR_SPI_DC "|" D_SENSOR_BACKLIGHT "|" + D_SENSOR_PMS5003_RX "|" D_SENSOR_SDS0X1_RX "|" + D_SENSOR_SBR_TX "|" D_SENSOR_SBR_RX "|" + D_SENSOR_SR04_TRIG "|" D_SENSOR_SR04_ECHO "|" + D_SENSOR_SDM120_TX "|" D_SENSOR_SDM120_RX "|" + D_SENSOR_SDM630_TX "|" D_SENSOR_SDM630_RX "|" + D_SENSOR_TM1638_CLK "|" D_SENSOR_TM1638_DIO "|" D_SENSOR_TM1638_STB "|" + D_SENSOR_SWITCH "1n|" D_SENSOR_SWITCH "2n|" D_SENSOR_SWITCH "3n|" D_SENSOR_SWITCH "4n|" D_SENSOR_SWITCH "5n|" D_SENSOR_SWITCH "6n|" D_SENSOR_SWITCH "7n|" D_SENSOR_SWITCH "8n|" + D_SENSOR_BUTTON "1n|" D_SENSOR_BUTTON "2n|" D_SENSOR_BUTTON "3n|" D_SENSOR_BUTTON "4n|" + D_SENSOR_COUNTER "1n|" D_SENSOR_COUNTER "2n|" D_SENSOR_COUNTER "3n|" D_SENSOR_COUNTER "4n|" + D_SENSOR_PZEM016_RX "|" D_SENSOR_PZEM017_RX "|" + D_SENSOR_DFR562 "|" D_SENSOR_SDS0X1_TX "|" + D_SENSOR_HX711_SCK "|" D_SENSOR_HX711_DAT "|" + D_SENSOR_TX2X_TX "|" + D_SENSOR_RFSEND "|" D_SENSOR_RFRECV "|" + D_SENSOR_TUYA_TX "|" D_SENSOR_TUYA_RX "|" + D_SENSOR_MGC3130_XFER "|" D_SENSOR_MGC3130_RESET "|" + D_SENSOR_SSPI_MISO "|" D_SENSOR_SSPI_MOSI "|" D_SENSOR_SSPI_SCLK "|" D_SENSOR_SSPI_CS "|" D_SENSOR_SSPI_DC "|" + D_SENSOR_RF_SENSOR "|" + D_SENSOR_AZ_TX "|" D_SENSOR_AZ_RX "|" + D_SENSOR_MAX31855_CS "|" D_SENSOR_MAX31855_CLK "|" D_SENSOR_MAX31855_DO "|" + D_SENSOR_BUTTON "1i|" D_SENSOR_BUTTON "2i|" D_SENSOR_BUTTON "3i|" D_SENSOR_BUTTON "4i|" + D_SENSOR_BUTTON "1in|" D_SENSOR_BUTTON "2in|" D_SENSOR_BUTTON "3in|" D_SENSOR_BUTTON "4in|" + D_SENSOR_NRG_SEL "|" D_SENSOR_NRG_SEL "i|" D_SENSOR_NRG_CF1 "|" D_SENSOR_HLW_CF "|" D_SENSOR_HJL_CF "|" + D_SENSOR_MCP39F5_TX "|" D_SENSOR_MCP39F5_RX "|" D_SENSOR_MCP39F5_RST "|" + D_SENSOR_PN532_TX "|" D_SENSOR_PN532_RX "|" + D_SENSOR_SM16716_CLK "|" D_SENSOR_SM16716_DAT "|" D_SENSOR_SM16716_POWER "|" + D_SENSOR_MY92X1_DI "|" D_SENSOR_MY92X1_DCKI "|" + D_SENSOR_CSE7766_TX "|" D_SENSOR_CSE7766_RX "|" + D_SENSOR_ARIRFRCV "|" D_SENSOR_TXD "|" D_SENSOR_RXD "|" + D_SENSOR_ROTARY "1a|" D_SENSOR_ROTARY "1b|" D_SENSOR_ROTARY "2a|" D_SENSOR_ROTARY "2b|" + D_SENSOR_HRE_CLOCK "|" D_SENSOR_HRE_DATA "|" + D_SENSOR_ADE7953_IRQ "|" + D_SENSOR_LED_LINK "|" D_SENSOR_LED_LINK "i|" + D_SENSOR_ARIRFSEL "|" + D_SENSOR_BUZZER "|" D_SENSOR_BUZZER "i|" + D_SENSOR_OLED_RESET "|" + D_SENSOR_SOLAXX1_TX "|" D_SENSOR_SOLAXX1_RX "|" + D_SENSOR_ZIGBEE_TXD "|" D_SENSOR_ZIGBEE_RXD "|" + D_SENSOR_RDM6300_RX "|" + D_SENSOR_IBEACON_TX "|" D_SENSOR_IBEACON_RX "|" + D_SENSOR_A4988_DIR "|" D_SENSOR_A4988_STP "|" D_SENSOR_A4988_ENA "|" D_SENSOR_A4988_MS1 "|" D_SENSOR_A4988_MS2 "|" D_SENSOR_A4988_MS3 "|" + D_SENSOR_DDS2382_TX "|" D_SENSOR_DDS2382_RX "|" + D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|" + D_SENSOR_SM2135_CLK "|" D_SENSOR_SM2135_DAT "|" + D_SENSOR_DEEPSLEEP "|" D_SENSOR_EXS_ENABLE "|" + D_SENSOR_SLAVE_TX "|" D_SENSOR_SLAVE_RX "|" D_SENSOR_SLAVE_RESET "|" D_SENSOR_SLAVE_RESET "i|" + D_SENSOR_HPMA_RX "|" D_SENSOR_HPMA_TX "|" + D_SENSOR_GPS_RX "|" D_SENSOR_GPS_TX "|" + D_SENSOR_DS18X20 "o|" D_SENSOR_DHT11 "o|" + D_SENSOR_HM10_RX "|" D_SENSOR_HM10_TX "|" + D_SENSOR_LE01MR_RX "|" D_SENSOR_LE01MR_TX "|" + D_SENSOR_CC1101_GDO0 "|" D_SENSOR_CC1101_GDO2 "|" + D_SENSOR_HRXL_RX "|" + D_SENSOR_ELECTRIQ_MOODL "|" + D_SENSOR_AS3935 "|" D_SENSOR_PMS5003_TX + ; + +const char kSensorNamesFixed[] PROGMEM = + D_SENSOR_SPI_MISO "|" D_SENSOR_SPI_MOSI "|" D_SENSOR_SPI_CLK "|" + D_SENSOR_USER; + +const uint8_t kGpioNiceList[] PROGMEM = { + GPIO_NONE, // Not used + GPIO_KEY1, // Buttons + GPIO_KEY1_NP, + GPIO_KEY1_INV, + GPIO_KEY1_INV_NP, + GPIO_KEY2, + GPIO_KEY2_NP, + GPIO_KEY2_INV, + GPIO_KEY2_INV_NP, + GPIO_KEY3, + GPIO_KEY3_NP, + GPIO_KEY3_INV, + GPIO_KEY3_INV_NP, + GPIO_KEY4, + GPIO_KEY4_NP, + GPIO_KEY4_INV, + GPIO_KEY4_INV_NP, + GPIO_SWT1, // User connected external switches + GPIO_SWT1_NP, + GPIO_SWT2, + GPIO_SWT2_NP, + GPIO_SWT3, + GPIO_SWT3_NP, + GPIO_SWT4, + GPIO_SWT4_NP, + GPIO_SWT5, + GPIO_SWT5_NP, + GPIO_SWT6, + GPIO_SWT6_NP, + GPIO_SWT7, + GPIO_SWT7_NP, + GPIO_SWT8, + GPIO_SWT8_NP, + GPIO_REL1, // Relays + GPIO_REL1_INV, + GPIO_REL2, + GPIO_REL2_INV, + GPIO_REL3, + GPIO_REL3_INV, + GPIO_REL4, + GPIO_REL4_INV, + GPIO_REL5, + GPIO_REL5_INV, + GPIO_REL6, + GPIO_REL6_INV, + GPIO_REL7, + GPIO_REL7_INV, + GPIO_REL8, + GPIO_REL8_INV, + GPIO_LED1, // Leds + GPIO_LED1_INV, + GPIO_LED2, + GPIO_LED2_INV, + GPIO_LED3, + GPIO_LED3_INV, + GPIO_LED4, + GPIO_LED4_INV, + GPIO_LEDLNK, // Link led + GPIO_LEDLNK_INV, // Inverted link led + GPIO_PWM1, // RGB Red or C Cold White + GPIO_PWM1_INV, + GPIO_PWM2, // RGB Green or CW Warm White + GPIO_PWM2_INV, + GPIO_PWM3, // RGB Blue + GPIO_PWM3_INV, + GPIO_PWM4, // RGBW (Cold) White + GPIO_PWM4_INV, + GPIO_PWM5, // RGBCW Warm White + GPIO_PWM5_INV, +#ifdef USE_COUNTER + GPIO_CNTR1, // Counters + GPIO_CNTR1_NP, + GPIO_CNTR2, + GPIO_CNTR2_NP, + GPIO_CNTR3, + GPIO_CNTR3_NP, + GPIO_CNTR4, + GPIO_CNTR4_NP, +#endif +#ifdef USE_BUZZER + GPIO_BUZZER, // Buzzer + GPIO_BUZZER_INV, // Inverted buzzer +#endif + GPIO_TXD, // Serial interface + GPIO_RXD, // Serial interface +#ifdef USE_I2C + GPIO_I2C_SCL, // I2C SCL + GPIO_I2C_SDA, // I2C SDA +#endif +#ifdef USE_SPI + GPIO_SPI_CS, // SPI Chip Select + GPIO_SPI_DC, // SPI Data Direction + GPIO_SSPI_MISO, // Software SPI Master Input Slave Output + GPIO_SSPI_MOSI, // Software SPI Master Output Slave Input + GPIO_SSPI_SCLK, // Software SPI Serial Clock + GPIO_SSPI_CS, // Software SPI Chip Select + GPIO_SSPI_DC, // Software SPI Data or Command +#endif +#ifdef USE_DISPLAY + GPIO_BACKLIGHT, // Display backlight control + GPIO_OLED_RESET, // OLED Display Reset +#endif +#ifdef USE_DHT + GPIO_DHT11, // DHT11 + GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_SI7021, // iTead SI7021 + GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321 +#endif +#ifdef USE_DS18x20 + GPIO_DSB, // Single wire DS18B20 or DS18S20 + GPIO_DSB_OUT, // Pseudo Single wire DS18B20 or DS18S20 +#endif + +// Light +#ifdef USE_LIGHT +#ifdef USE_WS2812 + GPIO_WS2812, // WS2812 Led string +#endif +#ifdef USE_ARILUX_RF + GPIO_ARIRFRCV, // AriLux RF Receive input + GPIO_ARIRFSEL, // Arilux RF Receive input selected +#endif +#ifdef USE_MY92X1 + GPIO_DI, // my92x1 PWM input + GPIO_DCKI, // my92x1 CLK input +#endif // USE_MY92X1 +#ifdef USE_SM16716 + GPIO_SM16716_CLK, // SM16716 CLOCK + GPIO_SM16716_DAT, // SM16716 DATA + GPIO_SM16716_SEL, // SM16716 SELECT +#endif // USE_SM16716 +#ifdef USE_SM2135 + GPIO_SM2135_CLK, // SM2135 CLOCK + GPIO_SM2135_DAT, // SM2135 DATA +#endif // USE_SM2135 +#ifdef USE_TUYA_MCU + GPIO_TUYA_TX, // Tuya Serial interface + GPIO_TUYA_RX, // Tuya Serial interface +#endif +#ifdef USE_EXS_DIMMER + GPIO_EXS_ENABLE, // EXS MCU Enable +#endif +#ifdef USE_ELECTRIQ_MOODL + GPIO_ELECTRIQ_MOODL_TX, +#endif +#endif // USE_LIGHT + +#if defined(USE_IR_REMOTE) || defined(USE_IR_REMOTE_FULL) + GPIO_IRSEND, // IR remote +#if defined(USE_IR_RECEIVE) || defined(USE_IR_REMOTE_FULL) + GPIO_IRRECV, // IR receiver +#endif +#endif + +#ifdef USE_RC_SWITCH + GPIO_RFSEND, // RF transmitter + GPIO_RFRECV, // RF receiver +#endif +#ifdef USE_RF_SENSOR + GPIO_RF_SENSOR, // Rf receiver with sensor decoding +#endif +#ifdef USE_SR04 + GPIO_SR04_TRIG, // SR04 Tri/TXgger pin + GPIO_SR04_ECHO, // SR04 Ech/RXo pin +#endif +#ifdef USE_TM1638 + GPIO_TM16CLK, // TM1638 Clock + GPIO_TM16DIO, // TM1638 Data I/O + GPIO_TM16STB, // TM1638 Strobe +#endif +#ifdef USE_HX711 + GPIO_HX711_SCK, // HX711 Load Cell clock + GPIO_HX711_DAT, // HX711 Load Cell data +#endif + +// Energy sensors +#ifdef USE_ENERGY_SENSOR +#ifdef USE_HLW8012 + GPIO_NRG_SEL, // HLW8012/HLJ-01 Sel output (1 = Voltage) + GPIO_NRG_SEL_INV, // HLW8012/HLJ-01 Sel output (0 = Voltage) + GPIO_NRG_CF1, // HLW8012/HLJ-01 CF1 voltage / current + GPIO_HLW_CF, // HLW8012 CF power + GPIO_HJL_CF, // HJL-01/BL0937 CF power +#endif +#if defined(USE_I2C) && defined(USE_ADE7953) + GPIO_ADE7953_IRQ, // ADE7953 IRQ +#endif +#ifdef USE_CSE7766 + GPIO_CSE7766_TX, // CSE7766 Serial interface (S31 and Pow R2) + GPIO_CSE7766_RX, // CSE7766 Serial interface (S31 and Pow R2) +#endif +#ifdef USE_MCP39F501 + GPIO_MCP39F5_TX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RST, // MCP39F501 Reset (Shelly2) +#endif +#if defined(USE_PZEM004T) || defined(USE_PZEM_AC) || defined(USE_PZEM_DC) + GPIO_PZEM0XX_TX, // PZEM0XX Serial interface +#endif +#ifdef USE_PZEM004T + GPIO_PZEM004_RX, // PZEM004T Serial interface +#endif +#ifdef USE_PZEM_AC + GPIO_PZEM016_RX, // PZEM-014,016 Serial Modbus interface +#endif +#ifdef USE_PZEM_DC + GPIO_PZEM017_RX, // PZEM-003,017 Serial Modbus interface +#endif +#ifdef USE_SDM120 + GPIO_SDM120_TX, // SDM120 Serial interface + GPIO_SDM120_RX, // SDM120 Serial interface +#endif +#ifdef USE_SDM630 + GPIO_SDM630_TX, // SDM630 Serial interface + GPIO_SDM630_RX, // SDM630 Serial interface +#endif +#ifdef USE_DDS2382 + GPIO_DDS2382_TX, // DDS2382 Serial interface + GPIO_DDS2382_RX, // DDS2382 Serial interface +#endif +#ifdef USE_DDSU666 + GPIO_DDSU666_TX, // DDSU666 Serial interface + GPIO_DDSU666_RX, // DDSU666 Serial interface +#endif // USE_DDSU666 +#ifdef USE_SOLAX_X1 + GPIO_SOLAXX1_TX, // Solax Inverter tx pin + GPIO_SOLAXX1_RX, // Solax Inverter rx pin +#endif // USE_SOLAX_X1 +#ifdef USE_LE01MR + GPIO_LE01MR_RX, // F7F LE-01MR energy meter rx pin + GPIO_LE01MR_TX, // F7F LE-01MR energy meter tx pin +#endif // IFDEF:USE_LE01MR +#endif // USE_ENERGY_SENSOR + +// Serial +#ifdef USE_SERIAL_BRIDGE + GPIO_SBR_TX, // Serial Bridge Serial interface + GPIO_SBR_RX, // Serial Bridge Serial interface +#endif +#ifdef USE_ZIGBEE + GPIO_ZIGBEE_TX, // Zigbee Serial interface + GPIO_ZIGBEE_RX, // Zigbee Serial interface +#endif +#ifdef USE_MHZ19 + GPIO_MHZ_TXD, // MH-Z19 Serial interface + GPIO_MHZ_RXD, // MH-Z19 Serial interface +#endif +#ifdef USE_SENSEAIR + GPIO_SAIR_TX, // SenseAir Serial interface + GPIO_SAIR_RX, // SenseAir Serial interface +#endif +#ifdef USE_NOVA_SDS + GPIO_SDS0X1_TX, // Nova Fitness SDS011 Serial interface + GPIO_SDS0X1_RX, // Nova Fitness SDS011 Serial interface +#endif +#ifdef USE_HPMA + GPIO_HPMA_TX, // Honeywell HPMA115S0 Serial interface + GPIO_HPMA_RX, // Honeywell HPMA115S0 Serial interface +#endif +#ifdef USE_PMS5003 + GPIO_PMS5003_TX, // Plantower PMS5003 Serial interface + GPIO_PMS5003_RX, // Plantower PMS5003 Serial interface +#endif +#if defined(USE_TX20_WIND_SENSOR) || defined(USE_TX23_WIND_SENSOR) + GPIO_TX2X_TXD_BLACK, // TX20/TX23 Transmission Pin +#endif +#ifdef USE_MP3_PLAYER + GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface +#endif +#ifdef USE_AZ7798 + GPIO_AZ_TXD, // AZ-Instrument 7798 CO2 datalogger Serial interface + GPIO_AZ_RXD, // AZ-Instrument 7798 CO2 datalogger Serial interface +#endif +#ifdef USE_PN532_HSU + GPIO_PN532_TXD, // PN532 HSU Tx + GPIO_PN532_RXD, // PN532 HSU Rx +#endif +#ifdef USE_TASMOTA_SLAVE + GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX + GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX + GPIO_TASMOTASLAVE_RST, // Tasmota Slave Reset + GPIO_TASMOTASLAVE_RST_INV, // Tasmota Slave Reset Inverted +#endif +#ifdef USE_RDM6300 + GPIO_RDM6300_RX, +#endif +#ifdef USE_IBEACON + GPIO_IBEACON_RX, + GPIO_IBEACON_TX, +#endif +#ifdef USE_GPS + GPIO_GPS_RX, // GPS serial interface + GPIO_GPS_TX, // GPS serial interface +#endif +#ifdef USE_HM10 + GPIO_HM10_RX, // GPS serial interface + GPIO_HM10_TX, // GPS serial interface +#endif + +#ifdef USE_MGC3130 + GPIO_MGC3130_XFER, + GPIO_MGC3130_RESET, +#endif +#ifdef USE_MAX31855 + GPIO_MAX31855CS, // MAX31855 Serial interface + GPIO_MAX31855CLK, // MAX31855 Serial interface + GPIO_MAX31855DO, // MAX31855 Serial interface +#endif +#ifdef ROTARY_V1 + GPIO_ROT1A, // Rotary switch1 A Pin + GPIO_ROT1B, // Rotary switch1 B Pin + GPIO_ROT2A, // Rotary switch2 A Pin + GPIO_ROT2B, // Rotary switch2 B Pin +#endif +#ifdef USE_HRE + GPIO_HRE_CLOCK, + GPIO_HRE_DATA, +#endif +#ifdef USE_A4988_STEPPER + GPIO_A4988_DIR, // A4988 direction pin + GPIO_A4988_STP, // A4988 step pin + // folowing are not mandatory + GPIO_A4988_ENA, // A4988 enabled pin + GPIO_A4988_MS1, // A4988 microstep pin1 + GPIO_A4988_MS2, // A4988 microstep pin2 + GPIO_A4988_MS3, // A4988 microstep pin3 +#endif +#ifdef USE_DEEPSLEEP + GPIO_DEEPSLEEP, +#endif +#ifdef USE_KEELOQ + GPIO_CC1101_GDO0, // CC1101 pin for RX + GPIO_CC1101_GDO2, // CC1101 pin for RX +#endif +#ifdef USE_HRXL + GPIO_HRXL_RX, +#endif +#ifdef USE_AS3935 + GPIO_AS3935, +#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|" + ; + +/********************************************************************************************/ + +// esp32 has more pins +#define USER_MODULE 255 +#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 +const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOflashcFLFLolIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOA6A7A0IoIoA3"; + +/********************************************************************************************/ + +typedef struct MYIO { + uint8_t io[MAX_GPIO_PIN]; +} myio; + +typedef struct MYCFGIO { + uint8_t io[MAX_GPIO_PIN - MIN_FLASH_PINS]; +} mycfgio; + +#define GPIO_FLAG_USED 0 // Currently two flags used + +#define GPIO_FLAG_SPARE04 16 +#define GPIO_FLAG_SPARE05 32 +#define GPIO_FLAG_SPARE06 64 +#define GPIO_FLAG_SPARE07 128 + +typedef union { + uint8_t data; + struct { + uint8_t adc0 : 4; // Allow ADC0 when define USE_ADC_VCC is disabled + uint8_t spare04 : 1; + uint8_t spare05 : 1; + uint8_t spare06 : 1; + uint8_t spare07 : 1; + }; +} gpio_flag; + +typedef struct MYTMPLT { + mycfgio gp; + gpio_flag flag; +} mytmplt; + /********************************************************************************************/ // Supported hardware modules + enum SupportedModules { WEMOS, ESP32_CAM_AITHINKER, MAXMODULE}; +#define USER_MODULE 255 + const char kModuleNames[] PROGMEM = "ESP32-DevKit|ESP32 Cam AiThinker"; @@ -102,6 +829,10 @@ const mytmplt kModules PROGMEM = 0 // Flag }; +#else // FINAL_ESP32 +#include "tasmota_template_ESP32_final.h" +#endif // FINAL_ESP32 + #endif // ESP32 #endif // _TASMOTA_TEMPLATE_ESP32_H_ diff --git a/tasmota/tasmota_template_ESP32_final.h b/tasmota/tasmota_template_ESP32_final.h new file mode 100644 index 000000000..e13dbec24 --- /dev/null +++ b/tasmota/tasmota_template_ESP32_final.h @@ -0,0 +1,742 @@ +/* + tasmota_template_ESP32_final.h - template settings for Tasmota + + Copyright (C) 2020 Theo Arends + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _TASMOTA_TEMPLATE_ESP32_FINAL_H_ +#define _TASMOTA_TEMPLATE_ESP32_FINAL_H_ + +#ifdef ESP32 + +// Hardware has no ESP32 +#undef USE_TUYA_DIMMER +#undef USE_PWM_DIMMER +#undef USE_EXS_DIMMER +#undef USE_ARMTRONIX_DIMMERS +#undef USE_SONOFF_RF +#undef USE_SONOFF_SC +#undef USE_SONOFF_IFAN +#undef USE_SONOFF_L1 +#undef USE_SONOFF_D1 +#undef USE_RF_FLASH + +// Not ported (yet) +#undef USE_DISCOVERY +#undef USE_ADC_VCC // Needs to be ported +#undef USE_DEEPSLEEP +#undef USE_MY92X1 +#undef USE_TUYA_MCU +#undef USE_PS_16_DZ + +enum UserSelectablePins { + GPIO_NONE, // Not used + GPIO_KEY1, // 4 x Button usually connected to GPIO0 + GPIO_KEY1_NP, + GPIO_KEY1_INV, + GPIO_KEY1_INV_NP, + GPIO_SWT1, // 8 x User connected external switches + GPIO_SWT1_NP, + GPIO_REL1, // 8 x Relays + GPIO_REL1_INV, + GPIO_LED1, // 4 x Leds + GPIO_LED1_INV, + GPIO_CNTR1, // 4 x Counter + GPIO_CNTR1_NP, + GPIO_PWM1, // 5 x PWM + GPIO_PWM1_INV, + GPIO_BUZZER, // Buzzer + GPIO_BUZZER_INV, // Inverted buzzer + GPIO_LEDLNK, // Link led + GPIO_LEDLNK_INV, // Inverted link led + GPIO_I2C_SCL, // I2C SCL + GPIO_I2C_SDA, // I2C SDA + GPIO_SPI_MISO, // SPI MISO + GPIO_SPI_MOSI, // SPI MOSI + GPIO_SPI_CLK, // SPI Clk + GPIO_SPI_CS, // SPI Chip Select + GPIO_SPI_DC, // SPI Data Direction + GPIO_SSPI_MISO, // Software SPI Master Input Slave Output + GPIO_SSPI_MOSI, // Software SPI Master Output Slave Input + GPIO_SSPI_SCLK, // Software SPI Serial Clock + GPIO_SSPI_CS, // Software SPI Chip Select + GPIO_SSPI_DC, // Software SPI Data or Command + GPIO_BACKLIGHT, // Display backlight control + GPIO_OLED_RESET, // OLED Display Reset + GPIO_IRSEND, // IR remote + GPIO_IRRECV, // IR receiver + GPIO_RFSEND, // RF transmitter + GPIO_RFRECV, // RF receiver + GPIO_DHT11, // DHT11 + GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_SI7021, // iTead SI7021 + GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_DSB, // Single wire DS18B20 or DS18S20 + GPIO_DSB_OUT, // Pseudo Single wire DS18B20 or DS18S20 + GPIO_WS2812, // WS2812 Led string + GPIO_MHZ_TXD, // MH-Z19 Serial interface + GPIO_MHZ_RXD, // MH-Z19 Serial interface + GPIO_PZEM0XX_TX, // PZEM0XX Serial interface + GPIO_PZEM004_RX, // PZEM004T Serial interface + GPIO_PZEM016_RX, // PZEM-014,016 Serial Modbus interface + GPIO_PZEM017_RX, // PZEM-003,017 Serial Modbus interface + GPIO_SAIR_TX, // SenseAir Serial interface + GPIO_SAIR_RX, // SenseAir Serial interface + GPIO_PMS5003_TX, // Plantower PMS5003 Serial interface + GPIO_PMS5003_RX, // Plantower PMS5003 Serial interface + GPIO_SDS0X1_TX, // Nova Fitness SDS011 Serial interface + GPIO_SDS0X1_RX, // Nova Fitness SDS011 Serial interface + GPIO_SBR_TX, // Serial Bridge Serial interface + GPIO_SBR_RX, // Serial Bridge Serial interface + GPIO_SR04_TRIG, // SR04 Trigger/TX pin + GPIO_SR04_ECHO, // SR04 Echo/RX pin + GPIO_SDM120_TX, // SDM120 Serial interface + GPIO_SDM120_RX, // SDM120 Serial interface + GPIO_SDM630_TX, // SDM630 Serial interface + GPIO_SDM630_RX, // SDM630 Serial interface + GPIO_TM16CLK, // TM1638 Clock + GPIO_TM16DIO, // TM1638 Data I/O + GPIO_TM16STB, // TM1638 Strobe + GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player + GPIO_HX711_SCK, // HX711 Load Cell clock + GPIO_HX711_DAT, // HX711 Load Cell data + GPIO_TX2X_TXD_BLACK, // TX20/TX23 Transmission Pin + GPIO_TUYA_TX, // Tuya Serial interface + GPIO_TUYA_RX, // Tuya Serial interface + GPIO_MGC3130_XFER, // MGC3130 Transfer + GPIO_MGC3130_RESET, // MGC3130 Reset + GPIO_RF_SENSOR, // Rf receiver with sensor decoding + GPIO_AZ_TXD, // AZ-Instrument 7798 Serial interface + GPIO_AZ_RXD, // AZ-Instrument 7798 Serial interface + GPIO_MAX31855CS, // MAX31855 Serial interface + GPIO_MAX31855CLK, // MAX31855 Serial interface + GPIO_MAX31855DO, // MAX31855 Serial interface + GPIO_NRG_SEL, // HLW8012/HLJ-01 Sel output (1 = Voltage) + GPIO_NRG_SEL_INV, // HLW8012/HLJ-01 Sel output (0 = Voltage) + GPIO_NRG_CF1, // HLW8012/HLJ-01 CF1 voltage / current + GPIO_HLW_CF, // HLW8012 CF power + GPIO_HJL_CF, // HJL-01/BL0937 CF power + GPIO_MCP39F5_TX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RST, // MCP39F501 Reset (Shelly2) + GPIO_PN532_TXD, // PN532 NFC Serial Tx + GPIO_PN532_RXD, // PN532 NFC Serial Rx + GPIO_SM16716_CLK, // SM16716 CLOCK + GPIO_SM16716_DAT, // SM16716 DATA + GPIO_SM16716_SEL, // SM16716 SELECT + GPIO_DI, // my92x1 PWM input + GPIO_DCKI, // my92x1 CLK input + GPIO_CSE7766_TX, // CSE7766 Serial interface (S31 and Pow R2) - Not used anymore 20200121 + GPIO_CSE7766_RX, // CSE7766 Serial interface (S31 and Pow R2) + GPIO_ARIRFRCV, // AriLux RF Receive input + GPIO_TXD, // Serial interface + GPIO_RXD, // Serial interface + GPIO_ROT1A, // Rotary switch1 A Pin + GPIO_ROT1B, // Rotary switch1 B Pin + GPIO_ROT2A, // Rotary switch2 A Pin + GPIO_ROT2B, // Rotary switch2 B Pin + GPIO_HRE_CLOCK, // Clock/Power line for HR-E Water Meter + GPIO_HRE_DATA, // Data line for HR-E Water Meter + GPIO_ADE7953_IRQ, // ADE7953 IRQ + GPIO_ARIRFSEL, // Arilux RF Receive input selected + GPIO_SOLAXX1_TX, // Solax Inverter tx pin + GPIO_SOLAXX1_RX, // Solax Inverter rx pin + GPIO_ZIGBEE_TX, // Zigbee Serial interface + GPIO_ZIGBEE_RX, // Zigbee Serial interface + GPIO_RDM6300_RX, // RDM6300 RX + GPIO_IBEACON_TX, // HM17 IBEACON TX + GPIO_IBEACON_RX, // HM17 IBEACON RX + GPIO_A4988_DIR, // A4988 direction pin + GPIO_A4988_STP, // A4988 step pin + GPIO_A4988_ENA, // A4988 enabled pin + GPIO_A4988_MS1, // A4988 microstep pin1 + GPIO_A4988_MS2, // A4988 microstep pin2 + GPIO_A4988_MS3, // A4988 microstep pin3 + GPIO_DDS2382_TX, // DDS2382 Serial interface + GPIO_DDS2382_RX, // DDS2382 Serial interface + GPIO_DDSU666_TX, // DDSU666 Serial interface + GPIO_DDSU666_RX, // DDSU666 Serial interface + GPIO_SM2135_CLK, // SM2135 Clk + GPIO_SM2135_DAT, // SM2135 Dat + GPIO_DEEPSLEEP, // Kill switch for deepsleep + GPIO_EXS_ENABLE, // EXS MCU Enable + GPIO_TASMOTASLAVE_TXD, // Slave TX + GPIO_TASMOTASLAVE_RXD, // Slave RX + GPIO_TASMOTASLAVE_RST, // Slave Reset Pin + GPIO_TASMOTASLAVE_RST_INV, // Slave Reset Inverted + GPIO_HPMA_RX, // Honeywell HPMA115S0 Serial interface + GPIO_HPMA_TX, // Honeywell HPMA115S0 Serial interface + GPIO_GPS_RX, // GPS serial interface + GPIO_GPS_TX, // GPS serial interface + GPIO_HM10_RX, // HM10-BLE-Mijia-bridge serial interface + GPIO_HM10_TX, // HM10-BLE-Mijia-bridge serial interface + GPIO_LE01MR_RX, // F&F LE-01MR energy meter + GPIO_LE01MR_TX, // F&F LE-01MR energy meter + GPIO_CC1101_GDO0, // CC1101 pin for RX + GPIO_CC1101_GDO2, // CC1101 pin for RX + 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 + ADC0_BUTTON, // Button + ADC0_BUTTON_INV, + ADC0_RANGE, // Range + ADC0_CT_POWER, // Current +*/ + GPIO_SENSOR_END }; + +enum ProgramSelectablePins { +// GPIO_FIX_START = 254, + GPIO_FIX_START = 2046, + GPIO_USER, // User configurable needs to be 2047 + GPIO_MAX }; + +// Text in webpage Module Parameters and commands GPIOS and GPIO +const char kSensorNames[] PROGMEM = + D_SENSOR_NONE "|" + D_SENSOR_BUTTON "|" + D_SENSOR_BUTTON "n|" + D_SENSOR_BUTTON "i|" + D_SENSOR_BUTTON "in|" + D_SENSOR_SWITCH "|" + D_SENSOR_SWITCH "n|" + D_SENSOR_RELAY "|" + D_SENSOR_RELAY "i|" + D_SENSOR_LED "|" + D_SENSOR_LED "i|" + D_SENSOR_COUNTER "|" + D_SENSOR_COUNTER "n|" + D_SENSOR_PWM "|" + D_SENSOR_PWM "i|" + D_SENSOR_BUZZER "|" + D_SENSOR_BUZZER "i|" + D_SENSOR_LED_LINK "|" D_SENSOR_LED_LINK "i|" + D_SENSOR_I2C_SCL "|" D_SENSOR_I2C_SDA "|" + D_SENSOR_SPI_MISO "|" D_SENSOR_SPI_MOSI "|" D_SENSOR_SPI_CLK "|" D_SENSOR_SPI_CS "|" D_SENSOR_SPI_DC "|" + D_SENSOR_SSPI_MISO "|" D_SENSOR_SSPI_MOSI "|" D_SENSOR_SSPI_SCLK "|" D_SENSOR_SSPI_CS "|" D_SENSOR_SSPI_DC "|" + D_SENSOR_BACKLIGHT "|" D_SENSOR_OLED_RESET "|" + D_SENSOR_IRSEND "|" D_SENSOR_IRRECV "|" + D_SENSOR_RFSEND "|" D_SENSOR_RFRECV "|" + D_SENSOR_DHT11 "|" D_SENSOR_AM2301 "|" D_SENSOR_SI7021 "|" D_SENSOR_DHT11 "o|" + D_SENSOR_DS18X20 "|" D_SENSOR_DS18X20 "o|" + D_SENSOR_WS2812 "|" + D_SENSOR_MHZ_TX "|" D_SENSOR_MHZ_RX "|" + D_SENSOR_PZEM0XX_TX "|" D_SENSOR_PZEM004_RX "|" D_SENSOR_PZEM016_RX "|" D_SENSOR_PZEM017_RX "|" + D_SENSOR_SAIR_TX "|" D_SENSOR_SAIR_RX "|" + D_SENSOR_PMS5003_TX "|" D_SENSOR_PMS5003_RX "|" + D_SENSOR_SDS0X1_TX "|" D_SENSOR_SDS0X1_RX "|" + D_SENSOR_SBR_TX "|" D_SENSOR_SBR_RX "|" + D_SENSOR_SR04_TRIG "|" D_SENSOR_SR04_ECHO "|" + D_SENSOR_SDM120_TX "|" D_SENSOR_SDM120_RX "|" + D_SENSOR_SDM630_TX "|" D_SENSOR_SDM630_RX "|" + D_SENSOR_TM1638_CLK "|" D_SENSOR_TM1638_DIO "|" D_SENSOR_TM1638_STB "|" + D_SENSOR_DFR562 "|" + D_SENSOR_HX711_SCK "|" D_SENSOR_HX711_DAT "|" + D_SENSOR_TX2X_TX "|" + D_SENSOR_TUYA_TX "|" D_SENSOR_TUYA_RX "|" + D_SENSOR_MGC3130_XFER "|" D_SENSOR_MGC3130_RESET "|" + D_SENSOR_RF_SENSOR "|" + D_SENSOR_AZ_TX "|" D_SENSOR_AZ_RX "|" + D_SENSOR_MAX31855_CS "|" D_SENSOR_MAX31855_CLK "|" D_SENSOR_MAX31855_DO "|" + D_SENSOR_NRG_SEL "|" D_SENSOR_NRG_SEL "i|" D_SENSOR_NRG_CF1 "|" D_SENSOR_HLW_CF "|" D_SENSOR_HJL_CF "|" + D_SENSOR_MCP39F5_TX "|" D_SENSOR_MCP39F5_RX "|" D_SENSOR_MCP39F5_RST "|" + D_SENSOR_PN532_TX "|" D_SENSOR_PN532_RX "|" + D_SENSOR_SM16716_CLK "|" D_SENSOR_SM16716_DAT "|" D_SENSOR_SM16716_POWER "|" + D_SENSOR_MY92X1_DI "|" D_SENSOR_MY92X1_DCKI "|" + D_SENSOR_CSE7766_TX "|" D_SENSOR_CSE7766_RX "|" + D_SENSOR_ARIRFRCV "|" + D_SENSOR_TXD "|" D_SENSOR_RXD "|" + D_SENSOR_ROTARY "1a|" D_SENSOR_ROTARY "1b|" D_SENSOR_ROTARY "2a|" D_SENSOR_ROTARY "2b|" + D_SENSOR_HRE_CLOCK "|" D_SENSOR_HRE_DATA "|" + D_SENSOR_ADE7953_IRQ "|" + D_SENSOR_ARIRFSEL "|" + D_SENSOR_SOLAXX1_TX "|" D_SENSOR_SOLAXX1_RX "|" + D_SENSOR_ZIGBEE_TXD "|" D_SENSOR_ZIGBEE_RXD "|" + D_SENSOR_RDM6300_RX "|" + D_SENSOR_IBEACON_TX "|" D_SENSOR_IBEACON_RX "|" + D_SENSOR_A4988_DIR "|" D_SENSOR_A4988_STP "|" D_SENSOR_A4988_ENA "|" D_SENSOR_A4988_MS1 "|" D_SENSOR_A4988_MS2 "|" D_SENSOR_A4988_MS3 "|" + D_SENSOR_DDS2382_TX "|" D_SENSOR_DDS2382_RX "|" + D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|" + D_SENSOR_SM2135_CLK "|" D_SENSOR_SM2135_DAT "|" + D_SENSOR_DEEPSLEEP "|" D_SENSOR_EXS_ENABLE "|" + D_SENSOR_SLAVE_TX "|" D_SENSOR_SLAVE_RX "|" D_SENSOR_SLAVE_RESET "|" D_SENSOR_SLAVE_RESET "i|" + D_SENSOR_HPMA_RX "|" D_SENSOR_HPMA_TX "|" + D_SENSOR_GPS_RX "|" D_SENSOR_GPS_TX "|" + D_SENSOR_HM10_RX "|" D_SENSOR_HM10_TX "|" + D_SENSOR_LE01MR_RX "|" D_SENSOR_LE01MR_TX "|" + D_SENSOR_CC1101_GDO0 "|" D_SENSOR_CC1101_GDO2 "|" + 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 = + D_SENSOR_USER; + +const uint16_t kGpioNiceList[] PROGMEM = { + GPIO_NONE, // Not used + GPIO_KEY1, // Buttons + GPIO_KEY1_NP, + GPIO_KEY1_INV, + GPIO_KEY1_INV_NP, + GPIO_SWT1, // User connected external switches + GPIO_SWT1_NP, + GPIO_REL1, // Relays + GPIO_REL1_INV, + GPIO_LED1, // Leds + GPIO_LED1_INV, +#ifdef USE_COUNTER + GPIO_CNTR1, // Counters + GPIO_CNTR1_NP, +#endif + GPIO_PWM1, // RGB Red or C Cold White + GPIO_PWM1_INV, +#ifdef USE_BUZZER + GPIO_BUZZER, // Buzzer + GPIO_BUZZER_INV, // Inverted buzzer +#endif + GPIO_LEDLNK, // Link led + GPIO_LEDLNK_INV, // Inverted link led +#ifdef USE_I2C + GPIO_I2C_SCL, // I2C SCL + GPIO_I2C_SDA, // I2C SDA +#endif +#ifdef USE_SPI + GPIO_SPI_MISO, // SPI MISO + GPIO_SPI_MOSI, // SPI MOSI + GPIO_SPI_CLK, // SPI Clk + GPIO_SPI_CS, // SPI Chip Select + GPIO_SPI_DC, // SPI Data Direction + GPIO_SSPI_MISO, // Software SPI Master Input Slave Output + GPIO_SSPI_MOSI, // Software SPI Master Output Slave Input + GPIO_SSPI_SCLK, // Software SPI Serial Clock + GPIO_SSPI_CS, // Software SPI Chip Select + GPIO_SSPI_DC, // Software SPI Data or Command +#endif +#ifdef USE_DISPLAY + GPIO_BACKLIGHT, // Display backlight control + GPIO_OLED_RESET, // OLED Display Reset +#endif + + GPIO_TXD, // Serial interface + GPIO_RXD, // Serial interface + +#ifdef USE_DHT + GPIO_DHT11, // DHT11 + GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_SI7021, // iTead SI7021 + GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321 +#endif +#ifdef USE_DS18x20 + GPIO_DSB, // Single wire DS18B20 or DS18S20 + GPIO_DSB_OUT, // Pseudo Single wire DS18B20 or DS18S20 +#endif + +// Light +#ifdef USE_LIGHT +#ifdef USE_WS2812 + GPIO_WS2812, // WS2812 Led string +#endif +#ifdef USE_ARILUX_RF + GPIO_ARIRFRCV, // AriLux RF Receive input + GPIO_ARIRFSEL, // Arilux RF Receive input selected +#endif +#ifdef USE_MY92X1 + GPIO_DI, // my92x1 PWM input + GPIO_DCKI, // my92x1 CLK input +#endif // USE_MY92X1 +#ifdef USE_SM16716 + GPIO_SM16716_CLK, // SM16716 CLOCK + GPIO_SM16716_DAT, // SM16716 DATA + GPIO_SM16716_SEL, // SM16716 SELECT +#endif // USE_SM16716 +#ifdef USE_SM2135 + GPIO_SM2135_CLK, // SM2135 CLOCK + GPIO_SM2135_DAT, // SM2135 DATA +#endif // USE_SM2135 +#ifdef USE_TUYA_MCU + GPIO_TUYA_TX, // Tuya Serial interface + GPIO_TUYA_RX, // Tuya Serial interface +#endif +#ifdef USE_EXS_DIMMER + GPIO_EXS_ENABLE, // EXS MCU Enable +#endif +#ifdef USE_ELECTRIQ_MOODL + GPIO_ELECTRIQ_MOODL_TX, +#endif +#endif // USE_LIGHT + +#if defined(USE_IR_REMOTE) || defined(USE_IR_REMOTE_FULL) + GPIO_IRSEND, // IR remote +#if defined(USE_IR_RECEIVE) || defined(USE_IR_REMOTE_FULL) + GPIO_IRRECV, // IR receiver +#endif +#endif + +#ifdef USE_RC_SWITCH + GPIO_RFSEND, // RF transmitter + GPIO_RFRECV, // RF receiver +#endif +#ifdef USE_RF_SENSOR + GPIO_RF_SENSOR, // Rf receiver with sensor decoding +#endif +#ifdef USE_SR04 + GPIO_SR04_TRIG, // SR04 Tri/TXgger pin + GPIO_SR04_ECHO, // SR04 Ech/RXo pin +#endif +#ifdef USE_TM1638 + GPIO_TM16CLK, // TM1638 Clock + GPIO_TM16DIO, // TM1638 Data I/O + GPIO_TM16STB, // TM1638 Strobe +#endif +#ifdef USE_HX711 + GPIO_HX711_SCK, // HX711 Load Cell clock + GPIO_HX711_DAT, // HX711 Load Cell data +#endif + +// Energy sensors +#ifdef USE_ENERGY_SENSOR +#ifdef USE_HLW8012 + GPIO_NRG_SEL, // HLW8012/HLJ-01 Sel output (1 = Voltage) + GPIO_NRG_SEL_INV, // HLW8012/HLJ-01 Sel output (0 = Voltage) + GPIO_NRG_CF1, // HLW8012/HLJ-01 CF1 voltage / current + GPIO_HLW_CF, // HLW8012 CF power + GPIO_HJL_CF, // HJL-01/BL0937 CF power +#endif +#if defined(USE_I2C) && defined(USE_ADE7953) + GPIO_ADE7953_IRQ, // ADE7953 IRQ +#endif +#ifdef USE_CSE7766 + GPIO_CSE7766_TX, // CSE7766 Serial interface (S31 and Pow R2) + GPIO_CSE7766_RX, // CSE7766 Serial interface (S31 and Pow R2) +#endif +#ifdef USE_MCP39F501 + GPIO_MCP39F5_TX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RX, // MCP39F501 Serial interface (Shelly2) + GPIO_MCP39F5_RST, // MCP39F501 Reset (Shelly2) +#endif +#if defined(USE_PZEM004T) || defined(USE_PZEM_AC) || defined(USE_PZEM_DC) + GPIO_PZEM0XX_TX, // PZEM0XX Serial interface +#endif +#ifdef USE_PZEM004T + GPIO_PZEM004_RX, // PZEM004T Serial interface +#endif +#ifdef USE_PZEM_AC + GPIO_PZEM016_RX, // PZEM-014,016 Serial Modbus interface +#endif +#ifdef USE_PZEM_DC + GPIO_PZEM017_RX, // PZEM-003,017 Serial Modbus interface +#endif +#ifdef USE_SDM120 + GPIO_SDM120_TX, // SDM120 Serial interface + GPIO_SDM120_RX, // SDM120 Serial interface +#endif +#ifdef USE_SDM630 + GPIO_SDM630_TX, // SDM630 Serial interface + GPIO_SDM630_RX, // SDM630 Serial interface +#endif +#ifdef USE_DDS2382 + GPIO_DDS2382_TX, // DDS2382 Serial interface + GPIO_DDS2382_RX, // DDS2382 Serial interface +#endif +#ifdef USE_DDSU666 + GPIO_DDSU666_TX, // DDSU666 Serial interface + GPIO_DDSU666_RX, // DDSU666 Serial interface +#endif // USE_DDSU666 +#ifdef USE_SOLAX_X1 + GPIO_SOLAXX1_TX, // Solax Inverter tx pin + GPIO_SOLAXX1_RX, // Solax Inverter rx pin +#endif // USE_SOLAX_X1 +#ifdef USE_LE01MR + GPIO_LE01MR_RX, // F7F LE-01MR energy meter rx pin + GPIO_LE01MR_TX, // F7F LE-01MR energy meter tx pin +#endif // IFDEF:USE_LE01MR +#endif // USE_ENERGY_SENSOR + +// Serial +#ifdef USE_SERIAL_BRIDGE + GPIO_SBR_TX, // Serial Bridge Serial interface + GPIO_SBR_RX, // Serial Bridge Serial interface +#endif +#ifdef USE_ZIGBEE + GPIO_ZIGBEE_TX, // Zigbee Serial interface + GPIO_ZIGBEE_RX, // Zigbee Serial interface +#endif +#ifdef USE_MHZ19 + GPIO_MHZ_TXD, // MH-Z19 Serial interface + GPIO_MHZ_RXD, // MH-Z19 Serial interface +#endif +#ifdef USE_SENSEAIR + GPIO_SAIR_TX, // SenseAir Serial interface + GPIO_SAIR_RX, // SenseAir Serial interface +#endif +#ifdef USE_NOVA_SDS + GPIO_SDS0X1_TX, // Nova Fitness SDS011 Serial interface + GPIO_SDS0X1_RX, // Nova Fitness SDS011 Serial interface +#endif +#ifdef USE_HPMA + GPIO_HPMA_TX, // Honeywell HPMA115S0 Serial interface + GPIO_HPMA_RX, // Honeywell HPMA115S0 Serial interface +#endif +#ifdef USE_PMS5003 + GPIO_PMS5003_TX, // Plantower PMS5003 Serial interface + GPIO_PMS5003_RX, // Plantower PMS5003 Serial interface +#endif +#if defined(USE_TX20_WIND_SENSOR) || defined(USE_TX23_WIND_SENSOR) + GPIO_TX2X_TXD_BLACK, // TX20/TX23 Transmission Pin +#endif +#ifdef USE_MP3_PLAYER + GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface +#endif +#ifdef USE_AZ7798 + GPIO_AZ_TXD, // AZ-Instrument 7798 CO2 datalogger Serial interface + GPIO_AZ_RXD, // AZ-Instrument 7798 CO2 datalogger Serial interface +#endif +#ifdef USE_PN532_HSU + GPIO_PN532_TXD, // PN532 HSU Tx + GPIO_PN532_RXD, // PN532 HSU Rx +#endif +#ifdef USE_TASMOTA_SLAVE + GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX + GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX + GPIO_TASMOTASLAVE_RST, // Tasmota Slave Reset + GPIO_TASMOTASLAVE_RST_INV, // Tasmota Slave Reset Inverted +#endif +#ifdef USE_RDM6300 + GPIO_RDM6300_RX, +#endif +#ifdef USE_IBEACON + GPIO_IBEACON_RX, + GPIO_IBEACON_TX, +#endif +#ifdef USE_GPS + GPIO_GPS_RX, // GPS serial interface + GPIO_GPS_TX, // GPS serial interface +#endif +#ifdef USE_HM10 + GPIO_HM10_RX, // GPS serial interface + GPIO_HM10_TX, // GPS serial interface +#endif + +#ifdef USE_MGC3130 + GPIO_MGC3130_XFER, + GPIO_MGC3130_RESET, +#endif +#ifdef USE_MAX31855 + GPIO_MAX31855CS, // MAX31855 Serial interface + GPIO_MAX31855CLK, // MAX31855 Serial interface + GPIO_MAX31855DO, // MAX31855 Serial interface +#endif +#ifdef ROTARY_V1 + GPIO_ROT1A, // Rotary switch1 A Pin + GPIO_ROT1B, // Rotary switch1 B Pin + GPIO_ROT2A, // Rotary switch2 A Pin + GPIO_ROT2B, // Rotary switch2 B Pin +#endif +#ifdef USE_HRE + GPIO_HRE_CLOCK, + GPIO_HRE_DATA, +#endif +#ifdef USE_A4988_STEPPER + GPIO_A4988_DIR, // A4988 direction pin + GPIO_A4988_STP, // A4988 step pin + // folowing are not mandatory + GPIO_A4988_ENA, // A4988 enabled pin + GPIO_A4988_MS1, // A4988 microstep pin1 + GPIO_A4988_MS2, // A4988 microstep pin2 + GPIO_A4988_MS3, // A4988 microstep pin3 +#endif +#ifdef USE_DEEPSLEEP + GPIO_DEEPSLEEP, +#endif +#ifdef USE_KEELOQ + GPIO_CC1101_GDO0, // CC1101 pin for RX + GPIO_CC1101_GDO2, // CC1101 pin for RX +#endif +#ifdef USE_HRXL + GPIO_HRXL_RX, +#endif +#ifdef USE_AS3935 + 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 +*/ +}; + +//******************************************************************************************** + +// 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 +const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOflashcFLFLolIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOA6A7A0IoIoA3"; + +//******************************************************************************************** + +typedef struct MYIO { + uint16_t io[MAX_GPIO_PIN]; +} myio; // 40 * 2 = 80 bytes + +typedef struct MYCFGIO { + uint16_t io[MAX_USER_PINS]; +} mycfgio; // 36 * 2 = 72 bytes + +#define GPIO_FLAG_USED 0 // Currently no flags used + +typedef union { + uint16_t data; + struct { + uint16_t spare00 : 1; + uint16_t spare01 : 1; + uint16_t spare02 : 1; + uint16_t spare03 : 1; + uint16_t spare04 : 1; + uint16_t spare05 : 1; + uint16_t spare06 : 1; + uint16_t spare07 : 1; + uint16_t spare08 : 1; + uint16_t spare09 : 1; + uint16_t spare10 : 1; + uint16_t spare11 : 1; + uint16_t spare12 : 1; + uint16_t spare13 : 1; + uint16_t spare14 : 1; + uint16_t spare15 : 1; + }; +} gpio_flag; // 2 bytes + +typedef struct MYTMPLT { + mycfgio gp; // 72 bytes + gpio_flag flag; // 2 bytes +} mytmplt; // 74 bytes + +/********************************************************************************************/ +// Supported hardware modules +enum SupportedModules { + WEMOS, ESP32_CAM_AITHINKER, + MAXMODULE}; + +#define USER_MODULE 255 + +const char kModuleNames[] PROGMEM = + "ESP32-DevKit|ESP32 Cam AiThinker"; + +// Default module settings +const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = { + WEMOS, + ESP32_CAM_AITHINKER +}; + +const mytmplt kModules PROGMEM = +{ // WEMOS - Espressif ESP32-DevKitC - Any ESP32 device like WeMos and NodeMCU hardware (ESP32) + GPIO_USER << 5, // 0 (I)O GPIO0, ADC2_CH1, TOUCH1, RTC_GPIO11, CLK_OUT1, EMAC_TX_CLK + GPIO_USER << 5, // 1 IO TXD0 GPIO1, U0TXD, CLK_OUT3, EMAC_RXD2 + GPIO_USER << 5, // 2 IO GPIO2, ADC2_CH2, TOUCH2, RTC_GPIO12, HSPIWP, HS2_DATA0, SD_DATA0 + GPIO_USER << 5, // 3 IO RXD0 GPIO3, U0RXD, CLK_OUT2 + GPIO_USER << 5, // 4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER + GPIO_USER << 5, // 5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK + // 6 IO GPIO6, Flash CLK + // 7 IO GPIO7, Flash D0 + // 8 IO GPIO8, Flash D1 + GPIO_USER << 5, // 9 IO GPIO9, Flash D2, U1RXD + GPIO_USER << 5, // 10 IO GPIO10, Flash D3, U1TXD + // 11 IO GPIO11, Flash CMD + GPIO_USER << 5, // 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 << 5, // 13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER + GPIO_USER << 5, // 14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 + GPIO_USER << 5, // 15 (I)O GPIO15, ADC2_CH3, TOUCH3, MTDO, HSPICS0, RTC_GPIO13, HS2_CMD, SD_CMD, EMAC_RXD3 (If driven Low, silences boot messages from normal boot. Has internal pull-up, so unconnected = High = normal output.) + GPIO_USER << 5, // 16 IO GPIO16, HS1_DATA4, U2RXD, EMAC_CLK_OUT + GPIO_USER << 5, // 17 IO GPIO17, HS1_DATA5, U2TXD, EMAC_CLK_OUT_180 + GPIO_USER << 5, // 18 IO GPIO18, VSPICLK, HS1_DATA7 + GPIO_USER << 5, // 19 IO GPIO19, VSPIQ, U0CTS, EMAC_TXD0 + 0, // 20 + GPIO_USER << 5, // 21 IO GPIO21, VSPIHD, EMAC_TX_EN + GPIO_USER << 5, // 22 IO LED GPIO22, VSPIWP, U0RTS, EMAC_TXD1 + GPIO_USER << 5, // 23 IO GPIO23, VSPID, HS1_STROBE + 0, // 24 + GPIO_USER << 5, // 25 IO GPIO25, DAC_1, ADC2_CH8, RTC_GPIO6, EMAC_RXD0 + GPIO_USER << 5, // 26 IO GPIO26, DAC_2, ADC2_CH9, RTC_GPIO7, EMAC_RXD1 + GPIO_USER << 5, // 27 IO GPIO27, ADC2_CH7, TOUCH7, RTC_GPIO17, EMAC_RX_DV + 0, // 28 + 0, // 29 + 0, // 30 + 0, // 31 + GPIO_USER << 5, // 32 IO GPIO32, XTAL_32K_P (32.768 kHz crystal oscillator input), ADC1_CH4, TOUCH9, RTC_GPIO9 + GPIO_USER << 5, // 33 IO GPIO33, XTAL_32K_N (32.768 kHz crystal oscillator output), ADC1_CH5, TOUCH8, RTC_GPIO8 + GPIO_USER << 5, // 34 I NO PULLUP GPIO34, ADC1_CH6, RTC_GPIO4 + GPIO_USER << 5, // 35 I NO PULLUP GPIO35, ADC1_CH7, RTC_GPIO5 + GPIO_USER << 5, // 36 I NO PULLUP GPIO36, SENSOR_VP, ADC_H, ADC1_CH0, RTC_GPIO0 + 0, // 37 NO PULLUP + 0, // 38 NO PULLUP + GPIO_USER << 5, // 39 I NO PULLUP GPIO39, SENSOR_VN, ADC1_CH3, ADC_H, RTC_GPIO3 + 0 // Flag +}; + +#endif // ESP32 + +#endif // _TASMOTA_TEMPLATE_ESP32_FINAL_H_