From 6f8b8c394db5f5037e85d3b16dc63bfeb11f6891 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Wed, 31 Jul 2019 21:50:23 -0400 Subject: [PATCH] Homing backoff per-axis / delta Z (#14789) --- Marlin/src/gcode/calibrate/G28.cpp | 9 --------- Marlin/src/module/motion.cpp | 18 ++++++++++++++++++ Marlin/src/module/motion.h | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index f39d3bae1..039bd3d1a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -391,15 +391,6 @@ void GcodeSuite::G28(const bool always_home_all) { #endif // DUAL_X_CARRIAGE - #ifdef HOMING_BACKOFF_MM - endstops.enable(false); - constexpr float endstop_backoff[XYZ] = HOMING_BACKOFF_MM; - const float backoff_x = doX ? ABS(endstop_backoff[X_AXIS]) * (X_HOME_DIR) : 0, - backoff_y = doY ? ABS(endstop_backoff[Y_AXIS]) * (Y_HOME_DIR) : 0, - backoff_z = doZ ? ABS(endstop_backoff[Z_AXIS]) * (Z_HOME_DIR) : 0; - if (backoff_z) do_blocking_move_to_z(current_position[Z_AXIS] - backoff_z); - if (backoff_x || backoff_y) do_blocking_move_to_xy(current_position[X_AXIS] - backoff_x, current_position[Y_AXIS] - backoff_y); - #endif endstops.not_homing(); #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 69b5905b2..fd67b887e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -423,6 +423,9 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f void do_blocking_move_to_x(const float &rx, const float &fr_mm_s/*=0.0*/) { do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s); } +void do_blocking_move_to_y(const float &ry, const float &fr_mm_s/*=0.0*/) { + do_blocking_move_to(current_position[Y_AXIS], ry, current_position[Z_AXIS], fr_mm_s); +} void do_blocking_move_to_z(const float &rz, const float &fr_mm_s/*=0.0*/) { do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], rz, fr_mm_s); } @@ -1599,6 +1602,21 @@ void homeaxis(const AxisEnum axis) { if (axis == Z_AXIS && STOW_PROBE()) return; #endif + #ifdef HOMING_BACKOFF_MM + constexpr float endstop_backoff[XYZ] = HOMING_BACKOFF_MM; + const AxisEnum backoff_mm = endstop_backoff[ + #if ENABLED(DELTA) + Z_AXIS + #else + axis + #endif + ]; + if (backoff_mm) { + current_position[axis] -= ABS(backoff_mm) * axis_home_dir; + line_to_current_position(); + } + #endif + // Clear retracted status if homing the Z axis #if ENABLED(FWRETRACT) if (axis == Z_AXIS) fwretract.current_hop = 0.0; diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 1d2ccf110..7c637f9cb 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -185,6 +185,7 @@ void prepare_move_to_destination(); */ void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s=0); void do_blocking_move_to_x(const float &rx, const float &fr_mm_s=0); +void do_blocking_move_to_y(const float &ry, const float &fr_mm_s=0); void do_blocking_move_to_z(const float &rz, const float &fr_mm_s=0); void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s=0);