Browse Source

🧑‍💻 Handle PLR in manage_media

Scott Lahteine 3 years ago
parent
commit
fd082df077

+ 8
- 3
Marlin/src/feature/powerloss.cpp View File

108
  *
108
  *
109
  * If a saved state exists send 'M1000 S' to initiate job recovery.
109
  * If a saved state exists send 'M1000 S' to initiate job recovery.
110
  */
110
  */
111
-void PrintJobRecovery::check() {
111
+bool PrintJobRecovery::check() {
112
   //if (!card.isMounted()) card.mount();
112
   //if (!card.isMounted()) card.mount();
113
+  bool success = false;
113
   if (card.isMounted()) {
114
   if (card.isMounted()) {
114
     load();
115
     load();
115
-    if (!valid()) return cancel();
116
-    queue.inject(F("M1000S"));
116
+    success = valid();
117
+    if (!success)
118
+      cancel();
119
+    else
120
+      queue.inject(F("M1000S"));
117
   }
121
   }
122
+  return success;
118
 }
123
 }
119
 
124
 
120
 /**
125
 /**

+ 2
- 2
Marlin/src/feature/powerloss.h View File

176
     static void open(const bool read) { card.openJobRecoveryFile(read); }
176
     static void open(const bool read) { card.openJobRecoveryFile(read); }
177
     static void close() { file.close(); }
177
     static void close() { file.close(); }
178
 
178
 
179
-    static void check();
179
+    static bool check();
180
     static void resume();
180
     static void resume();
181
     static void purge();
181
     static void purge();
182
 
182
 
183
-    static void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
183
+    static void cancel() { purge(); }
184
 
184
 
185
     static void load();
185
     static void load();
186
     static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);
186
     static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);

+ 1
- 1
Marlin/src/gcode/feature/powerloss/M413.cpp View File

49
     if (parser.seen_test('P')) recovery.purge();
49
     if (parser.seen_test('P')) recovery.purge();
50
     if (parser.seen_test('D')) recovery.debug(F("M413"));
50
     if (parser.seen_test('D')) recovery.debug(F("M413"));
51
     if (parser.seen_test('O')) recovery._outage(true);
51
     if (parser.seen_test('O')) recovery._outage(true);
52
-    if (parser.seen_test('C')) recovery.check();
52
+    if (parser.seen_test('C')) (void)recovery.check();
53
     if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n"));
53
     if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n"));
54
     if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n"));
54
     if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n"));
55
   #endif
55
   #endif

+ 7
- 5
Marlin/src/sd/cardreader.cpp View File

514
 
514
 
515
   DEBUG_ECHOLNPGM("First mount.");
515
   DEBUG_ECHOLNPGM("First mount.");
516
 
516
 
517
-  #if ENABLED(POWER_LOSS_RECOVERY)
518
-    recovery.check();               // Check for PLR file. (If not there then call autofile_begin)
519
-  #elif DISABLED(NO_SD_AUTOSTART)
520
-    autofile_begin();               // Look for auto0.g on the next loop
521
-  #endif
517
+  bool do_auto = true; UNUSED(do_auto);
518
+
519
+  // Check for PLR file.
520
+  TERN_(POWER_LOSS_RECOVERY, if (recovery.check()) do_auto = false);
521
+
522
+  // Look for auto0.g on the next idle()
523
+  IF_DISABLED(NO_SD_AUTOSTART, if (do_auto) autofile_begin());
522
 }
524
 }
523
 
525
 
524
 /**
526
 /**

Loading…
Cancel
Save