Quellcode durchsuchen

🧑‍💻 Handle PLR in manage_media

Scott Lahteine vor 2 Jahren
Ursprung
Commit
fd082df077

+ 8
- 3
Marlin/src/feature/powerloss.cpp Datei anzeigen

@@ -108,13 +108,18 @@ void PrintJobRecovery::changed() {
108 108
  *
109 109
  * If a saved state exists send 'M1000 S' to initiate job recovery.
110 110
  */
111
-void PrintJobRecovery::check() {
111
+bool PrintJobRecovery::check() {
112 112
   //if (!card.isMounted()) card.mount();
113
+  bool success = false;
113 114
   if (card.isMounted()) {
114 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 Datei anzeigen

@@ -176,11 +176,11 @@ class PrintJobRecovery {
176 176
     static void open(const bool read) { card.openJobRecoveryFile(read); }
177 177
     static void close() { file.close(); }
178 178
 
179
-    static void check();
179
+    static bool check();
180 180
     static void resume();
181 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 185
     static void load();
186 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 Datei anzeigen

@@ -49,7 +49,7 @@ void GcodeSuite::M413() {
49 49
     if (parser.seen_test('P')) recovery.purge();
50 50
     if (parser.seen_test('D')) recovery.debug(F("M413"));
51 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 53
     if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n"));
54 54
     if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n"));
55 55
   #endif

+ 7
- 5
Marlin/src/sd/cardreader.cpp Datei anzeigen

@@ -514,11 +514,13 @@ void CardReader::manage_media() {
514 514
 
515 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
 /**

Laden…
Abbrechen
Speichern