diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 32347113307..470fb46fcac 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1750,7 +1750,6 @@ //#define POWER_LOSS_PIN 44 // Pin to detect power-loss. Set to -1 to disable default pin on boards without module, or comment to use board default. //#define POWER_LOSS_STATE HIGH // State of pin indicating power-loss - #endif //#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor //#define POWER_LOSS_PULLDOWN diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 16a07918f8e..2dacd1c0e0d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -936,17 +936,18 @@ void minkill(const bool steppers_off/*=false*/) { // Reboot the board hal.reboot(); - - #elif defined(PLR_REBOOT_TIMEOUT) - - for (uint16_t i = 0; i < PLR_REBOOT_TIMEOUT; i++) { - hal.watchdog_refresh(); - delay(1000); - } - hal.reboot(); - #else + #if defined(PLR_REBOOT_TIMEOUT) + if (PrintJobRecovery::outage_counter > 0) { + for (uint16_t i = 0; i < PLR_REBOOT_TIMEOUT; i++) { + hal.watchdog_refresh(); + delay(1000); + } + hal.reboot(); + } + #endif + for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle #endif diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 70fac66fce3..def4ea8c132 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -41,6 +41,10 @@ bool PrintJobRecovery::enabled; // Initialized by settings.load() celsius_t PrintJobRecovery::bed_temp_threshold; // Initialized by settings.load() #endif +#if PIN_EXISTS(POWER_LOSS) + uint8_t PrintJobRecovery::outage_counter; // = 0 +#endif + MediaFile PrintJobRecovery::file; job_recovery_info_t PrintJobRecovery::info; const char PrintJobRecovery::filename[5] = "/PLR"; diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 579731ffddc..ac6a61e49d6 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -199,9 +199,9 @@ class PrintJobRecovery { static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); #if PIN_EXISTS(POWER_LOSS) + static uint8_t outage_counter; 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();