瀏覽代碼

Preheat before Power Loss Recovery homing (#20697)

Java 4 年之前
父節點
當前提交
8edcf03715
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 27 行新增36 行删除
  1. 27
    36
      Marlin/src/feature/powerloss.cpp

+ 27
- 36
Marlin/src/feature/powerloss.cpp 查看文件

342
     gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
342
     gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
343
   #endif
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
   // Reset E, raise Z, home XY...
369
   // Reset E, raise Z, home XY...
346
   #if Z_HOME_DIR > 0
370
   #if Z_HOME_DIR > 0
347
 
371
 
353
 
377
 
354
   #else // "G92.9 E0 ..."
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
     gcode.process_subcommands_now(cmd);
382
     gcode.process_subcommands_now(cmd);
369
 
383
 
384
+    // Home safely with no Z raise
370
     gcode.process_subcommands_now_P(PSTR(
385
     gcode.process_subcommands_now_P(PSTR(
371
       "G28R0"                               // No raise during G28
386
       "G28R0"                               // No raise during G28
372
       #if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
387
       #if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
404
     #endif
419
     #endif
405
   #endif
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
   // Select the previously active tool (with no_move)
422
   // Select the previously active tool (with no_move)
432
   #if HAS_MULTI_EXTRUDER
423
   #if HAS_MULTI_EXTRUDER
433
     sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
424
     sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);

Loading…
取消
儲存