mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Fix buzzer permanent sleep change
Fix buzzer permanent sleep change (#11969)
This commit is contained in:
parent
2bc67da369
commit
54a856f2c8
@ -37,6 +37,7 @@ struct BUZZER {
|
|||||||
uint8_t state = 0;
|
uint8_t state = 0;
|
||||||
uint8_t tune_size = 0;
|
uint8_t tune_size = 0;
|
||||||
uint8_t size = 0;
|
uint8_t size = 0;
|
||||||
|
uint8_t sleep; // Current copy of TasmotaGlobal.sleep
|
||||||
} Buzzer;
|
} 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);
|
Buzzer.enable = (Buzzer.count > 0);
|
||||||
if (Buzzer.enable) {
|
if (Buzzer.enable) {
|
||||||
|
Buzzer.sleep = TasmotaGlobal.sleep;
|
||||||
if (Settings.sleep > PWM_MAX_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
|
TasmotaGlobal.sleep = PWM_MAX_SLEEP; // Set a maxumum value of 10 milliseconds to ensure that buzzer periods are a bit more accurate
|
||||||
} else {
|
} else {
|
||||||
TasmotaGlobal.sleep = Settings.sleep; // Or keep the current sleep if it's lower than 10
|
TasmotaGlobal.sleep = Settings.sleep; // Or keep the current sleep if it's lower than 10
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TasmotaGlobal.sleep = Settings.sleep; // Restore original sleep
|
TasmotaGlobal.sleep = Buzzer.sleep; // Restore original sleep
|
||||||
BuzzerSet(0);
|
BuzzerSet(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,6 +167,7 @@ void BuzzerEvery100mSec(void) {
|
|||||||
}
|
}
|
||||||
BuzzerSet(Buzzer.state);
|
BuzzerSet(Buzzer.state);
|
||||||
} else {
|
} else {
|
||||||
|
TasmotaGlobal.sleep = Buzzer.sleep; // Restore original sleep
|
||||||
Buzzer.enable = false;
|
Buzzer.enable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user