From 0ea6247fc2dd921be941c14236eb44dbeae7dc8f Mon Sep 17 00:00:00 2001 From: AnHardt Date: Fri, 8 Jul 2016 14:43:01 +0200 Subject: [PATCH] Use logic in Z_SAFE_HOMING Use logic in Z_SAFE_HOMING From ``` if (home_all_axis || homeZ) { if (home_all_axis) { ... home z } else if (homeZ) { // Don't need to Home Z twice home z } } ``` to ``` if (home_all_axis || homeZ) { if (home_all_axis) { ... } home z } ``` --- Marlin/Marlin_main.cpp | 46 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ef01f1226b..e89d702d86 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3015,36 +3015,30 @@ inline void gcode_G28() { */ current_position[X_AXIS] = destination[X_AXIS]; current_position[Y_AXIS] = destination[Y_AXIS]; + } + + // Let's see if X and Y are homed + if (axis_unhomed_error(true, true, false)) return; + + /** + * Make sure the Z probe is within the physical limits + * NOTE: This doesn't necessarily ensure the Z probe is also + * within the bed! + */ + float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS]; + if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) + && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) + && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER) + && cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) { // Home the Z axis HOMEAXIS(Z); } - - else if (homeZ) { // Don't need to Home Z twice - - // Let's see if X and Y are homed - if (axis_unhomed_error(true, true, false)) return; - - /** - * Make sure the Z probe is within the physical limits - * NOTE: This doesn't necessarily ensure the Z probe is also - * within the bed! - */ - float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS]; - if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) - && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) - && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER) - && cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) { - - // Home the Z axis - HOMEAXIS(Z); - } - else { - LCD_MESSAGEPGM(MSG_ZPROBE_OUT); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT); - } - } // !home_all_axes && homeZ + else { + LCD_MESSAGEPGM(MSG_ZPROBE_OUT); + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT); + } #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {