diff --git a/RELEASENOTES.md b/RELEASENOTES.md index eb9da8a74..6d46d8cda 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -55,3 +55,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ### Version 8.2.0.1 - Change HM-10 sensor type detection and add features (#7962) +- Change GPIO initialization solving possible Relay toggle on (OTA) restart +- Add command ``ZbRestore`` to restore device configuration dumped with ``ZbStatus 2`` diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 9851355a0..bea282bd9 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -3,6 +3,7 @@ ### 8.2.0.1 20200321 - Change HM-10 sensor type detection and add features (#7962) +- Change GPIO initialization solving possible Relay toggle on (OTA) restart - Add command ``ZbRestore`` to restore device configuration dumped with ``ZbStatus 2`` ## Released diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index d8ca2668c..1caaa2779 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1297,6 +1297,18 @@ void SerialInput(void) /********************************************************************************************/ +void ResetPwm(void) +{ + for (uint32_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only + if (pin[GPIO_PWM1 +i] < 99) { + analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range : 0); +// analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - Settings.pwm_value[i] : Settings.pwm_value[i]); + } + } +} + +/********************************************************************************************/ + void GpioInit(void) { uint32_t mpin; @@ -1506,6 +1518,17 @@ void GpioInit(void) RotaryInit(); #endif + // Set any non-used GPIO to INPUT + for (uint32_t i = 0; i < sizeof(my_module.io); i++) { + mpin = ValidPin(i, my_module.io[i]); +// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin); + if (((i < 6) || (i > 11)) && (0 == mpin)) { // Skip SPI flash interface + if (!((1 == i) || (3 == i))) { // Skip serial + pinMode(i, INPUT); + } + } + } + SetLedPower(Settings.ledstate &8); SetLedLink(Settings.ledstate &8); diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index f4e88a49d..efc0f9a26 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -694,6 +694,7 @@ void WifiShutdown(bool option = false) void EspRestart(void) { + ResetPwm(); WifiShutdown(true); CrashDumpClear(); // Clear the stack dump in RTC // ESP.restart(); // This results in exception 3 on restarts on core 2.3.0