From dbe2b6f7b0067f7398b85ffb57b78cd4ecb857ea Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Mar 2018 21:26:43 -0500 Subject: [PATCH] Do moves towards endstops differently in do_homing_move --- Marlin/src/module/motion.cpp | 56 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 414c65e3a..ad76683f5 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -998,19 +998,29 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa } #endif - #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) - const bool deploy_bltouch = (axis == Z_AXIS && distance < 0); - if (deploy_bltouch) set_bltouch_deployed(true); - #endif + // Only do some things when moving towards an endstop + const int8_t axis_home_dir = + #if ENABLED(DUAL_X_CARRIAGE) + (axis == X_AXIS) ? x_home_dir(active_extruder) : + #endif + home_dir(axis); + const bool is_home_dir = (axis_home_dir > 0) == (distance > 0); - #if QUIET_PROBING - if (axis == Z_AXIS) probing_pause(true); - #endif + if (is_home_dir) { + #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) + const bool deploy_bltouch = (axis == Z_AXIS && is_home_dir); + if (deploy_bltouch) set_bltouch_deployed(true); + #endif - // Disable stealthChop if used. Enable diag1 pin on driver. - #if ENABLED(SENSORLESS_HOMING) - sensorless_homing_per_axis(axis); - #endif + #if QUIET_PROBING + if (axis == Z_AXIS) probing_pause(true); + #endif + + // Disable stealthChop if used. Enable diag1 pin on driver. + #if ENABLED(SENSORLESS_HOMING) + sensorless_homing_per_axis(axis); + #endif + } // Tell the planner the axis is at 0 current_position[axis] = 0; @@ -1028,20 +1038,22 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa stepper.synchronize(); - #if QUIET_PROBING - if (axis == Z_AXIS) probing_pause(false); - #endif + if (is_home_dir) { + #if QUIET_PROBING + if (axis == Z_AXIS) probing_pause(false); + #endif - #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) - if (deploy_bltouch) set_bltouch_deployed(false); - #endif + #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) + if (deploy_bltouch) set_bltouch_deployed(false); + #endif - endstops.hit_on_purpose(); + endstops.hit_on_purpose(); - // Re-enable stealthChop if used. Disable diag1 pin on driver. - #if ENABLED(SENSORLESS_HOMING) - sensorless_homing_per_axis(axis, false); - #endif + // Re-enable stealthChop if used. Disable diag1 pin on driver. + #if ENABLED(SENSORLESS_HOMING) + sensorless_homing_per_axis(axis, false); + #endif + } #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {