Debounce for Power-Loss pin
This commit is contained in:
parent
9f7177c67d
commit
1292ff76b3
|
@ -186,8 +186,14 @@ class PrintJobRecovery {
|
||||||
|
|
||||||
#if PIN_EXISTS(POWER_LOSS)
|
#if PIN_EXISTS(POWER_LOSS)
|
||||||
static inline void outage() {
|
static inline void outage() {
|
||||||
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE)
|
static constexpr uint8_t OUTAGE_THRESHOLD = 3;
|
||||||
_outage();
|
static uint8_t outage_counter = 0;
|
||||||
|
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
|
||||||
|
outage_counter++;
|
||||||
|
if (outage_counter >= OUTAGE_THRESHOLD) _outage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
outage_counter = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue