Browse Source

Preheat before Power Loss Recovery homing (#20697)

Java 4 years ago
parent
commit
8edcf03715
No account linked to committer's email address
1 changed files with 27 additions and 36 deletions
  1. 27
    36
      Marlin/src/feature/powerloss.cpp

+ 27
- 36
Marlin/src/feature/powerloss.cpp View File

@@ -342,6 +342,30 @@ void PrintJobRecovery::resume() {
342 342
     gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
343 343
   #endif
344 344
 
345
+  #if HAS_HEATED_BED
346
+    const int16_t bt = info.target_temperature_bed;
347
+    if (bt) {
348
+      // Restore the bed temperature
349
+      sprintf_P(cmd, PSTR("M190 S%i"), bt);
350
+      gcode.process_subcommands_now(cmd);
351
+    }
352
+  #endif
353
+
354
+  // Restore all hotend temperatures
355
+  #if HAS_HOTEND
356
+    HOTEND_LOOP() {
357
+      const int16_t et = info.target_temperature[e];
358
+      if (et) {
359
+        #if HAS_MULTI_HOTEND
360
+          sprintf_P(cmd, PSTR("T%i S"), e);
361
+          gcode.process_subcommands_now(cmd);
362
+        #endif
363
+        sprintf_P(cmd, PSTR("M109 S%i"), et);
364
+        gcode.process_subcommands_now(cmd);
365
+      }
366
+    }
367
+  #endif
368
+
345 369
   // Reset E, raise Z, home XY...
346 370
   #if Z_HOME_DIR > 0
347 371
 
@@ -353,20 +377,11 @@ void PrintJobRecovery::resume() {
353 377
 
354 378
   #else // "G92.9 E0 ..."
355 379
 
356
-    // Set Z to 0, raise Z by info.zraise, and Home (XY only for Cartesian)
357
-    // with no raise. (Only do simulated homing in Marlin Dev Mode.)
358
-
359
-    sprintf_P(cmd, PSTR("G92.9 E0 "
360
-        #if ENABLED(BACKUP_POWER_SUPPLY)
361
-          "Z%s"                             // Z was already raised at outage
362
-        #else
363
-          "Z0\nG1Z%s"                       // Set Z=0 and Raise Z now
364
-        #endif
365
-      ),
366
-      dtostrf(info.zraise, 1, 3, str_1)
367
-    );
380
+    // If a Z raise occurred at outage restore Z, otherwise raise Z now
381
+    sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
368 382
     gcode.process_subcommands_now(cmd);
369 383
 
384
+    // Home safely with no Z raise
370 385
     gcode.process_subcommands_now_P(PSTR(
371 386
       "G28R0"                               // No raise during G28
372 387
       #if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
@@ -404,30 +419,6 @@ void PrintJobRecovery::resume() {
404 419
     #endif
405 420
   #endif
406 421
 
407
-  #if HAS_HEATED_BED
408
-    const int16_t bt = info.target_temperature_bed;
409
-    if (bt) {
410
-      // Restore the bed temperature
411
-      sprintf_P(cmd, PSTR("M190 S%i"), bt);
412
-      gcode.process_subcommands_now(cmd);
413
-    }
414
-  #endif
415
-
416
-  // Restore all hotend temperatures
417
-  #if HAS_HOTEND
418
-    HOTEND_LOOP() {
419
-      const int16_t et = info.target_temperature[e];
420
-      if (et) {
421
-        #if HAS_MULTI_HOTEND
422
-          sprintf_P(cmd, PSTR("T%i S"), e);
423
-          gcode.process_subcommands_now(cmd);
424
-        #endif
425
-        sprintf_P(cmd, PSTR("M109 S%i"), et);
426
-        gcode.process_subcommands_now(cmd);
427
-      }
428
-    }
429
-  #endif
430
-
431 422
   // Select the previously active tool (with no_move)
432 423
   #if HAS_MULTI_EXTRUDER
433 424
     sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);

Loading…
Cancel
Save