Change QPC detection from 4 to 7 power interrupts

Change Quick Power Cycle detection from 4 to 7 power interrupts (#4066)
This commit is contained in:
Theo Arends 2020-05-16 11:22:48 +02:00
parent a9cd30f26e
commit c11952595e
3 changed files with 11 additions and 5 deletions

View File

@ -54,4 +54,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
### Version 8.3.0.1
- Change KNX pow function to approximative pow saving 5k of code space
- Change Mutichannel Gas sensor pow function to approximative pow saving 5k of code space
- Change Quick Power Cycle detection from 4 to 7 power interrupts (#4066)
- Fix default state of ``SetOption73 0`` for button decoupling and send multi-press and hold MQTT messages

View File

@ -2,6 +2,9 @@
### 8.3.0.1 20200514
- Change KNX pow function to approximative pow saving 5k of code space
- Change Mutichannel Gas sensor pow function to approximative pow saving 5k of code space
- Change Quick Power Cycle detection from 4 to 7 power interrupts (#4066)
- Fix default state of ``SetOption73 0`` for button decoupling and send multi-press and hold MQTT messages
## Released

View File

@ -357,9 +357,9 @@ void UpdateQuickPowerCycle(bool update)
#else // ESP32
QPCRead(&pc_register, sizeof(pc_register));
#endif // ESP8266 - ESP32
if (update && ((pc_register & 0xFFFFFFF0) == 0xFFA55AB0)) {
uint32_t counter = ((pc_register & 0xF) << 1) & 0xF;
if (0 == counter) { // 4 power cycles in a row
if (update && ((pc_register & 0xFFFFFF80) == 0xFFA55A80)) {
uint32_t counter = ((pc_register & 0x7F) << 1) & 0x7F;
if (0 == counter) { // 7 power cycles in a row
SettingsErase(3); // Quickly reset all settings including QuickPowerCycle flag
EspRestart(); // And restart
} else {
@ -372,8 +372,8 @@ void UpdateQuickPowerCycle(bool update)
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("QPC: Flag %02X"), counter);
}
}
else if (pc_register != 0xFFA55ABF) {
pc_register = 0xFFA55ABF;
else if (pc_register != 0xFFA55AFF) {
pc_register = 0xFFA55AFF;
#ifdef ESP8266
// Assume flash is default all ones and setting a bit to zero does not need an erase
if (ESP.flashEraseSector(pc_location)) {