diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0fffc08e5..350348c8a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -731,6 +731,7 @@ */ #define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points +//#define Z_AFTER_PROBING 5 // Z position after probing is done // For M851 give a range for adjusting the Z probe offset #define Z_PROBE_OFFSET_RANGE_MIN -20 diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 4730ab251..5da03d3d6 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -389,6 +389,11 @@ void report_current_position(); #if HAS_BED_PROBE extern float zprobe_zoffset; bool set_probe_deployed(const bool deploy); + #ifdef Z_AFTER_PROBING + void move_z_after_probing(); + #else + inline void move_z_after_probing() {} + #endif #define DEPLOY_PROBE() set_probe_deployed(true) #define STOW_PROBE() set_probe_deployed(false) #else diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2d8e2235c..f8ecaddae 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3839,6 +3839,15 @@ inline void gcode_G4() { #endif // DELTA +#ifdef Z_AFTER_PROBING + void move_z_after_probing() { + if (current_position[Z_AXIS] != Z_AFTER_PROBING) { + do_blocking_move_to_z(Z_AFTER_PROBING); + current_position[Z_AXIS] = Z_AFTER_PROBING; + } + } +#endif + #if ENABLED(Z_SAFE_HOMING) inline void home_z_safely() { @@ -4068,6 +4077,11 @@ inline void gcode_G28(const bool always_home_all) { #else HOMEAXIS(Z); #endif + + #if HOMING_Z_WITH_PROBE + move_z_after_probing(); + #endif + } // home_all || homeZ #endif // Z_HOME_DIR < 0 @@ -5015,7 +5029,7 @@ void home_all_axes() { gcode_G28(true); } #endif // AUTO_BED_LEVELING_3POINT - // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe. + // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (STOW_PROBE()) { set_bed_leveling_enabled(abl_should_enable); measured_z = NAN; @@ -5249,12 +5263,16 @@ void home_all_axes() { gcode_G28(true); } if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29"); #endif - report_current_position(); - KEEPALIVE_STATE(IN_HANDLER); if (planner.leveling_active) SYNC_PLAN_POSITION_KINEMATIC(); + + #if HAS_BED_PROBE + move_z_after_probing(); + #endif + + report_current_position(); } #endif // OLDSCHOOL_ABL @@ -5283,7 +5301,8 @@ void home_all_axes() { gcode_G28(true); } setup_for_endstop_or_probe_move(); - const float measured_z = probe_pt(xpos, ypos, parser.boolval('E'), 1); + const bool do_stow = parser.boolval('E'); + const float measured_z = probe_pt(xpos, ypos, do_stow, 1); if (!isnan(measured_z)) { SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos)); @@ -5293,6 +5312,8 @@ void home_all_axes() { gcode_G28(true); } clean_up_after_endstop_or_probe_move(); + if (do_stow) move_z_after_probing(); + report_current_position(); } @@ -7600,6 +7621,7 @@ inline void gcode_M42() { set_bed_leveling_enabled(was_enabled); #endif + move_z_after_probing(); report_current_position(); } @@ -9665,12 +9687,19 @@ inline void gcode_M400() { stepper.synchronize(); } /** * M401: Deploy and activate the Z probe */ - inline void gcode_M401() { DEPLOY_PROBE(); } + inline void gcode_M401() { + DEPLOY_PROBE(); + report_current_position(); + } /** * M402: Deactivate and stow the Z probe */ - inline void gcode_M402() { STOW_PROBE(); } + inline void gcode_M402() { + STOW_PROBE(); + move_z_after_probing(); + report_current_position(); + } #endif // HAS_BED_PROBE diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 15e49ddf9..078038d4f 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -162,7 +162,7 @@ #elif defined(MIN_Z_HEIGHT_FOR_HOMING) #error "MIN_Z_HEIGHT_FOR_HOMING is now Z_HOMING_HEIGHT. Please update your configuration." #elif defined(Z_RAISE_BEFORE_PROBING) || defined(Z_RAISE_AFTER_PROBING) - #error "Z_RAISE_(BEFORE|AFTER)_PROBING are deprecated. Use Z_CLEARANCE_DEPLOY_PROBE instead." + #error "Z_RAISE_(BEFORE|AFTER)_PROBING are deprecated. Use Z_CLEARANCE_DEPLOY_PROBE and Z_AFTER_PROBING instead." #elif defined(Z_RAISE_PROBE_DEPLOY_STOW) || defined(Z_RAISE_BETWEEN_PROBINGS) #error "Z_RAISE_PROBE_DEPLOY_STOW and Z_RAISE_BETWEEN_PROBINGS are now Z_CLEARANCE_DEPLOY_PROBE and Z_CLEARANCE_BETWEEN_PROBES. Please update your configuration." #elif defined(Z_PROBE_DEPLOY_HEIGHT) || defined(Z_PROBE_TRAVEL_HEIGHT) @@ -762,6 +762,8 @@ static_assert(1 >= 0 #error "Probes need Z_CLEARANCE_DEPLOY_PROBE >= 0." #elif Z_CLEARANCE_BETWEEN_PROBES < 0 #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0." + #elif Z_AFTER_PROBING < 0 + #error "Probes need Z_AFTER_PROBING >= 0." #endif #if MULTIPLE_PROBING && MULTIPLE_PROBING < 2 diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index cdca64c76..7abe183f8 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -387,6 +387,7 @@ restore_ubl_active_state_and_leave(); } do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y))); + report_current_position(); } #endif // HAS_BED_PROBE @@ -424,6 +425,8 @@ } probe_entire_mesh(g29_x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, g29_y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, parser.seen('T'), parser.seen('E'), parser.seen('U')); + + report_current_position(); break; #endif // HAS_BED_PROBE @@ -471,6 +474,8 @@ SERIAL_PROTOCOLLNPGM("G29 P2 finished."); + report_current_position(); + #else SERIAL_PROTOCOLLNPGM("?P2 is only available when an LCD is present."); @@ -754,6 +759,8 @@ } while (location.x_index >= 0 && --max_iterations); STOW_PROBE(); + move_z_after_probing(); + restore_ubl_active_state_and_leave(); do_blocking_move_to_xy(