Add UNKNOWN_Z_NO_RAISE option
With this option enabled, Z won't ever be raised until after `G28` has been completed, and it won't raise if Z becomes unknown. This is good for machines whose beds fall when Z is powered off.
This commit is contained in:
		@@ -804,6 +804,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
//#define NO_MOTION_BEFORE_HOMING  // Inhibit movement until all axes have been homed
 | 
					//#define NO_MOTION_BEFORE_HOMING  // Inhibit movement until all axes have been homed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//#define UNKNOWN_Z_NO_RAISE // Don't raise Z (lower the bed) if Z is "unknown." For beds that fall when Z is powered off.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//#define Z_HOMING_HEIGHT 4  // (in mm) Minimal z height before homing (G28) for Z clearance above the bed, clamps, ...
 | 
					//#define Z_HOMING_HEIGHT 4  // (in mm) Minimal z height before homing (G28) for Z clearance above the bed, clamps, ...
 | 
				
			||||||
                             // Be sure you have this distance over your Z_MAX_POS in case.
 | 
					                             // Be sure you have this distance over your Z_MAX_POS in case.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -221,9 +221,15 @@ void GcodeSuite::G28(const bool always_home_all) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (home_all || homeX || homeY) {
 | 
					    #if ENABLED(UNKNOWN_Z_NO_RAISE)
 | 
				
			||||||
 | 
					      const float z_homing_height = axis_known_position[Z_AXIS] ? Z_HOMING_HEIGHT : 0;
 | 
				
			||||||
 | 
					    #else
 | 
				
			||||||
 | 
					      constexpr float z_homing_height = Z_HOMING_HEIGHT;
 | 
				
			||||||
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (z_homing_height && (home_all || homeX || homeY)) {
 | 
				
			||||||
      // Raise Z before homing any other axes and z is not already high enough (never lower z)
 | 
					      // Raise Z before homing any other axes and z is not already high enough (never lower z)
 | 
				
			||||||
      destination[Z_AXIS] = Z_HOMING_HEIGHT;
 | 
					      destination[Z_AXIS] = z_homing_height;
 | 
				
			||||||
      if (destination[Z_AXIS] > current_position[Z_AXIS]) {
 | 
					      if (destination[Z_AXIS] > current_position[Z_AXIS]) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #if ENABLED(DEBUG_LEVELING_FEATURE)
 | 
					        #if ENABLED(DEBUG_LEVELING_FEATURE)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -378,13 +378,21 @@ bool set_probe_deployed(const bool deploy) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Make room for probe to deploy (or stow)
 | 
					  // Make room for probe to deploy (or stow)
 | 
				
			||||||
  // Fix-mounted probe should only raise for deploy
 | 
					  // Fix-mounted probe should only raise for deploy
 | 
				
			||||||
  if (
 | 
					 | 
				
			||||||
  #if ENABLED(FIX_MOUNTED_PROBE)
 | 
					  #if ENABLED(FIX_MOUNTED_PROBE)
 | 
				
			||||||
      deploy
 | 
					    const bool deploy_stow_condition = deploy;
 | 
				
			||||||
  #else
 | 
					  #else
 | 
				
			||||||
      true
 | 
					    constexpr bool deploy_stow_condition = true;
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  ) do_probe_raise(max(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
 | 
					
 | 
				
			||||||
 | 
					  // For beds that fall when Z is powered off only raise for trusted Z
 | 
				
			||||||
 | 
					  #if ENABLED(UNKNOWN_Z_NO_RAISE)
 | 
				
			||||||
 | 
					    const bool unknown_condition = axis_known_position[Z_AXIS];
 | 
				
			||||||
 | 
					  #else
 | 
				
			||||||
 | 
					    constexpr float unknown_condition = true;
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (deploy_stow_condition && unknown_condition)
 | 
				
			||||||
 | 
					    do_probe_raise(max(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
 | 
					  #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
 | 
				
			||||||
    #if ENABLED(Z_PROBE_SLED)
 | 
					    #if ENABLED(Z_PROBE_SLED)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user