|
28 | 28 | #include "../../module/planner.h" |
29 | 29 | #include "../../module/stepper.h" // for various |
30 | 30 |
|
| 31 | +#if HAS_HOMING_CURRENT |
| 32 | + #include "../../module/motion.h" // for set/restore_homing_current |
| 33 | +#endif |
| 34 | + |
31 | 35 | #if HAS_MULTI_HOTEND |
32 | 36 | #include "../../module/tool_change.h" |
33 | 37 | #endif |
|
77 | 81 | const float minfr = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)), |
78 | 82 | fr_mm_s = HYPOT(minfr, minfr); |
79 | 83 |
|
| 84 | + // Set homing current to X and Y axis if defined |
| 85 | + #if HAS_CURRENT_HOME(X) |
| 86 | + set_homing_current(X_AXIS); |
| 87 | + #endif |
| 88 | + #if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) |
| 89 | + set_homing_current(Y_AXIS); |
| 90 | + #endif |
| 91 | + |
80 | 92 | #if ENABLED(SENSORLESS_HOMING) |
81 | 93 | sensorless_t stealth_states { |
82 | 94 | NUM_AXIS_LIST( |
|
95 | 107 |
|
96 | 108 | current_position.set(0.0, 0.0); |
97 | 109 |
|
| 110 | + #if HAS_CURRENT_HOME(X) |
| 111 | + restore_homing_current(X_AXIS); |
| 112 | + #endif |
| 113 | + #if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) |
| 114 | + restore_homing_current(Y_AXIS); |
| 115 | + #endif |
| 116 | + |
98 | 117 | #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) |
99 | 118 | TERN_(X_SENSORLESS, tmc_disable_stallguard(stepperX, stealth_states.x)); |
100 | 119 | TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, stealth_states.x2)); |
@@ -254,73 +273,6 @@ void GcodeSuite::G28() { |
254 | 273 | // Reset to the XY plane |
255 | 274 | TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); |
256 | 275 |
|
257 | | - #define _OR_HAS_CURR_HOME(N) HAS_CURRENT_HOME(N) || |
258 | | - #if MAIN_AXIS_MAP(_OR_HAS_CURR_HOME) MAP(_OR_HAS_CURR_HOME, X2, Y2, Z2, Z3, Z4) 0 |
259 | | - #define HAS_HOMING_CURRENT 1 |
260 | | - #endif |
261 | | - |
262 | | - #if HAS_HOMING_CURRENT |
263 | | - |
264 | | - #if ENABLED(DEBUG_LEVELING_FEATURE) |
265 | | - auto debug_current = [](FSTR_P const s, const int16_t a, const int16_t b) { |
266 | | - if (DEBUGGING(LEVELING)) { DEBUG_ECHOLN(s, F(" current: "), a, F(" -> "), b); } |
267 | | - }; |
268 | | - #else |
269 | | - #define debug_current(...) |
270 | | - #endif |
271 | | - |
272 | | - #define _SAVE_SET_CURRENT(A) \ |
273 | | - const int16_t saved_current_##A = stepper##A.getMilliamps(); \ |
274 | | - stepper##A.rms_current(A##_CURRENT_HOME); \ |
275 | | - debug_current(F(STR_##A), saved_current_##A, A##_CURRENT_HOME) |
276 | | - |
277 | | - #if HAS_CURRENT_HOME(X) |
278 | | - _SAVE_SET_CURRENT(X); |
279 | | - #endif |
280 | | - #if HAS_CURRENT_HOME(X2) |
281 | | - _SAVE_SET_CURRENT(X2); |
282 | | - #endif |
283 | | - #if HAS_CURRENT_HOME(Y) |
284 | | - _SAVE_SET_CURRENT(Y); |
285 | | - #endif |
286 | | - #if HAS_CURRENT_HOME(Y2) |
287 | | - _SAVE_SET_CURRENT(Y2); |
288 | | - #endif |
289 | | - #if HAS_CURRENT_HOME(Z) |
290 | | - _SAVE_SET_CURRENT(Z); |
291 | | - #endif |
292 | | - #if HAS_CURRENT_HOME(Z2) |
293 | | - _SAVE_SET_CURRENT(Z2); |
294 | | - #endif |
295 | | - #if HAS_CURRENT_HOME(Z3) |
296 | | - _SAVE_SET_CURRENT(Z3); |
297 | | - #endif |
298 | | - #if HAS_CURRENT_HOME(Z4) |
299 | | - _SAVE_SET_CURRENT(Z4); |
300 | | - #endif |
301 | | - #if HAS_CURRENT_HOME(I) |
302 | | - _SAVE_SET_CURRENT(I); |
303 | | - #endif |
304 | | - #if HAS_CURRENT_HOME(J) |
305 | | - _SAVE_SET_CURRENT(J); |
306 | | - #endif |
307 | | - #if HAS_CURRENT_HOME(K) |
308 | | - _SAVE_SET_CURRENT(K); |
309 | | - #endif |
310 | | - #if HAS_CURRENT_HOME(U) |
311 | | - _SAVE_SET_CURRENT(U); |
312 | | - #endif |
313 | | - #if HAS_CURRENT_HOME(V) |
314 | | - _SAVE_SET_CURRENT(V); |
315 | | - #endif |
316 | | - #if HAS_CURRENT_HOME(W) |
317 | | - _SAVE_SET_CURRENT(W); |
318 | | - #endif |
319 | | - #if SENSORLESS_STALLGUARD_DELAY |
320 | | - safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle |
321 | | - #endif |
322 | | - #endif // HAS_HOMING_CURRENT |
323 | | - |
324 | 276 | #if ENABLED(IMPROVE_HOMING_RELIABILITY) |
325 | 277 | motion_state_t saved_motion_state = begin_slow_homing(); |
326 | 278 | #endif |
@@ -572,55 +524,6 @@ void GcodeSuite::G28() { |
572 | 524 | // Clear endstop state for polled stallGuard endstops |
573 | 525 | TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state()); |
574 | 526 |
|
575 | | - #if HAS_HOMING_CURRENT |
576 | | - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current..."); |
577 | | - #if HAS_CURRENT_HOME(X) |
578 | | - stepperX.rms_current(saved_current_X); |
579 | | - #endif |
580 | | - #if HAS_CURRENT_HOME(X2) |
581 | | - stepperX2.rms_current(saved_current_X2); |
582 | | - #endif |
583 | | - #if HAS_CURRENT_HOME(Y) |
584 | | - stepperY.rms_current(saved_current_Y); |
585 | | - #endif |
586 | | - #if HAS_CURRENT_HOME(Y2) |
587 | | - stepperY2.rms_current(saved_current_Y2); |
588 | | - #endif |
589 | | - #if HAS_CURRENT_HOME(Z) |
590 | | - stepperZ.rms_current(saved_current_Z); |
591 | | - #endif |
592 | | - #if HAS_CURRENT_HOME(Z2) |
593 | | - stepperZ2.rms_current(saved_current_Z2); |
594 | | - #endif |
595 | | - #if HAS_CURRENT_HOME(Z3) |
596 | | - stepperZ3.rms_current(saved_current_Z3); |
597 | | - #endif |
598 | | - #if HAS_CURRENT_HOME(Z4) |
599 | | - stepperZ4.rms_current(saved_current_Z4); |
600 | | - #endif |
601 | | - #if HAS_CURRENT_HOME(I) |
602 | | - stepperI.rms_current(saved_current_I); |
603 | | - #endif |
604 | | - #if HAS_CURRENT_HOME(J) |
605 | | - stepperJ.rms_current(saved_current_J); |
606 | | - #endif |
607 | | - #if HAS_CURRENT_HOME(K) |
608 | | - stepperK.rms_current(saved_current_K); |
609 | | - #endif |
610 | | - #if HAS_CURRENT_HOME(U) |
611 | | - stepperU.rms_current(saved_current_U); |
612 | | - #endif |
613 | | - #if HAS_CURRENT_HOME(V) |
614 | | - stepperV.rms_current(saved_current_V); |
615 | | - #endif |
616 | | - #if HAS_CURRENT_HOME(W) |
617 | | - stepperW.rms_current(saved_current_W); |
618 | | - #endif |
619 | | - #if SENSORLESS_STALLGUARD_DELAY |
620 | | - safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle |
621 | | - #endif |
622 | | - #endif // HAS_HOMING_CURRENT |
623 | | - |
624 | 527 | // Move to a height where we can use the full xy-area |
625 | 528 | TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height)); |
626 | 529 |
|
|
0 commit comments