浏览代码

Misc Power Loss cleanup

Scott Lahteine 4 年前
父节点
当前提交
9f7177c67d
共有 2 个文件被更改,包括 17 次插入15 次删除
  1. 12
    15
      Marlin/src/feature/powerloss.cpp
  2. 5
    0
      Marlin/src/feature/powerloss.h

+ 12
- 15
Marlin/src/feature/powerloss.cpp 查看文件

@@ -66,9 +66,6 @@ PrintJobRecovery recovery;
66 66
 #ifndef POWER_LOSS_PURGE_LEN
67 67
   #define POWER_LOSS_PURGE_LEN 0
68 68
 #endif
69
-#ifndef POWER_LOSS_ZRAISE
70
-  #define POWER_LOSS_ZRAISE 2     // Move on loss with backup power, or on resume without it
71
-#endif
72 69
 
73 70
 #if DISABLED(BACKUP_POWER_SUPPLY)
74 71
   #undef POWER_LOSS_RETRACT_LEN   // No retract at outage without backup power
@@ -256,7 +253,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
256 253
           // Raise the Z axis now
257 254
           if (zraise) {
258 255
             char cmd[20], str_1[16];
259
-            sprintf_P(cmd, PSTR("G0 Z%s"), dtostrf(zraise, 1, 3, str_1));
256
+            sprintf_P(cmd, PSTR("G0Z%s"), dtostrf(zraise, 1, 3, str_1));
260 257
             gcode.process_subcommands_now(cmd);
261 258
           }
262 259
         #else
@@ -348,7 +345,7 @@ void PrintJobRecovery::resume() {
348 345
     const celsius_t bt = info.target_temperature_bed;
349 346
     if (bt) {
350 347
       // Restore the bed temperature
351
-      sprintf_P(cmd, PSTR("M190 S%i"), bt);
348
+      sprintf_P(cmd, PSTR("M190S%i"), bt);
352 349
       gcode.process_subcommands_now(cmd);
353 350
     }
354 351
   #endif
@@ -359,10 +356,10 @@ void PrintJobRecovery::resume() {
359 356
       const celsius_t et = info.target_temperature[e];
360 357
       if (et) {
361 358
         #if HAS_MULTI_HOTEND
362
-          sprintf_P(cmd, PSTR("T%i S"), e);
359
+          sprintf_P(cmd, PSTR("T%iS"), e);
363 360
           gcode.process_subcommands_now(cmd);
364 361
         #endif
365
-        sprintf_P(cmd, PSTR("M109 S%i"), et);
362
+        sprintf_P(cmd, PSTR("M109S%i"), et);
366 363
         gcode.process_subcommands_now(cmd);
367 364
       }
368 365
     }
@@ -370,7 +367,7 @@ void PrintJobRecovery::resume() {
370 367
 
371 368
   //
372 369
   // Home the axes that can safely be homed, and
373
-  // establish the current position as best we can
370
+  // establish the current position as best we can.
374 371
   //
375 372
   #if Z_HOME_DIR > 0
376 373
 
@@ -380,7 +377,7 @@ void PrintJobRecovery::resume() {
380 377
       "G28R0"                               // Home all axes (no raise)
381 378
     ));
382 379
 
383
-  #else // "G92.9 E0 ..."
380
+  #else
384 381
 
385 382
     // If a Z raise occurred at outage restore Z, otherwise raise Z now
386 383
     sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
@@ -475,7 +472,7 @@ void PrintJobRecovery::resume() {
475 472
 
476 473
   // Un-retract if there was a retract at outage
477 474
   #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
478
-    gcode.process_subcommands_now_P(PSTR("G1 E" STRINGIFY(POWER_LOSS_RETRACT_LEN) " F3000"));
475
+    gcode.process_subcommands_now_P(PSTR("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000"));
479 476
   #endif
480 477
 
481 478
   // Additional purge on resume if configured
@@ -488,8 +485,8 @@ void PrintJobRecovery::resume() {
488 485
     gcode.process_subcommands_now_P(PSTR("G12"));
489 486
   #endif
490 487
 
491
-  // Move back to the saved XY
492
-  sprintf_P(cmd, PSTR("G1 X%s Y%s F3000"),
488
+  // Move back over to the saved XY
489
+  sprintf_P(cmd, PSTR("G1X%sY%sF3000"),
493 490
     dtostrf(info.current_position.x, 1, 3, str_1),
494 491
     dtostrf(info.current_position.y, 1, 3, str_2)
495 492
   );
@@ -506,11 +503,11 @@ void PrintJobRecovery::resume() {
506 503
   gcode.process_subcommands_now(cmd);
507 504
 
508 505
   // Restore the feedrate
509
-  sprintf_P(cmd, PSTR("G1 F%d"), info.feedrate);
506
+  sprintf_P(cmd, PSTR("G1F%d"), info.feedrate);
510 507
   gcode.process_subcommands_now(cmd);
511 508
 
512 509
   // Restore E position with G92.9
513
-  sprintf_P(cmd, PSTR("G92.9 E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
510
+  sprintf_P(cmd, PSTR("G92.9E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
514 511
   gcode.process_subcommands_now(cmd);
515 512
 
516 513
   TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat);
@@ -535,7 +532,7 @@ void PrintJobRecovery::resume() {
535 532
   char *fn = info.sd_filename;
536 533
   sprintf_P(cmd, M23_STR, fn);
537 534
   gcode.process_subcommands_now(cmd);
538
-  sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
535
+  sprintf_P(cmd, PSTR("M24S%ldT%ld"), resume_sdpos, info.print_job_elapsed);
539 536
   gcode.process_subcommands_now(cmd);
540 537
 
541 538
   TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags);

+ 5
- 0
Marlin/src/feature/powerloss.h 查看文件

@@ -42,6 +42,10 @@
42 42
   #define POWER_LOSS_STATE HIGH
43 43
 #endif
44 44
 
45
+#ifndef POWER_LOSS_ZRAISE
46
+  #define POWER_LOSS_ZRAISE 2
47
+#endif
48
+
45 49
 //#define DEBUG_POWER_LOSS_RECOVERY
46 50
 //#define SAVE_EACH_CMD_MODE
47 51
 //#define SAVE_INFO_INTERVAL_MS 0
@@ -52,6 +56,7 @@ typedef struct {
52 56
   // Machine state
53 57
   xyze_pos_t current_position;
54 58
   uint16_t feedrate;
59
+
55 60
   float zraise;
56 61
 
57 62
   // Repeat information

正在加载...
取消
保存