From a46d47178c442ad94fc72f7b9320d67439c15dd3 Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Sun, 6 Feb 2022 08:35:18 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20init=20of=20delta=20safe?= =?UTF-8?q?=20height=20(for=20G29,=20G33,=20etc.)=20(#23622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 4 ++++ Marlin/src/module/delta.cpp | 7 +++++++ Marlin/src/module/delta.h | 2 ++ Marlin/src/module/motion.cpp | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e34c0d6c3c10..302e94494e1a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1339,6 +1339,10 @@ void setup() { SETUP_RUN(endstops.init()); // Init endstops and pullups + #if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS + SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops + #endif + SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts! #if HAS_SERVOS diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 2a4efb47da73..cd40175da4d2 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -63,6 +63,13 @@ abc_float_t delta_diagonal_rod_trim; float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height() { + delta_clip_start_height = TERN(HAS_SOFTWARE_ENDSTOPS, + soft_endstop.max.z, + DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) + ) - delta_safe_distance_from_top(); +} + /** * Recalculate factors used for delta kinematics whenever * settings have been changed (e.g., by M665). diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f1e43c7e4c9d..7cd42805c90a 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -82,6 +82,8 @@ void inverse_kinematics(const xyz_pos_t &raw); */ float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height(); + /** * Delta Forward Kinematics * diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 51f0681a150e..4b0c6aba7d35 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -743,7 +743,7 @@ void restore_feedrate_and_scaling() { delta_max_radius_2 = sq(delta_max_radius); break; case Z_AXIS: - delta_clip_start_height = soft_endstop.max[axis] - delta_safe_distance_from_top(); + refresh_delta_clip_start_height(); default: break; }