Fix ESP32 piezo ceramic buzzer

Fix ESP32 piezo ceramic buzzer doesn't buzz (#20118)
This commit is contained in:
Theo Arends 2023-12-19 15:38:12 +01:00
parent 87b5886ea7
commit 9e2ae391fc
3 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- Matter Contact sensor was not triggering any update (#20232)
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability (#12221)
- ESP32 piezo ceramic buzzer doesn't buzz (#20118)
### Removed

View File

@ -130,6 +130,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Fixed
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability [#12221](https://github.com/arendst/Tasmota/issues/12221)
- ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118)
- Matter Contact sensor was not triggering any update [#20232](https://github.com/arendst/Tasmota/issues/20232)
### Removed

View File

@ -52,7 +52,14 @@ void BuzzerSet(uint32_t state) {
if (last_state != state) {
// Set 50% duty cycle for frequency output
// Set 0% (or 100% for inverted PWM) duty cycle which turns off frequency output either way
#ifdef ESP8266
analogWrite(Pin(GPIO_BUZZER), (state) ? Settings->pwm_range / 2 : 0); // set duty cycle for frequency output
#else
int32_t pin = Pin(GPIO_BUZZER);
if (analogAttach(pin, Buzzer.inverted) >= 0) {
analogWritePhase(pin, (state) ? Settings->pwm_range / 2 : 0, 0);
}
#endif
last_state = state;
}
} else {