@@ -242,12 +242,16 @@ void GcodeSuite::G28() {
242242 SET_SOFT_ENDSTOP_LOOSE (false ); // Reset a leftover 'loose' motion state
243243
244244 // Disable the leveling matrix before homing
245- #if HAS_LEVELING
246- const bool leveling_restore_state = parser.boolval (' L' , TERN (RESTORE_LEVELING_AFTER_G28, planner.leveling_active , ENABLED (ENABLE_LEVELING_AFTER_G28)));
247- IF_ENABLED (PROBE_MANUALLY, g29_in_progress = false ); // Cancel the active G29 session
248- set_bed_leveling_enabled (false );
245+ #if CAN_SET_LEVELING_AFTER_G28
246+ const bool leveling_restore_state = parser.boolval (' L' , TERN1 (RESTORE_LEVELING_AFTER_G28, planner.leveling_active ));
249247 #endif
250248
249+ // Cancel any prior G29 session
250+ TERN_ (PROBE_MANUALLY, g29_in_progress = false );
251+
252+ // Disable leveling before homing
253+ TERN_ (HAS_LEVELING, set_bed_leveling_enabled (false ));
254+
251255 // Reset to the XY plane
252256 TERN_ (CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
253257
@@ -353,13 +357,14 @@ void GcodeSuite::G28() {
353357
354358 const float z_homing_height = parser.seenval (' R' ) ? parser.value_linear_units () : Z_HOMING_HEIGHT;
355359
356- if (z_homing_height && (0 LINEAR_AXIS_GANG (|| doX, || doY, || TERN0 (Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
360+ if (z_homing_height && (LINEAR_AXIS_GANG (doX, || doY, || TERN0 (Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
357361 // Raise Z before homing any other axes and z is not already high enough (never lower z)
358362 if (DEBUGGING (LEVELING)) DEBUG_ECHOLNPAIR (" Raise Z (before homing) by " , z_homing_height);
359363 do_z_clearance (z_homing_height);
360364 TERN_ (BLTOUCH, bltouch.init ());
361365 }
362366
367+ // Diagonal move first if both are homing
363368 TERN_ (QUICK_HOME, if (doX && doY) quick_home_xy ());
364369
365370 // Home Y (before X)
@@ -464,12 +469,10 @@ void GcodeSuite::G28() {
464469 // Clear endstop state for polled stallGuard endstops
465470 TERN_ (SPI_ENDSTOPS, endstops.clear_endstop_state ());
466471
467- #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
468- // move to a height where we can use the full xy-area
469- do_blocking_move_to_z (delta_clip_start_height);
470- #endif
472+ // Move to a height where we can use the full xy-area
473+ TERN_ (DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z (delta_clip_start_height));
471474
472- TERN_ (HAS_LEVELING, set_bed_leveling_enabled (leveling_restore_state));
475+ TERN_ (CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled ( ));
473476
474477 restore_feedrate_and_scaling ();
475478
0 commit comments