浏览代码

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
 #ifndef POWER_LOSS_PURGE_LEN
66
 #ifndef POWER_LOSS_PURGE_LEN
67
   #define POWER_LOSS_PURGE_LEN 0
67
   #define POWER_LOSS_PURGE_LEN 0
68
 #endif
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
 #if DISABLED(BACKUP_POWER_SUPPLY)
70
 #if DISABLED(BACKUP_POWER_SUPPLY)
74
   #undef POWER_LOSS_RETRACT_LEN   // No retract at outage without backup power
71
   #undef POWER_LOSS_RETRACT_LEN   // No retract at outage without backup power
256
           // Raise the Z axis now
253
           // Raise the Z axis now
257
           if (zraise) {
254
           if (zraise) {
258
             char cmd[20], str_1[16];
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
             gcode.process_subcommands_now(cmd);
257
             gcode.process_subcommands_now(cmd);
261
           }
258
           }
262
         #else
259
         #else
348
     const celsius_t bt = info.target_temperature_bed;
345
     const celsius_t bt = info.target_temperature_bed;
349
     if (bt) {
346
     if (bt) {
350
       // Restore the bed temperature
347
       // Restore the bed temperature
351
-      sprintf_P(cmd, PSTR("M190 S%i"), bt);
348
+      sprintf_P(cmd, PSTR("M190S%i"), bt);
352
       gcode.process_subcommands_now(cmd);
349
       gcode.process_subcommands_now(cmd);
353
     }
350
     }
354
   #endif
351
   #endif
359
       const celsius_t et = info.target_temperature[e];
356
       const celsius_t et = info.target_temperature[e];
360
       if (et) {
357
       if (et) {
361
         #if HAS_MULTI_HOTEND
358
         #if HAS_MULTI_HOTEND
362
-          sprintf_P(cmd, PSTR("T%i S"), e);
359
+          sprintf_P(cmd, PSTR("T%iS"), e);
363
           gcode.process_subcommands_now(cmd);
360
           gcode.process_subcommands_now(cmd);
364
         #endif
361
         #endif
365
-        sprintf_P(cmd, PSTR("M109 S%i"), et);
362
+        sprintf_P(cmd, PSTR("M109S%i"), et);
366
         gcode.process_subcommands_now(cmd);
363
         gcode.process_subcommands_now(cmd);
367
       }
364
       }
368
     }
365
     }
370
 
367
 
371
   //
368
   //
372
   // Home the axes that can safely be homed, and
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
   #if Z_HOME_DIR > 0
372
   #if Z_HOME_DIR > 0
376
 
373
 
380
       "G28R0"                               // Home all axes (no raise)
377
       "G28R0"                               // Home all axes (no raise)
381
     ));
378
     ));
382
 
379
 
383
-  #else // "G92.9 E0 ..."
380
+  #else
384
 
381
 
385
     // If a Z raise occurred at outage restore Z, otherwise raise Z now
382
     // If a Z raise occurred at outage restore Z, otherwise raise Z now
386
     sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
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
 
472
 
476
   // Un-retract if there was a retract at outage
473
   // Un-retract if there was a retract at outage
477
   #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
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
   #endif
476
   #endif
480
 
477
 
481
   // Additional purge on resume if configured
478
   // Additional purge on resume if configured
488
     gcode.process_subcommands_now_P(PSTR("G12"));
485
     gcode.process_subcommands_now_P(PSTR("G12"));
489
   #endif
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
     dtostrf(info.current_position.x, 1, 3, str_1),
490
     dtostrf(info.current_position.x, 1, 3, str_1),
494
     dtostrf(info.current_position.y, 1, 3, str_2)
491
     dtostrf(info.current_position.y, 1, 3, str_2)
495
   );
492
   );
506
   gcode.process_subcommands_now(cmd);
503
   gcode.process_subcommands_now(cmd);
507
 
504
 
508
   // Restore the feedrate
505
   // Restore the feedrate
509
-  sprintf_P(cmd, PSTR("G1 F%d"), info.feedrate);
506
+  sprintf_P(cmd, PSTR("G1F%d"), info.feedrate);
510
   gcode.process_subcommands_now(cmd);
507
   gcode.process_subcommands_now(cmd);
511
 
508
 
512
   // Restore E position with G92.9
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
   gcode.process_subcommands_now(cmd);
511
   gcode.process_subcommands_now(cmd);
515
 
512
 
516
   TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat);
513
   TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat);
535
   char *fn = info.sd_filename;
532
   char *fn = info.sd_filename;
536
   sprintf_P(cmd, M23_STR, fn);
533
   sprintf_P(cmd, M23_STR, fn);
537
   gcode.process_subcommands_now(cmd);
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
   gcode.process_subcommands_now(cmd);
536
   gcode.process_subcommands_now(cmd);
540
 
537
 
541
   TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags);
538
   TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags);

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

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

正在加载...
取消
保存