瀏覽代碼

Clean up and document load/unload/pause/resume

Scott Lahteine 7 年之前
父節點
當前提交
b1cd012aa6

+ 81
- 13
Marlin/src/feature/pause.cpp 查看文件

@@ -83,6 +83,15 @@ float filament_change_unload_length[EXTRUDERS],
83 83
   }
84 84
 #endif
85 85
 
86
+/**
87
+ * Ensure a safe temperature for extrusion
88
+ *
89
+ * - Fail if the TARGET temperature is too low
90
+ * - Display LCD placard with temperature status
91
+ * - Return when heating is done or aborted
92
+ *
93
+ * Returns 'true' if heating was completed, 'false' for abort
94
+ */
86 95
 static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT) {
87 96
 
88 97
   #if ENABLED(PREVENT_COLD_EXTRUSION)
@@ -115,7 +124,19 @@ static void do_pause_e_move(const float &length, const float &fr) {
115 124
   set_current_from_destination();
116 125
 }
117 126
 
118
-bool load_filament(const float &load_length/*=0*/, const float &extrude_length/*=0*/, const int8_t max_beep_count/*=0*/,
127
+/**
128
+ * Load filament into the hotend
129
+ *
130
+ * - Fail if the a safe temperature was not reached
131
+ * - If pausing for confirmation, wait for a click or M108
132
+ * - Show "wait for load" placard
133
+ * - Load and purge filament
134
+ * - Show "Purge more" / "Continue" menu
135
+ * - Return when "Continue" is selected
136
+ *
137
+ * Returns 'true' if load was completed, 'false' for abort
138
+ */
139
+bool load_filament(const float &load_length/*=0*/, const float &purge_length/*=0*/, const int8_t max_beep_count/*=0*/,
119 140
                           const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/,
120 141
                           const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
121 142
 ) {
@@ -158,15 +179,15 @@ bool load_filament(const float &load_length/*=0*/, const float &extrude_length/*
158 179
   }
159 180
 
160 181
   #if ENABLED(ULTIPANEL)
161
-    if (show_lcd) // Show "load" message
182
+    if (show_lcd) // Show "wait for load" message
162 183
       lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, mode);
163 184
   #endif
164 185
 
165 186
   // Load filament
166
-  do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE);
187
+  if (load_length) do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE);
167 188
 
168 189
   do {
169
-    if (extrude_length > 0) {
190
+    if (purge_length > 0) {
170 191
       // "Wait for filament purge"
171 192
       #if ENABLED(ULTIPANEL)
172 193
         if (show_lcd)
@@ -174,10 +195,10 @@ bool load_filament(const float &load_length/*=0*/, const float &extrude_length/*
174 195
       #endif
175 196
 
176 197
       // Extrude filament to get into hotend
177
-      do_pause_e_move(extrude_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
198
+      do_pause_e_move(purge_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
178 199
     }
179 200
 
180
-    // Show "Extrude More" / "Resume" menu and wait for reply
201
+    // Show "Purge More" / "Resume" menu and wait for reply
181 202
     #if ENABLED(ULTIPANEL)
182 203
       if (show_lcd) {
183 204
         KEEPALIVE_STATE(PAUSED_FOR_USER);
@@ -188,7 +209,7 @@ bool load_filament(const float &load_length/*=0*/, const float &extrude_length/*
188 209
       }
189 210
     #endif
190 211
 
191
-    // Keep looping if "Extrude More" was selected
212
+    // Keep looping if "Purge More" was selected
192 213
   } while (
193 214
     #if ENABLED(ULTIPANEL)
194 215
       show_lcd && advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE
@@ -200,6 +221,16 @@ bool load_filament(const float &load_length/*=0*/, const float &extrude_length/*
200 221
   return true;
201 222
 }
202 223
 
224
+/**
225
+ * Unload filament from the hotend
226
+ *
227
+ * - Fail if the a safe temperature was not reached
228
+ * - Show "wait for unload" placard
229
+ * - Retract, pause, then unload filament
230
+ * - Disable E stepper (on most machines)
231
+ *
232
+ * Returns 'true' if unload was completed, 'false' for abort
233
+ */
203 234
 bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
204 235
                             const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
205 236
 ) {
@@ -242,6 +273,19 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
242 273
 
243 274
 // public:
244 275
 
276
+/**
277
+ * Pause procedure
278
+ *
279
+ * - Abort if already paused
280
+ * - Send host action for pause, if configured
281
+ * - Abort if TARGET temperature is too low
282
+ * - Display "wait for start of filament change" (if a length was specified)
283
+ * - Initial retract, if current temperature is hot enough
284
+ * - Park the nozzle at the given position
285
+ * - Call unload_filament (if a length was specified)
286
+ *
287
+ * Returns 'true' if pause was completed, 'false' for abort
288
+ */
245 289
 uint8_t did_pause_print = 0;
246 290
 
247 291
 bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/) {
@@ -277,7 +321,7 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
277 321
   #if ENABLED(SDSUPPORT)
278 322
     if (card.sdprinting) {
279 323
       card.pauseSDPrint();
280
-      ++did_pause_print;
324
+      ++did_pause_print; // Indicate SD pause also
281 325
     }
282 326
   #endif
283 327
   print_job_timer.pause();
@@ -302,6 +346,13 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
302 346
   return true;
303 347
 }
304 348
 
349
+/**
350
+ * - Show "Insert filament and press button to continue"
351
+ * - Wait for a click before returning
352
+ * - Heaters can time out, reheated before accepting a click
353
+ *
354
+ * Used by M125 and M600
355
+ */
305 356
 void wait_for_filament_reload(const int8_t max_beep_count/*=0*/) {
306 357
   bool nozzle_timed_out = false;
307 358
 
@@ -388,12 +439,29 @@ void wait_for_filament_reload(const int8_t max_beep_count/*=0*/) {
388 439
   KEEPALIVE_STATE(IN_HANDLER);
389 440
 }
390 441
 
391
-void resume_print(const float &load_length/*=0*/, const float &extrude_length/*=ADVANCED_PAUSE_EXTRUDE_LENGTH*/, const int8_t max_beep_count/*=0*/) {
392
-  bool nozzle_timed_out = false;
393
-
442
+/**
443
+ * Resume or Start print procedure
444
+ *
445
+ * - Abort if not paused
446
+ * - Reset heater idle timers
447
+ * - Load filament if specified, but only if:
448
+ *   - a nozzle timed out, or
449
+ *   - the nozzle is already heated.
450
+ * - Display "wait for print to resume"
451
+ * - Re-prime the nozzle...
452
+ *   -  FWRETRACT: Recover/prime from the prior G10.
453
+ *   - !FWRETRACT: Retract by resume_position[E], if negative.
454
+ *                 Not sure how this logic comes into use.
455
+ * - Move the nozzle back to resume_position
456
+ * - Sync the planner E to resume_position[E]
457
+ * - Send host action for resume, if configured
458
+ * - Resume the current SD print job, if any
459
+ */
460
+void resume_print(const float &load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_EXTRUDE_LENGTH*/, const int8_t max_beep_count/*=0*/) {
394 461
   if (!did_pause_print) return;
395 462
 
396 463
   // Re-enable the heaters if they timed out
464
+  bool nozzle_timed_out = false;
397 465
   HOTEND_LOOP() {
398 466
     nozzle_timed_out |= thermalManager.is_heater_idle(e);
399 467
     thermalManager.reset_heater_idle_timer(e);
@@ -401,7 +469,7 @@ void resume_print(const float &load_length/*=0*/, const float &extrude_length/*=
401 469
 
402 470
   if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) {
403 471
     // Load the new filament
404
-    load_filament(load_length, extrude_length, max_beep_count, true, nozzle_timed_out);
472
+    load_filament(load_length, purge_length, max_beep_count, true, nozzle_timed_out);
405 473
   }
406 474
 
407 475
   #if ENABLED(ULTIPANEL)
@@ -415,7 +483,7 @@ void resume_print(const float &load_length/*=0*/, const float &extrude_length/*=
415 483
     if (fwretract.retracted[active_extruder])
416 484
       do_pause_e_move(-fwretract.retract_length, fwretract.retract_feedrate_mm_s);
417 485
   #else
418
-    // If resume_position negative
486
+    // If resume_position is negative
419 487
     if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE);
420 488
   #endif
421 489
 

+ 3
- 3
Marlin/src/gcode/feature/pause/M125.cpp 查看文件

@@ -50,11 +50,11 @@
50 50
  */
51 51
 void GcodeSuite::M125() {
52 52
   // Initial retract before move to filament change position
53
-  const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
53
+  const float retract = -FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
54 54
     #ifdef PAUSE_PARK_RETRACT_LENGTH
55
-      - (PAUSE_PARK_RETRACT_LENGTH)
55
+      + (PAUSE_PARK_RETRACT_LENGTH)
56 56
     #endif
57
-  ;
57
+  );
58 58
 
59 59
   point_t park_point = NOZZLE_PARK_POINT;
60 60
 

+ 1
- 1
Marlin/src/gcode/feature/pause/M600.cpp 查看文件

@@ -56,7 +56,7 @@ void GcodeSuite::M600() {
56 56
 
57 57
   if (get_target_extruder_from_command()) return;
58 58
 
59
-  // Show initial message
59
+  // Show initial "wait for start" message
60 60
   #if ENABLED(ULTIPANEL)
61 61
     lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT, target_extruder);
62 62
   #endif

+ 2
- 2
Marlin/src/gcode/feature/pause/M701_M702.cpp 查看文件

@@ -59,7 +59,7 @@ void GcodeSuite::M701() {
59 59
   const float load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) :
60 60
                                                     filament_change_load_length[target_extruder]);
61 61
 
62
-  // Show initial message
62
+  // Show initial "wait for load" message
63 63
   #if ENABLED(ULTIPANEL)
64 64
     lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, target_extruder);
65 65
   #endif
@@ -112,7 +112,7 @@ void GcodeSuite::M702() {
112 112
   // Z axis lift
113 113
   if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
114 114
 
115
-  // Show initial message
115
+  // Show initial "wait for unload" message
116 116
   #if ENABLED(ULTIPANEL)
117 117
     lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
118 118
   #endif

Loading…
取消
儲存