From da88b00585855be8a2a1da51ea2868e64538246b Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Sat, 25 Jun 2016 21:58:02 +0200 Subject: [PATCH] MBL: Add support for max z endstop See https://github.com/MarlinFirmware/Marlin/issues/4088 --- Marlin/Marlin_main.cpp | 18 +++++++++++++++--- Marlin/ultralcd.cpp | 6 +++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 934ae9c461..28a6a9c15d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3072,7 +3072,11 @@ inline void gcode_G28() { #if ENABLED(MESH_BED_LEVELING) if (mbl.has_mesh()) { if (home_all_axis || (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && homeZ)) { - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + #if Z_HOME_DIR > 0 + + Z_MAX_POS + #endif + ; SYNC_PLAN_POSITION_KINEMATIC(); mbl.set_active(true); #if ENABLED(MESH_G28_REST_ORIGIN) @@ -3084,7 +3088,11 @@ inline void gcode_G28() { #else current_position[Z_AXIS] = MESH_HOME_SEARCH_Z - mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS], - current_position[Y_AXIS] - home_offset[Y_AXIS]); + current_position[Y_AXIS] - home_offset[Y_AXIS]) + #if Z_HOME_DIR > 0 + + Z_MAX_POS + #endif + ; #endif } else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) { @@ -3223,7 +3231,11 @@ inline void gcode_G28() { // For each G29 S2... if (probe_point == 0) { // For the intial G29 S2 make Z a positive value (e.g., 4.0) - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + #if Z_HOME_DIR > 0 + + Z_MAX_POS + #endif + ; SYNC_PLAN_POSITION_KINEMATIC(); } else { diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index cc794d1d7b..ea8d8c700c 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1057,7 +1057,11 @@ static void lcd_status_screen() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING)); if (LCD_CLICKED) { _lcd_level_bed_position = 0; - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + #if Z_HOME_DIR > 0 + + Z_MAX_POS + #endif + ; planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); lcd_goto_screen(_lcd_level_goto_next_point, true); }