Browse Source

Only use slow homing speed where applicable (#15640)

Jacob Jordan 5 years ago
parent
commit
9895e6d766
1 changed files with 44 additions and 20 deletions
  1. 44
    20
      Marlin/src/gcode/calibrate/G28.cpp

+ 44
- 20
Marlin/src/gcode/calibrate/G28.cpp View File

162
 
162
 
163
 #endif // Z_SAFE_HOMING
163
 #endif // Z_SAFE_HOMING
164
 
164
 
165
+#if ENABLED(IMPROVE_HOMING_RELIABILITY)
166
+
167
+  slow_homing_t begin_slow_homing() {
168
+    slow_homing_t slow_homing{0};
169
+    slow_homing.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
170
+                                 planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
171
+    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
172
+    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
173
+    #if HAS_CLASSIC_JERK
174
+      slow_homing.jerk_xy = planner.max_jerk;
175
+      planner.max_jerk.set(0, 0);
176
+    #endif
177
+    planner.reset_acceleration_rates();
178
+    return slow_homing;
179
+  }
180
+
181
+  void end_slow_homing(const slow_homing_t &slow_homing) {
182
+    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
183
+    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
184
+    #if HAS_CLASSIC_JERK
185
+      planner.max_jerk = slow_homing.jerk_xy;
186
+    #endif
187
+    planner.reset_acceleration_rates();
188
+  }
189
+
190
+#endif // IMPROVE_HOMING_RELIABILITY
191
+
165
 /**
192
 /**
166
  * G28: Home all axes according to settings
193
  * G28: Home all axes according to settings
167
  *
194
  *
230
   #endif
257
   #endif
231
 
258
 
232
   #if ENABLED(IMPROVE_HOMING_RELIABILITY)
259
   #if ENABLED(IMPROVE_HOMING_RELIABILITY)
233
-    slow_homing_t slow_homing{0};
234
-    slow_homing.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
235
-                                 planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
236
-    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
237
-    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
238
-    #if HAS_CLASSIC_JERK
239
-      slow_homing.jerk_xy = planner.max_jerk;
240
-      planner.max_jerk.set(0, 0);
241
-    #endif
242
-
243
-    planner.reset_acceleration_rates();
260
+    slow_homing_t slow_homing = begin_slow_homing();
244
   #endif
261
   #endif
245
 
262
 
246
   // Always home with tool 0 active
263
   // Always home with tool 0 active
264
     home_delta();
281
     home_delta();
265
     UNUSED(always_home_all);
282
     UNUSED(always_home_all);
266
 
283
 
284
+    #if ENABLED(IMPROVE_HOMING_RELIABILITY)
285
+      end_slow_homing(slow_homing);
286
+    #endif
287
+
267
   #else // NOT DELTA
288
   #else // NOT DELTA
268
 
289
 
269
     const bool homeX = parser.seen('X'), homeY = parser.seen('Y'), homeZ = parser.seen('Z'),
290
     const bool homeX = parser.seen('X'), homeY = parser.seen('Y'), homeZ = parser.seen('Z'),
348
       if (doY) homeaxis(Y_AXIS);
369
       if (doY) homeaxis(Y_AXIS);
349
     #endif
370
     #endif
350
 
371
 
372
+    #if ENABLED(IMPROVE_HOMING_RELIABILITY)
373
+      end_slow_homing(slow_homing);
374
+    #endif
375
+
351
     // Home Z last if homing towards the bed
376
     // Home Z last if homing towards the bed
352
     #if Z_HOME_DIR < 0
377
     #if Z_HOME_DIR < 0
353
       if (doZ) {
378
       if (doZ) {
381
 
406
 
382
     if (dxc_is_duplicating()) {
407
     if (dxc_is_duplicating()) {
383
 
408
 
409
+      #if ENABLED(IMPROVE_HOMING_RELIABILITY)
410
+        slow_homing = begin_slow_homing();
411
+      #endif
412
+
384
       // Always home the 2nd (right) extruder first
413
       // Always home the 2nd (right) extruder first
385
       active_extruder = 1;
414
       active_extruder = 1;
386
       homeaxis(X_AXIS);
415
       homeaxis(X_AXIS);
401
 
430
 
402
       dual_x_carriage_mode         = IDEX_saved_mode;
431
       dual_x_carriage_mode         = IDEX_saved_mode;
403
       stepper.set_directions();
432
       stepper.set_directions();
433
+
434
+      #if ENABLED(IMPROVE_HOMING_RELIABILITY)
435
+        end_slow_homing(slow_homing);
436
+      #endif
404
     }
437
     }
405
 
438
 
406
   #endif // DUAL_X_CARRIAGE
439
   #endif // DUAL_X_CARRIAGE
433
     tool_change(old_tool_index, NO_FETCH);
466
     tool_change(old_tool_index, NO_FETCH);
434
   #endif
467
   #endif
435
 
468
 
436
-  #if ENABLED(IMPROVE_HOMING_RELIABILITY)
437
-    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
438
-    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
439
-    #if HAS_CLASSIC_JERK
440
-      planner.max_jerk = slow_homing.jerk_xy;
441
-    #endif
442
-    planner.reset_acceleration_rates();
443
-  #endif
444
-
445
   ui.refresh();
469
   ui.refresh();
446
 
470
 
447
   report_current_position();
471
   report_current_position();

Loading…
Cancel
Save