Browse Source

Pause and PLR refinements

- Move `pause_print` argument `unload_length` after `show_lcd` so it's next to `DXC_ARGS`.
- Tweak the position and conditions of PLR save in `resume_print`.
- Add `Nozzle::park_mode_0_height` accessor to get the raised Z height.
- Remove extraneous `recovery.save` from `dwin.cpp`.
- Move PLR `info.volumetric...` to `flag`.
- Remove some G-code spaces in PLR code
- Document `pause.h` function declarations.
Scott Lahteine 3 years ago
parent
commit
dfc906930c

+ 14
- 11
Marlin/src/feature/pause.cpp View File

@@ -316,7 +316,7 @@ bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/,
316 316
   );
317 317
 
318 318
   #if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
319
-    constexpr float mix_multiplier = 1.0;
319
+    constexpr float mix_multiplier = 1.0f;
320 320
   #endif
321 321
 
322 322
   if (!ensure_safe_temperature(false, mode)) {
@@ -371,7 +371,7 @@ bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/,
371 371
  */
372 372
 uint8_t did_pause_print = 0;
373 373
 
374
-bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float_t unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
374
+bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool show_lcd/*=false*/, const_float_t unload_length/*=0*/ DXC_ARGS) {
375 375
   DEBUG_SECTION(pp, "pause_print", true);
376 376
   DEBUG_ECHOLNPAIR("... park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", show_lcd DXC_SAY);
377 377
 
@@ -394,7 +394,8 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float
394 394
 
395 395
   // Pause the print job and timer
396 396
   #if ENABLED(SDSUPPORT)
397
-    if (IS_SD_PRINTING()) {
397
+    const bool was_sd_printing = IS_SD_PRINTING();
398
+    if (was_sd_printing) {
398 399
       card.pauseSDPrint();
399 400
       ++did_pause_print; // Indicate SD pause also
400 401
     }
@@ -418,7 +419,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float
418 419
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
419 420
   }
420 421
 
421
-  // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
422
+  // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
422 423
   if (!axes_should_home())
423 424
     nozzle.park(0, park_point);
424 425
 
@@ -630,9 +631,6 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
630 631
   // Set extruder to saved position
631 632
   planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
632 633
 
633
-  // Write PLR now to update the z axis value
634
-  TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
635
-
636 634
   ui.pause_show_message(PAUSE_MESSAGE_STATUS);
637 635
 
638 636
   #ifdef ACTION_ON_RESUMED
@@ -645,8 +643,16 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
645 643
 
646 644
   TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR));
647 645
 
646
+  // Resume the print job timer if it was running
647
+  if (print_job_timer.isPaused()) print_job_timer.start();
648
+
648 649
   #if ENABLED(SDSUPPORT)
649
-    if (did_pause_print) { card.startFileprint(); --did_pause_print; }
650
+    if (did_pause_print) {
651
+      --did_pause_print;
652
+      card.startFileprint();
653
+      // Write PLR now to update the z axis value
654
+      TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
655
+    }
650 656
   #endif
651 657
 
652 658
   #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN
@@ -655,9 +661,6 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
655 661
 
656 662
   TERN_(HAS_FILAMENT_SENSOR, runout.reset());
657 663
 
658
-  // Resume the print job timer if it was running
659
-  if (print_job_timer.isPaused()) print_job_timer.start();
660
-
661 664
   TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
662 665
   TERN_(HAS_LCD_MENU, ui.return_to_status());
663 666
 }

+ 36
- 8
Marlin/src/feature/pause.h View File

@@ -85,19 +85,47 @@ extern uint8_t did_pause_print;
85 85
   #define DXC_SAY
86 86
 #endif
87 87
 
88
-bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float_t unload_length=0, const bool show_lcd=false DXC_PARAMS);
88
+// Pause the print. If unload_length is set, do a Filament Unload
89
+bool pause_print(
90
+  const_float_t   retract,                                    // (mm) Retraction length
91
+  const xyz_pos_t &park_point,                                // Parking XY Position and Z Raise
92
+  const bool      show_lcd=false,                             // Set LCD status messages?
93
+  const_float_t   unload_length=0                             // (mm) Filament Change Unload Length - 0 to skip
94
+  DXC_PARAMS                                                  // Dual-X-Carriage extruder index
95
+);
89 96
 
90
-void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS);
97
+void wait_for_confirmation(
98
+  const bool      is_reload=false,                            // Reload Filament? (otherwise Resume Print)
99
+  const int8_t    max_beep_count=0                            // Beep alert for attention
100
+  DXC_PARAMS                                                  // Dual-X-Carriage extruder index
101
+);
91 102
 
92
-void resume_print(const_float_t slow_load_length=0, const_float_t fast_load_length=0, const_float_t extrude_length=ADVANCED_PAUSE_PURGE_LENGTH,
93
-                    const int8_t max_beep_count=0, const celsius_t targetTemp=0 DXC_PARAMS);
103
+void resume_print(
104
+  const_float_t   slow_load_length=0,                         // (mm) Slow Load Length for finishing move
105
+  const_float_t   fast_load_length=0,                         // (mm) Fast Load Length for initial move
106
+  const_float_t   extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length
107
+  const int8_t    max_beep_count=0,                           // Beep alert for attention
108
+  const celsius_t targetTemp=0                                // (°C) A target temperature for the hotend
109
+  DXC_PARAMS                                                  // Dual-X-Carriage extruder index
110
+);
94 111
 
95
-bool load_filament(const_float_t slow_load_length=0, const_float_t fast_load_length=0, const_float_t extrude_length=0, const int8_t max_beep_count=0,
96
-                    const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
112
+bool load_filament(
113
+  const_float_t   slow_load_length=0,                         // (mm) Slow Load Length for finishing move
114
+  const_float_t   fast_load_length=0,                         // (mm) Fast Load Length for initial move
115
+  const_float_t   extrude_length=0,                           // (mm) Purge length
116
+  const int8_t    max_beep_count=0,                           // Beep alert for attention
117
+  const bool      show_lcd=false,                             // Set LCD status messages?
118
+  const bool      pause_for_user=false,                       // Pause for user before returning?
119
+  const PauseMode mode=PAUSE_MODE_PAUSE_PRINT                 // Pause Mode to apply
120
+  DXC_PARAMS                                                  // Dual-X-Carriage extruder index
121
+);
97 122
 
98
-bool unload_filament(const_float_t unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT
123
+bool unload_filament(
124
+  const_float_t   unload_length,                              // (mm) Filament Unload Length - 0 to skip
125
+  const bool      show_lcd=false,                             // Set LCD status messages?
126
+  const PauseMode mode=PAUSE_MODE_PAUSE_PRINT                 // Pause Mode to apply
99 127
   #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
100
-    , const_float_t mix_multiplier=1.0
128
+    , const_float_t mix_multiplier=1.0f                       // Extrusion multiplier (for a Mixing Extruder)
101 129
   #endif
102 130
 );
103 131
 

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

@@ -149,6 +149,8 @@ void PrintJobRecovery::prepare() {
149 149
  */
150 150
 void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/) {
151 151
 
152
+  // We don't check IS_SD_PRINTING here so a save may occur during a pause
153
+
152 154
   #if SAVE_INFO_INTERVAL_MS > 0
153 155
     static millis_t next_save_ms; // = 0
154 156
     millis_t ms = millis();
@@ -192,7 +194,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
192 194
     #endif
193 195
 
194 196
     #if DISABLED(NO_VOLUMETRICS)
195
-      info.volumetric_enabled = parser.volumetric_enabled;
197
+      info.flag.volumetric_enabled = parser.volumetric_enabled;
196 198
       #if HAS_MULTI_EXTRUDER
197 199
         for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
198 200
       #else
@@ -366,13 +368,16 @@ void PrintJobRecovery::resume() {
366 368
     }
367 369
   #endif
368 370
 
369
-  // Reset E, raise Z, home XY...
371
+  //
372
+  // Home the axes that can safely be homed, and
373
+  // establish the current position as best we can
374
+  //
370 375
   #if Z_HOME_DIR > 0
371 376
 
372
-    // If Z homing goes to max, just reset E and home all
377
+    // If Z homing goes to max...
373 378
     gcode.process_subcommands_now_P(PSTR(
374
-      "G92.9 E0\n"
375
-      "G28R0"
379
+      "G92.9 E0\n"                          // Reset E to 0
380
+      "G28R0"                               // Home all axes (no raise)
376 381
     ));
377 382
 
378 383
   #else // "G92.9 E0 ..."
@@ -391,19 +396,20 @@ void PrintJobRecovery::resume() {
391 396
 
392 397
   #endif
393 398
 
394
-  #ifdef POWER_LOSS_ZHOME_POS
395
-    // If defined move to a safe Z homing position that avoids the print
399
+  #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS)
400
+    // Move to a safe XY position where Z can home while avoiding the print.
401
+    // If Z_SAFE_HOMING is enabled, its position must also be outside the print area!
396 402
     constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS;
397
-    sprintf_P(cmd, PSTR("G1 X%s Y%s F1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
403
+    sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2));
398 404
     gcode.process_subcommands_now(cmd);
399 405
   #endif
400 406
 
401
-  // Ensure that all axes are marked as homed
407
+  // Mark all axes as having been homed (no effect on current_position)
402 408
   set_all_homed();
403 409
 
404 410
   #if ENABLED(POWER_LOSS_RECOVER_ZHOME)
405
-    // Now move to ZsavedPos + POWER_LOSS_ZRAISE
406
-    sprintf_P(cmd, PSTR("G1 F500 Z%s"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
411
+    // Z was homed. Now move Z back up to the saved Z height, plus the POWER_LOSS_ZRAISE.
412
+    sprintf_P(cmd, PSTR("G1Z%sF500"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
407 413
     gcode.process_subcommands_now(cmd);
408 414
   #endif
409 415
 
@@ -411,16 +417,16 @@ void PrintJobRecovery::resume() {
411 417
   #if DISABLED(NO_VOLUMETRICS)
412 418
     #if HAS_MULTI_EXTRUDER
413 419
       for (int8_t e = 0; e < EXTRUDERS; e++) {
414
-        sprintf_P(cmd, PSTR("M200 T%i D%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1));
420
+        sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1));
415 421
         gcode.process_subcommands_now(cmd);
416 422
       }
417
-      if (!info.volumetric_enabled) {
418
-        sprintf_P(cmd, PSTR("M200 T%i D0"), info.active_extruder);
423
+      if (!info.flag.volumetric_enabled) {
424
+        sprintf_P(cmd, PSTR("M200T%iD0"), info.active_extruder);
419 425
         gcode.process_subcommands_now(cmd);
420 426
       }
421 427
     #else
422
-      if (info.volumetric_enabled) {
423
-        sprintf_P(cmd, PSTR("M200 D%s"), dtostrf(info.filament_size[0], 1, 3, str_1));
428
+      if (info.flag.volumetric_enabled) {
429
+        sprintf_P(cmd, PSTR("M200D%s"), dtostrf(info.filament_size[0], 1, 3, str_1));
424 430
         gcode.process_subcommands_now(cmd);
425 431
       }
426 432
     #endif
@@ -437,13 +443,13 @@ void PrintJobRecovery::resume() {
437 443
     FANS_LOOP(i) {
438 444
       const int f = info.fan_speed[i];
439 445
       if (f) {
440
-        sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
446
+        sprintf_P(cmd, PSTR("M106P%iS%i"), i, f);
441 447
         gcode.process_subcommands_now(cmd);
442 448
       }
443 449
     }
444 450
   #endif
445 451
 
446
-  // Restore retract and hop state
452
+  // Restore retract and hop state from an active `G10` command
447 453
   #if ENABLED(FWRETRACT)
448 454
     LOOP_L_N(e, EXTRUDERS) {
449 455
       if (info.retract[e] != 0.0) {
@@ -458,7 +464,7 @@ void PrintJobRecovery::resume() {
458 464
     // Restore leveling state before 'G92 Z' to ensure
459 465
     // the Z stepper count corresponds to the native Z.
460 466
     if (info.fade || info.flag.leveling) {
461
-      sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1));
467
+      sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1));
462 468
       gcode.process_subcommands_now(cmd);
463 469
     }
464 470
   #endif
@@ -468,11 +474,11 @@ void PrintJobRecovery::resume() {
468 474
   #endif
469 475
 
470 476
   // Un-retract if there was a retract at outage
471
-  #if POWER_LOSS_RETRACT_LEN
477
+  #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
472 478
     gcode.process_subcommands_now_P(PSTR("G1 E" STRINGIFY(POWER_LOSS_RETRACT_LEN) " F3000"));
473 479
   #endif
474 480
 
475
-  // Additional purge if configured
481
+  // Additional purge on resume if configured
476 482
   #if POWER_LOSS_PURGE_LEN
477 483
     sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
478 484
     gcode.process_subcommands_now(cmd);

+ 4
- 2
Marlin/src/feature/powerloss.h View File

@@ -70,7 +70,6 @@ typedef struct {
70 70
   #endif
71 71
 
72 72
   #if DISABLED(NO_VOLUMETRICS)
73
-    bool volumetric_enabled;
74 73
     float filament_size[EXTRUDERS];
75 74
   #endif
76 75
 
@@ -116,7 +115,10 @@ typedef struct {
116 115
     bool dryrun:1;                // M111 S8
117 116
     bool allow_cold_extrusion:1;  // M302 P1
118 117
     #if ENABLED(HAS_LEVELING)
119
-      bool leveling:1;
118
+      bool leveling:1;            // M420 S
119
+    #endif
120
+    #if DISABLED(NO_VOLUMETRICS)
121
+      bool volumetric_enabled:1;  // M200 S D
120 122
     #endif
121 123
   } flag;
122 124
 

+ 1
- 1
Marlin/src/gcode/feature/pause/M125.cpp View File

@@ -80,7 +80,7 @@ void GcodeSuite::M125() {
80 80
 
81 81
   TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
82 82
 
83
-  if (pause_print(retract, park_point, 0, show_lcd)) {
83
+  if (pause_print(retract, park_point, show_lcd, 0)) {
84 84
     if (ENABLED(EXTENSIBLE_UI) || !sd_printing || show_lcd) {
85 85
       wait_for_confirmation(false, 0);
86 86
       resume_print(0, 0, -retract, 0);

+ 1
- 1
Marlin/src/gcode/feature/pause/M600.cpp View File

@@ -149,7 +149,7 @@ void GcodeSuite::M600() {
149 149
     #endif
150 150
   );
151 151
 
152
-  if (pause_print(retract, park_point, unload_length, true DXC_PASS)) {
152
+  if (pause_print(retract, park_point, true, unload_length DXC_PASS)) {
153 153
     #if ENABLED(MMU2_MENUS)
154 154
       mmu2_M600();
155 155
       resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS);

+ 0
- 3
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

@@ -2298,9 +2298,6 @@ void HMI_PauseOrStop() {
2298 2298
       if (HMI_flag.select_flag) {
2299 2299
         HMI_flag.pause_action = true;
2300 2300
         ICON_Continue();
2301
-        #if ENABLED(POWER_LOSS_RECOVERY)
2302
-          if (recovery.enabled) recovery.save(true);
2303
-        #endif
2304 2301
         queue.inject_P(PSTR("M25"));
2305 2302
       }
2306 2303
       else {

+ 15
- 9
Marlin/src/libs/nozzle.cpp View File

@@ -225,6 +225,18 @@ Nozzle nozzle;
225 225
 
226 226
 #if ENABLED(NOZZLE_PARK_FEATURE)
227 227
 
228
+  float Nozzle::park_mode_0_height(const_float_t park_z) {
229
+    // Apply a minimum raise, if specified. Use park.z as a minimum height instead.
230
+    return _MAX(park_z,                       // Minimum height over 0 based on input
231
+      _MIN(Z_MAX_POS,                         // Maximum height is fixed
232
+        #ifdef NOZZLE_PARK_Z_RAISE_MIN
233
+          NOZZLE_PARK_Z_RAISE_MIN +           // Minimum raise...
234
+        #endif
235
+        current_position.z                    // ...over current position
236
+      )
237
+    );
238
+  }
239
+
228 240
   void Nozzle::park(const uint8_t z_action, const xyz_pos_t &park/*=NOZZLE_PARK_POINT*/) {
229 241
     constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE;
230 242
 
@@ -237,15 +249,9 @@ Nozzle nozzle;
237 249
         do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z);
238 250
         break;
239 251
 
240
-      default: {
241
-        // Apply a minimum raise, overriding G27 Z
242
-        const float min_raised_z =_MIN(Z_MAX_POS, current_position.z
243
-          #ifdef NOZZLE_PARK_Z_RAISE_MIN
244
-            + NOZZLE_PARK_Z_RAISE_MIN
245
-          #endif
246
-        );
247
-        do_blocking_move_to_z(_MAX(park.z, min_raised_z), fr_z);
248
-      } break;
252
+      default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height
253
+        do_blocking_move_to_z(park_mode_0_height(park.z), fr_z);
254
+        break;
249 255
     }
250 256
 
251 257
     do_blocking_move_to_xy(

+ 1
- 0
Marlin/src/libs/nozzle.h View File

@@ -83,6 +83,7 @@ class Nozzle {
83 83
 
84 84
   #if ENABLED(NOZZLE_PARK_FEATURE)
85 85
 
86
+    static float park_mode_0_height(const_float_t park_z) _Os;
86 87
     static void park(const uint8_t z_action, const xyz_pos_t &park=NOZZLE_PARK_POINT) _Os;
87 88
 
88 89
   #endif

Loading…
Cancel
Save