🎨 Adjust some conditionals
This commit is contained in:
		@@ -24,7 +24,7 @@
 | 
			
		||||
#include "../../inc/MarlinConfigPre.h"
 | 
			
		||||
 | 
			
		||||
#if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
 | 
			
		||||
  #define G28_L0_ENSURES_LEVELING_OFF 1
 | 
			
		||||
  #define CAN_SET_LEVELING_AFTER_G28 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ENABLED(PROBE_MANUALLY)
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ typedef struct {
 | 
			
		||||
    uint8_t fan_speed[FAN_COUNT];
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(HAS_LEVELING)
 | 
			
		||||
  #if HAS_LEVELING
 | 
			
		||||
    float fade;
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
@@ -120,7 +120,7 @@ typedef struct {
 | 
			
		||||
    bool raised:1;                // Raised before saved
 | 
			
		||||
    bool dryrun:1;                // M111 S8
 | 
			
		||||
    bool allow_cold_extrusion:1;  // M302 P1
 | 
			
		||||
    #if ENABLED(HAS_LEVELING)
 | 
			
		||||
    #if HAS_LEVELING
 | 
			
		||||
      bool leveling:1;            // M420 S
 | 
			
		||||
    #endif
 | 
			
		||||
    #if DISABLED(NO_VOLUMETRICS)
 | 
			
		||||
 
 | 
			
		||||
@@ -246,7 +246,7 @@ G29_TYPE GcodeSuite::G29() {
 | 
			
		||||
 | 
			
		||||
  // Send 'N' to force homing before G29 (internal only)
 | 
			
		||||
  if (parser.seen_test('N'))
 | 
			
		||||
    process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
 | 
			
		||||
    process_subcommands_now_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
 | 
			
		||||
 | 
			
		||||
  // Don't allow auto-leveling without homing first
 | 
			
		||||
  if (homing_needed_error()) G29_RETURN(false);
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ void GcodeSuite::G29() {
 | 
			
		||||
      mbl.reset();
 | 
			
		||||
      mbl_probe_index = 0;
 | 
			
		||||
      if (!ui.wait_for_move) {
 | 
			
		||||
        queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
 | 
			
		||||
        queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      state = MeshNext;
 | 
			
		||||
 
 | 
			
		||||
@@ -242,12 +242,16 @@ void GcodeSuite::G28() {
 | 
			
		||||
  SET_SOFT_ENDSTOP_LOOSE(false);  // Reset a leftover 'loose' motion state
 | 
			
		||||
 | 
			
		||||
  // Disable the leveling matrix before homing
 | 
			
		||||
  #if HAS_LEVELING
 | 
			
		||||
    const bool leveling_restore_state = parser.boolval('L', TERN(RESTORE_LEVELING_AFTER_G28, planner.leveling_active, ENABLED(ENABLE_LEVELING_AFTER_G28)));
 | 
			
		||||
    IF_ENABLED(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session
 | 
			
		||||
    set_bed_leveling_enabled(false);
 | 
			
		||||
  #if CAN_SET_LEVELING_AFTER_G28
 | 
			
		||||
    const bool leveling_restore_state = parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active));
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  // Cancel any prior G29 session
 | 
			
		||||
  TERN_(PROBE_MANUALLY, g29_in_progress = false);
 | 
			
		||||
 | 
			
		||||
  // Disable leveling before homing
 | 
			
		||||
  TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
 | 
			
		||||
 | 
			
		||||
  // Reset to the XY plane
 | 
			
		||||
  TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
 | 
			
		||||
 | 
			
		||||
@@ -353,13 +357,14 @@ void GcodeSuite::G28() {
 | 
			
		||||
 | 
			
		||||
    const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT;
 | 
			
		||||
 | 
			
		||||
    if (z_homing_height && (0 LINEAR_AXIS_GANG(|| doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
 | 
			
		||||
    if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
 | 
			
		||||
      // Raise Z before homing any other axes and z is not already high enough (never lower z)
 | 
			
		||||
      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
 | 
			
		||||
      do_z_clearance(z_homing_height);
 | 
			
		||||
      TERN_(BLTOUCH, bltouch.init());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Diagonal move first if both are homing
 | 
			
		||||
    TERN_(QUICK_HOME, if (doX && doY) quick_home_xy());
 | 
			
		||||
 | 
			
		||||
    // Home Y (before X)
 | 
			
		||||
@@ -464,12 +469,10 @@ void GcodeSuite::G28() {
 | 
			
		||||
  // Clear endstop state for polled stallGuard endstops
 | 
			
		||||
  TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
 | 
			
		||||
 | 
			
		||||
  #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
 | 
			
		||||
    // move to a height where we can use the full xy-area
 | 
			
		||||
    do_blocking_move_to_z(delta_clip_start_height);
 | 
			
		||||
  #endif
 | 
			
		||||
  // Move to a height where we can use the full xy-area
 | 
			
		||||
  TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
 | 
			
		||||
 | 
			
		||||
  TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));
 | 
			
		||||
  TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());
 | 
			
		||||
 | 
			
		||||
  restore_feedrate_and_scaling();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -392,7 +392,7 @@ public:
 | 
			
		||||
  static void process_subcommands_now(char * gcode);
 | 
			
		||||
 | 
			
		||||
  static inline void home_all_axes(const bool keep_leveling=false) {
 | 
			
		||||
    process_subcommands_now_P(keep_leveling ? G28_STR : TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
 | 
			
		||||
    process_subcommands_now_P(keep_leveling ? G28_STR : TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)
 | 
			
		||||
 
 | 
			
		||||
@@ -1027,6 +1027,10 @@
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if DISABLED(DELTA)
 | 
			
		||||
  #undef DELTA_HOME_TO_SAFE_ZONE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// This flag indicates some kind of jerk storage is needed
 | 
			
		||||
#if EITHER(CLASSIC_JERK, IS_KINEMATIC)
 | 
			
		||||
  #define HAS_CLASSIC_JERK 1
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@
 | 
			
		||||
// Global storage
 | 
			
		||||
float z_offset_backup, calculated_z_offset, z_offset_ref;
 | 
			
		||||
 | 
			
		||||
#if ENABLED(HAS_LEVELING)
 | 
			
		||||
#if HAS_LEVELING
 | 
			
		||||
  bool leveling_was_active;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ void goto_tramming_wizard() {
 | 
			
		||||
 | 
			
		||||
  // Inject G28, wait for homing to complete,
 | 
			
		||||
  set_all_unhomed();
 | 
			
		||||
  queue.inject_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
 | 
			
		||||
  queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
 | 
			
		||||
 | 
			
		||||
  ui.goto_screen([]{
 | 
			
		||||
    _lcd_draw_homing();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user