@@ -399,49 +399,50 @@ void GcodeSuite::G28() {
399
399
doU = home_all || homeU, doV = home_all || homeV, doW = home_all || homeW
400
400
);
401
401
402
+ #if !HAS_Y_AXIS
403
+ constexpr bool doY = false ;
404
+ #endif
405
+
402
406
#if HAS_Z_AXIS
407
+
403
408
UNUSED (needZ); UNUSED (homeZZ);
404
- #else
405
- constexpr bool doZ = false ;
406
- #if !HAS_Y_AXIS
407
- constexpr bool doY = false ;
408
- #endif
409
- #endif
410
409
411
- // Z may home first, e.g., when homing away from the bed
412
- TERN_ (HOME_Z_FIRST, if (doZ) homeaxis (Z_AXIS));
410
+ // Z may home first, e.g., when homing away from the bed
411
+ TERN_ (HOME_Z_FIRST, if (doZ) homeaxis (Z_AXIS));
413
412
414
- // 'R' to specify a specific raise. 'R0' indicates no raise, e.g., for recovery.resume
415
- // When 'R0' is used, there should already be adequate clearance, e.g., from homing Z to max.
416
- const bool seenR = parser.seenval (' R' );
413
+ // 'R' to specify a specific raise. 'R0' indicates no raise, e.g., for recovery.resume
414
+ // When 'R0' is used, there should already be adequate clearance, e.g., from homing Z to max.
415
+ const bool seenR = parser.seenval (' R' );
417
416
418
- // Use raise given by 'R' or Z_HOMING_HEIGHT (above the probe trigger point)
419
- float z_homing_height = seenR ? parser.value_linear_units () : Z_HOMING_HEIGHT ;
417
+ // Use raise given by 'R' or Z_CLEARANCE_FOR_HOMING (above the probe trigger point)
418
+ float z_homing_height = seenR ? parser.value_linear_units () : Z_CLEARANCE_FOR_HOMING ;
420
419
421
- // Check for any lateral motion that might require clearance
422
- const bool may_skate = seenR || NUM_AXIS_GANG (doX, || doY, || TERN0 (Z_SAFE_HOMING, doZ), || doI, || doJ, || doK, || doU, || doV, || doW);
420
+ // Check for any lateral motion that might require clearance
421
+ const bool may_skate = seenR || NUM_AXIS_GANG (doX, || doY, || TERN0 (Z_SAFE_HOMING, doZ), || doI, || doJ, || doK, || doU, || doV, || doW);
423
422
424
- if (seenR && z_homing_height == 0 ) {
425
- if (DEBUGGING (LEVELING)) DEBUG_ECHOLNPGM (" R0 = No Z raise" );
426
- }
427
- else {
428
- bool with_probe = ENABLED (HOMING_Z_WITH_PROBE);
429
- // Raise above the current Z (which should be synced in the planner)
430
- // The "height" for Z is a coordinate. But if Z is not trusted/homed make it relative.
431
- if (seenR || !TERN (HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(Z_AXIS)) {
432
- z_homing_height += current_position.z ;
433
- with_probe = false ;
423
+ if (seenR && z_homing_height == 0 ) {
424
+ if (DEBUGGING (LEVELING)) DEBUG_ECHOLNPGM (" R0 = No Z raise" );
434
425
}
426
+ else {
427
+ bool with_probe = ENABLED (HOMING_Z_WITH_PROBE);
428
+ // Raise above the current Z (which should be synced in the planner)
429
+ // The "height" for Z is a coordinate. But if Z is not trusted/homed make it relative.
430
+ if (seenR || !TERN (HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(Z_AXIS)) {
431
+ z_homing_height += current_position.z ;
432
+ with_probe = false ;
433
+ }
435
434
436
- if (may_skate) {
437
- // Apply Z clearance before doing any lateral motion
438
- if (DEBUGGING (LEVELING)) DEBUG_ECHOLNPGM (" Raise Z before homing:" );
439
- do_z_clearance (z_homing_height, with_probe);
435
+ if (may_skate) {
436
+ // Apply Z clearance before doing any lateral motion
437
+ if (DEBUGGING (LEVELING)) DEBUG_ECHOLNPGM (" Raise Z before homing:" );
438
+ do_z_clearance (z_homing_height, with_probe);
439
+ }
440
440
}
441
- }
442
441
443
- // Init BLTouch ahead of any lateral motion, even if not homing with the probe
444
- TERN_ (BLTOUCH, if (may_skate) bltouch.init ());
442
+ // Init BLTouch ahead of any lateral motion, even if not homing with the probe
443
+ TERN_ (BLTOUCH, if (may_skate) bltouch.init ());
444
+
445
+ #endif // HAS_Z_AXIS
445
446
446
447
// Diagonal move first if both are homing
447
448
TERN_ (QUICK_HOME, if (doX && doY) quick_home_xy ());
@@ -497,11 +498,14 @@ void GcodeSuite::G28() {
497
498
TERN_ (IMPROVE_HOMING_RELIABILITY, end_slow_homing (saved_motion_state));
498
499
499
500
#if ENABLED(FOAMCUTTER_XYUV)
500
- // skip homing of unused Z axis for foamcutters
501
+
502
+ // Skip homing of unused Z axis for foamcutters
501
503
if (doZ) set_axis_is_at_home (Z_AXIS);
502
- #else
504
+
505
+ #elif HAS_Z_AXIS
506
+
503
507
// Home Z last if homing towards the bed
504
- #if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST)
508
+ #if DISABLED(HOME_Z_FIRST)
505
509
if (doZ) {
506
510
#if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
507
511
stepper.set_all_z_lock (false );
@@ -513,7 +517,7 @@ void GcodeSuite::G28() {
513
517
#else
514
518
homeaxis (Z_AXIS);
515
519
#endif
516
- probe. move_z_after_homing ();
520
+ do_move_after_z_homing ();
517
521
}
518
522
#endif
519
523
@@ -525,7 +529,8 @@ void GcodeSuite::G28() {
525
529
if (doV) homeaxis (V_AXIS),
526
530
if (doW) homeaxis (W_AXIS)
527
531
);
528
- #endif
532
+
533
+ #endif // HAS_Z_AXIS
529
534
530
535
sync_plan_position ();
531
536
@@ -629,7 +634,7 @@ void GcodeSuite::G28() {
629
634
630
635
report_current_position ();
631
636
632
- if (ENABLED (NANODLP_Z_SYNC) && (doZ || ENABLED (NANODLP_ALL_AXIS) ))
637
+ if (BOTH (NANODLP_Z_SYNC, NANODLP_ALL_AXIS) || TERN0 (HAS_Z_AXIS, doZ ))
633
638
SERIAL_ECHOLNPGM (STR_Z_MOVE_COMP);
634
639
635
640
TERN_ (FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate (old_grblstate));
0 commit comments