From 552f7a91d09d53b596abd6612f1f716f6aa75f75 Mon Sep 17 00:00:00 2001
From: InsanityAutomation
 <38436470+InsanityAutomation@users.noreply.github.com>
Date: Mon, 2 Mar 2020 17:07:53 -0500
Subject: [PATCH] Default on/off for Power Loss Recovery (#17051)

---
 Marlin/Configuration_adv.h                | 4 ++++
 Marlin/src/inc/Conditionals_adv.h         | 4 ++++
 Marlin/src/module/configuration_store.cpp | 4 ++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 261ef90ad6..03173f67ef 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1039,9 +1039,13 @@
    * during SD printing. If the recovery file is found at boot time, present
    * an option on the LCD screen to continue the print from the last-known
    * point in the file.
+   *
+   * If the machine reboots when resuming a print you may need to replace or
+   * reformat the SD card. (Bad sectors delay startup triggering the watchdog.)
    */
   //#define POWER_LOSS_RECOVERY
   #if ENABLED(POWER_LOSS_RECOVERY)
+    //#define PLR_ENABLED_DEFAULT  true // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
     //#define BACKUP_POWER_SUPPLY       // Backup power / UPS to move the steppers on power loss
     //#define POWER_LOSS_ZRAISE       2 // (mm) Z axis raise on resume (on power loss with UPS)
     //#define POWER_LOSS_PIN         44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index 155258be43..ea2578c460 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -65,6 +65,10 @@
   #define NUM_Z_STEPPER_DRIVERS 1
 #endif
 
+#ifndef PLR_ENABLED_DEFAULT
+  #define PLR_ENABLED_DEFAULT true
+#endif
+
 #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
   #undef Z_STEPPER_ALIGN_AMP
 #endif
diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp
index 77fc18bb53..2bac5b2b00 100644
--- a/Marlin/src/module/configuration_store.cpp
+++ b/Marlin/src/module/configuration_store.cpp
@@ -930,7 +930,7 @@ void MarlinSettings::postprocess() {
         #if ENABLED(POWER_LOSS_RECOVERY)
           recovery.enabled
         #else
-          true
+          PLR_ENABLED_DEFAULT
         #endif
       ;
       EEPROM_WRITE(recovery_enabled);
@@ -2670,7 +2670,7 @@ void MarlinSettings::reset() {
   //
 
   #if ENABLED(POWER_LOSS_RECOVERY)
-    recovery.enable(true);
+    recovery.enable(PLR_ENABLED_DEFAULT);
   #endif
 
   //
-- 
GitLab