Fix ESP32 PWM activity on unconfigured PWM GPIOs (#20732)

This commit is contained in:
Theo Arends 2024-02-17 15:19:12 +01:00
parent 7216db339e
commit 1abaf146b5
6 changed files with 12 additions and 8 deletions

View File

@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
### Added ### Added
- HASPmota `p<x>b<y>.delete` to delete an object (#20735) - HASPmota `p<x>b<y>.delete` to delete an object (#20735)
- LVGL and HASPmota typicons font (#20742) - LVGL and HASPmota typicons font (#20742)
- HASPmota more attributes (#20744)
### Breaking Changed ### Breaking Changed
@ -17,6 +18,7 @@ All notable changes to this project will be documented in this file.
- HASPmota fix and improve demo with pixel-perfect fonts (#20734) - HASPmota fix and improve demo with pixel-perfect fonts (#20734)
### Fixed ### Fixed
- ESP32 PWM activity on unconfigured PWM GPIOs (#20732)
### Removed ### Removed
@ -179,7 +181,6 @@ All notable changes to this project will be documented in this file.
### Added ### Added
- DeepSleep support through TIMERS (#20117) - DeepSleep support through TIMERS (#20117)
- Command ``WebCanvas linear-gradient(#F02 7%,#F93,#FF4,#082,#00F,#708 93%)`` to set GUI canvas - Command ``WebCanvas linear-gradient(#F02 7%,#F93,#FF4,#082,#00F,#708 93%)`` to set GUI canvas
- HASPmota more attributes
### Breaking Changed ### Breaking Changed
- Remove Berry `every_200ms` event which didn't work anyways (#20205) - Remove Berry `every_200ms` event which didn't work anyways (#20205)

View File

@ -128,7 +128,9 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Berry class `int64` made immutable [#20727](https://github.com/arendst/Tasmota/issues/20727) - Berry class `int64` made immutable [#20727](https://github.com/arendst/Tasmota/issues/20727)
- LVGL make lv_touch_3_buttons more responsive [#20728](https://github.com/arendst/Tasmota/issues/20728) - LVGL make lv_touch_3_buttons more responsive [#20728](https://github.com/arendst/Tasmota/issues/20728)
- HASPmota fix and improve demo with pixel-perfect fonts [#20734](https://github.com/arendst/Tasmota/issues/20734) - HASPmota fix and improve demo with pixel-perfect fonts [#20734](https://github.com/arendst/Tasmota/issues/20734)
- HASPmota more attributes [#20744](https://github.com/arendst/Tasmota/issues/20744)
### Fixed ### Fixed
- ESP32 PWM activity on unconfigured PWM GPIOs [#20732](https://github.com/arendst/Tasmota/issues/20732)
### Removed ### Removed

View File

@ -323,7 +323,7 @@ int32_t analogAttach(uint32_t pin, bool output_invert) { // returns ledc chan
return chan; return chan;
} }
void analogDetach(void) { void analogDetachAll(void) {
for (uint32_t pin = 0; pin < SOC_GPIO_PIN_COUNT; pin++) { for (uint32_t pin = 0; pin < SOC_GPIO_PIN_COUNT; pin++) {
if (pin_to_channel[pin] > 0) { if (pin_to_channel[pin] > 0) {
#if ESP_IDF_VERSION_MAJOR < 5 #if ESP_IDF_VERSION_MAJOR < 5

View File

@ -45,6 +45,7 @@
extern "C" uint32_t ledcReadFreq2(uint8_t chan); extern "C" uint32_t ledcReadFreq2(uint8_t chan);
uint8_t ledcReadResolution(uint8_t chan); uint8_t ledcReadResolution(uint8_t chan);
// //
// analogAttach - attach a GPIO to a hardware PWM // analogAttach - attach a GPIO to a hardware PWM
// //
@ -55,7 +56,11 @@ uint8_t ledcReadResolution(uint8_t chan);
// Returns: hardware channel number, or -1 if it failed // 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 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
void analogDetach(void); //
// analogDetachAll - detach all attached GPIOs from a hardware PWM
//
// This solves ghost PWM activity on reconfigured GPIOs after a restart
void analogDetachAll(void);
// change both freq and range // change both freq and range
// `0`: set to global value // `0`: set to global value

View File

@ -183,6 +183,7 @@ void ResetPwm(void)
TasmotaGlobal.pwm_value[i] = 0; TasmotaGlobal.pwm_value[i] = 0;
} }
PwmApplyGPIO(true); PwmApplyGPIO(true);
analogDetachAll(); // Fix PWM activity on unconfigured PWM GPIOs after restart
} }
void CmndPwmfrequency(void) void CmndPwmfrequency(void)

View File

@ -1816,11 +1816,6 @@ void HandleModuleConfiguration(void) {
if (Webserver->hasArg(F("save"))) { if (Webserver->hasArg(F("save"))) {
ModuleSaveSettings(); ModuleSaveSettings();
#ifdef CONFIG_IDF_TARGET_ESP32
analogDetach();
#endif
WebRestart(1); WebRestart(1);
return; return;
} }