diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a052bdf2..8cc3dcf2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file. - Allow negative values for AdcParam/AdcGpio INPUT, TEMP and RANGE parameters (#22809) - GPIOViewer from v1.5.9 to v1.6.0 (No functional change) - ESP32 Platform from 2025.01.30 to 2025.01.31 (#22832) +- Berry `gpio.pin_mode` frees PWM on pin ### Fixed - Sonoff SPM `PowerOnState` overrules `SSPMPowerOnState` in mixed 4Relay setup with 4Relay version 1.0.0 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index aba5cbcd5..f25b68090 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -148,6 +148,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Allow negative values for AdcParam/AdcGpio INPUT, TEMP and RANGE parameters [#22809](https://github.com/arendst/Tasmota/issues/22809) - Command `Pixels` has backwards compatible arguments fixing #22755 [#22791](https://github.com/arendst/Tasmota/issues/22791) - ESP32 disable PSRAM check (and on restart some relay toggles) with `#define DISABLE_PSRAMCHECK true` [#21266](https://github.com/arendst/Tasmota/issues/21266) +- Berry `gpio.pin_mode` frees PWM on pin - Berry bit-shift operators to `int64` [#22709](https://github.com/arendst/Tasmota/issues/22709) - HASPmota use 'roboto.ttf' for automatic sizing of default font [#22697](https://github.com/arendst/Tasmota/issues/22697) - HASPmota add 'tag' attribute for free-form JSON [#22698](https://github.com/arendst/Tasmota/issues/22698) diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp index 40a55cf83..8149b4bfa 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp @@ -326,15 +326,20 @@ int32_t analogAttach(uint32_t pin, bool output_invert) { // returns ledc chan return chan; } +void analogDetach(uint32_t pin) { + if (pin_to_channel[pin] > 0) { +#if ESP_IDF_VERSION_MAJOR < 5 + ledcDetachPin(pin); +#else + ledcDetach(pin); +#endif + pin_to_channel[pin] = 0; + } +} + void analogDetachAll(void) { for (uint32_t pin = 0; pin < SOC_GPIO_PIN_COUNT; pin++) { - if (pin_to_channel[pin] > 0) { -#if ESP_IDF_VERSION_MAJOR < 5 - ledcDetachPin(pin); -#else - ledcDetach(pin); -#endif - } + analogDetach(pin); } } diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index 99a4b1b30..079cc7a3b 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -56,6 +56,11 @@ uint8_t ledcReadResolution(uint8_t chan); // Returns: hardware channel number, or -1 if it failed int32_t analogAttach(uint32_t pin, bool output_invert = false); // returns the ledc channel, or -1 if failed. This is implicitly called by analogWrite if the channel was not already allocated +// +// analogDetach - detach attached GPIO from a hardware PWM +// +void analogDetach(uint32_t pin); + // // analogDetachAll - detach all attached GPIOs from a hardware PWM // diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino index 97eb571e4..6b0172497 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino @@ -54,6 +54,7 @@ extern "C" { if (pin >= 0) { if (mode > 0) { // standard ESP mode + analogDetach(pin); pinMode(pin, mode); } else { // synthetic mode