mirror of https://github.com/arendst/Tasmota.git
Fix PWM channels after restart (#20732)
This commit is contained in:
parent
d3093a13c2
commit
0faef8e4dd
|
@ -323,6 +323,14 @@ int32_t analogAttach(uint32_t pin, bool output_invert) { // returns ledc chan
|
|||
return chan;
|
||||
}
|
||||
|
||||
void analogDetach(void) {
|
||||
for (uint32_t pin = 0; pin < SOC_GPIO_PIN_COUNT; pin++) {
|
||||
if (pin_to_channel[pin] > 0) {
|
||||
ledcDetachPin(pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" uint32_t ledcReadFreq2(uint8_t chan) {
|
||||
// extern "C" uint32_t __wrap_ledcReadFreq(uint8_t chan) {
|
||||
if (chan > MAX_PWMS) {
|
||||
|
|
|
@ -55,6 +55,8 @@ 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
|
||||
|
||||
void analogDetach(void);
|
||||
|
||||
// change both freq and range
|
||||
// `0`: set to global value
|
||||
// `-1`: keep unchanged
|
||||
|
|
|
@ -1816,6 +1816,11 @@ void HandleModuleConfiguration(void) {
|
|||
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
ModuleSaveSettings();
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
analogDetach();
|
||||
#endif
|
||||
|
||||
WebRestart(1);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue