From 54a856f2c8d29a895cc5195c6fc9c6dbe2eb3673 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 4 May 2021 12:31:35 +0200 Subject: [PATCH] Fix buzzer permanent sleep change Fix buzzer permanent sleep change (#11969) --- tasmota/xdrv_24_buzzer.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index a2849065e..46570a41f 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -37,6 +37,7 @@ struct BUZZER { uint8_t state = 0; uint8_t tune_size = 0; uint8_t size = 0; + uint8_t sleep; // Current copy of TasmotaGlobal.sleep } Buzzer; /*********************************************************************************************/ @@ -93,13 +94,14 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32 Buzzer.enable = (Buzzer.count > 0); if (Buzzer.enable) { + Buzzer.sleep = TasmotaGlobal.sleep; if (Settings.sleep > PWM_MAX_SLEEP) { TasmotaGlobal.sleep = PWM_MAX_SLEEP; // Set a maxumum value of 10 milliseconds to ensure that buzzer periods are a bit more accurate } else { TasmotaGlobal.sleep = Settings.sleep; // Or keep the current sleep if it's lower than 10 } } else { - TasmotaGlobal.sleep = Settings.sleep; // Restore original sleep + TasmotaGlobal.sleep = Buzzer.sleep; // Restore original sleep BuzzerSet(0); } } @@ -165,6 +167,7 @@ void BuzzerEvery100mSec(void) { } BuzzerSet(Buzzer.state); } else { + TasmotaGlobal.sleep = Buzzer.sleep; // Restore original sleep Buzzer.enable = false; } }