From 9eb6df17a7d1ac22bc1a35714e0c05c4448ce3a8 Mon Sep 17 00:00:00 2001 From: Lukas Obermann Date: Wed, 15 Oct 2014 16:59:41 +0200 Subject: [PATCH] Consider negative Z Offsets when auto bed leveling is active --- Marlin/Marlin_main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 809da798e5..1219ad743d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3946,7 +3946,14 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - if (target[Z_AXIS] < min_pos[Z_AXIS]) target[Z_AXIS] = min_pos[Z_AXIS]; + + float negative_z_offset = 0; + #ifdef ENABLE_AUTO_BED_LEVELING + if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; + if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; + #endif + + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } if (max_software_endstops) {