mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-03-06 01:54:53 -07:00
Merge d198f1fdc5 into a6ebfe14cc
This commit is contained in:
commit
bcce87cadb
2 changed files with 19 additions and 8 deletions
|
|
@ -1881,6 +1881,8 @@
|
|||
//#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail
|
||||
#endif
|
||||
|
||||
//#define POWER_LOSS_TIMEOUT 10 // (ms) Power loss duration to raise event, three idle() calls otherwise
|
||||
|
||||
// Enable if Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
|
||||
//#define POWER_LOSS_RECOVER_ZHOME
|
||||
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
||||
|
|
|
|||
|
|
@ -216,14 +216,23 @@ class PrintJobRecovery {
|
|||
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
static void outage() {
|
||||
static constexpr uint8_t OUTAGE_THRESHOLD = 3;
|
||||
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;
|
||||
#if defined(POWER_LOSS_TIMEOUT)
|
||||
static unsigned long last_power_on;
|
||||
if ( enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
|
||||
if (millis() - last_power_on >= POWER_LOSS_TIMEOUT) _outage();
|
||||
}
|
||||
else
|
||||
last_power_on = millis();
|
||||
#else
|
||||
static constexpr uint8_t OUTAGE_THRESHOLD = 3;
|
||||
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…
Add table
Add a link
Reference in a new issue