|
|
@ -1592,9 +1592,6 @@ inline void set_destination_to_current() { memcpy(destination, current_position, |
|
|
|
// - Reset the command timeout
|
|
|
|
// - Enable the endstops (for endstop moves)
|
|
|
|
//
|
|
|
|
// clean_up_after_endstop_move() restores
|
|
|
|
// feedrates, sets endstops back to global state.
|
|
|
|
//
|
|
|
|
static void setup_for_endstop_or_probe_move() { |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("setup_for_endstop_or_probe_move", current_position); |
|
|
@ -1619,12 +1616,6 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
} |
|
|
|
|
|
|
|
#if HAS_BED_PROBE |
|
|
|
|
|
|
|
static void clean_up_after_endstop_move() { |
|
|
|
clean_up_after_endstop_or_probe_move(); |
|
|
|
endstops.not_homing(); |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(DELTA) |
|
|
|
/**
|
|
|
|
* Calculate delta, start a line, and set current_position to destination |
|
|
@ -1666,18 +1657,25 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
feedrate = homing_feedrate[Z_AXIS]; |
|
|
|
|
|
|
|
current_position[Z_AXIS] = z; |
|
|
|
line_to_current_position(); |
|
|
|
stepper.synchronize(); |
|
|
|
// If Z needs to raise, do it before moving XY
|
|
|
|
if (current_position[Z_AXIS] < z) { |
|
|
|
feedrate = homing_feedrate[Z_AXIS]; |
|
|
|
current_position[Z_AXIS] = z; |
|
|
|
line_to_current_position(); |
|
|
|
} |
|
|
|
|
|
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
|
|
|
|
|
|
current_position[X_AXIS] = x; |
|
|
|
current_position[Y_AXIS] = y; |
|
|
|
line_to_current_position(); |
|
|
|
|
|
|
|
// If Z needs to lower, do it after moving XY
|
|
|
|
if (current_position[Z_AXIS] > z) { |
|
|
|
feedrate = homing_feedrate[Z_AXIS]; |
|
|
|
current_position[Z_AXIS] = z; |
|
|
|
line_to_current_position(); |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
stepper.synchronize(); |
|
|
@ -1722,11 +1720,6 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
inline void raise_z_after_probing() { |
|
|
|
#if Z_RAISE_AFTER_PROBING > 0 |
|
|
|
do_probe_raise(Z_RAISE_AFTER_PROBING); |
|
|
|
#endif |
|
|
|
} |
|
|
|
#endif //HAS_BED_PROBE
|
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE |
|
|
@ -1774,7 +1767,9 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
float oldXpos = current_position[X_AXIS]; // save x position
|
|
|
|
float old_feedrate = feedrate; |
|
|
|
if (dock) { |
|
|
|
raise_z_after_probing(); // raise Z
|
|
|
|
#if Z_RAISE_AFTER_PROBING > 0 |
|
|
|
do_probe_raise(Z_RAISE_AFTER_PROBING); |
|
|
|
#endif |
|
|
|
// Dock sled a bit closer to ensure proper capturing
|
|
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
|
|
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1); |
|
|
@ -1804,15 +1799,17 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
|
|
|
|
if (endstops.z_probe_enabled) return; |
|
|
|
|
|
|
|
// Make room for probe
|
|
|
|
#if Z_RAISE_BEFORE_PROBING > 0 |
|
|
|
do_probe_raise(Z_RAISE_BEFORE_PROBING); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) |
|
|
|
|
|
|
|
dock_sled(false); |
|
|
|
|
|
|
|
#elif HAS_Z_SERVO_ENDSTOP |
|
|
|
|
|
|
|
// Make room for Z Servo
|
|
|
|
do_probe_raise(Z_RAISE_BEFORE_PROBING); |
|
|
|
|
|
|
|
// Engage Z Servo endstop if enabled
|
|
|
|
DEPLOY_Z_SERVO(); |
|
|
|
|
|
|
@ -1906,15 +1903,17 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
|
|
|
|
if (!endstops.z_probe_enabled) return; |
|
|
|
|
|
|
|
// Make more room for the servo
|
|
|
|
#if Z_RAISE_AFTER_PROBING > 0 |
|
|
|
do_probe_raise(Z_RAISE_AFTER_PROBING); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) |
|
|
|
|
|
|
|
dock_sled(true); |
|
|
|
|
|
|
|
#elif HAS_Z_SERVO_ENDSTOP |
|
|
|
|
|
|
|
// Make room for the servo
|
|
|
|
do_probe_raise(Z_RAISE_AFTER_PROBING); |
|
|
|
|
|
|
|
// Change the Z servo angle
|
|
|
|
STOW_Z_SERVO(); |
|
|
|
|
|
|
@ -2080,27 +2079,24 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
return current_position[Z_AXIS]; |
|
|
|
} |
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
|
#if HAS_PROBING_PROCEDURE |
|
|
|
|
|
|
|
inline void do_blocking_move_to_xy(float x, float y) { |
|
|
|
do_blocking_move_to(x, y, current_position[Z_AXIS]); |
|
|
|
} |
|
|
|
|
|
|
|
enum ProbeAction { |
|
|
|
ProbeStay = 0, |
|
|
|
ProbeDeploy = _BV(0), |
|
|
|
ProbeStow = _BV(1), |
|
|
|
ProbeDeployAndStow = (ProbeDeploy | ProbeStow) |
|
|
|
}; |
|
|
|
|
|
|
|
// Probe bed height at position (x,y), returns the measured z value
|
|
|
|
static float probe_pt(float x, float y, float z_raise, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) { |
|
|
|
//
|
|
|
|
// - Move to the given XY
|
|
|
|
// - Deploy the probe, if not already deployed
|
|
|
|
// - Probe the bed, get the Z position
|
|
|
|
// - Depending on the 'stow' flag
|
|
|
|
// - Stow the probe, or
|
|
|
|
// - Raise to the BETWEEN height
|
|
|
|
// - Return the probed Z position
|
|
|
|
//
|
|
|
|
static float probe_pt(float x, float y, bool stow = true, int verbose_level = 1) { |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOLNPGM("probe_pt >>>"); |
|
|
|
SERIAL_ECHOPAIR("> ProbeAction:", probe_action); |
|
|
|
SERIAL_ECHOPAIR("> stow:", stow); |
|
|
|
SERIAL_EOL; |
|
|
|
DEBUG_POS("", current_position); |
|
|
|
} |
|
|
@ -2111,39 +2107,37 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
// Raise by z_raise, then move the Z probe to the given XY
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOPAIR("Z Raise by z_raise ", z_raise); |
|
|
|
SERIAL_EOL; |
|
|
|
} |
|
|
|
#endif |
|
|
|
do_probe_raise(z_raise); // this also updates current_position
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - (X_PROBE_OFFSET_FROM_EXTRUDER)); |
|
|
|
SERIAL_ECHOPAIR("> do_blocking_move_to ", x - (X_PROBE_OFFSET_FROM_EXTRUDER)); |
|
|
|
SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); |
|
|
|
SERIAL_ECHOPAIR(", ", max(current_position[Z_AXIS], Z_RAISE_BETWEEN_PROBINGS)); |
|
|
|
SERIAL_EOL; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// this also updates current_position
|
|
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
|
|
do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); |
|
|
|
|
|
|
|
if (probe_action & ProbeDeploy) { |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeDeploy"); |
|
|
|
#endif |
|
|
|
deploy_z_probe(); |
|
|
|
} |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> deploy_z_probe"); |
|
|
|
#endif |
|
|
|
deploy_z_probe(); |
|
|
|
|
|
|
|
float measured_z = run_z_probe(); |
|
|
|
|
|
|
|
if (probe_action & ProbeStow) { |
|
|
|
if (stow) { |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeStow (stow_z_probe will do Z Raise)"); |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> stow_z_probe"); |
|
|
|
#endif |
|
|
|
stow_z_probe(); |
|
|
|
} |
|
|
|
#if Z_RAISE_BETWEEN_PROBINGS > 0 |
|
|
|
else { |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> do_probe_raise"); |
|
|
|
#endif |
|
|
|
do_probe_raise(Z_RAISE_BETWEEN_PROBINGS); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if (verbose_level > 2) { |
|
|
|
SERIAL_PROTOCOLPGM("Bed X: "); |
|
|
@ -2164,7 +2158,7 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
|
return measured_z; |
|
|
|
} |
|
|
|
|
|
|
|
#endif // AUTO_BED_LEVELING_FEATURE || Z_MIN_PROBE_REPEATABILITY_TEST
|
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE) |
|
|
|
|
|
|
@ -3383,8 +3377,10 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
bool dryrun = code_seen('D'); |
|
|
|
|
|
|
|
#if DISABLED(Z_PROBE_SLED) && DISABLED(Z_PROBE_ALLEN_KEY) |
|
|
|
bool deploy_probe_for_each_reading = code_seen('E'); |
|
|
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) |
|
|
|
const bool stow_probe_after_each = false; |
|
|
|
#else |
|
|
|
bool stow_probe_after_each = code_seen('E'); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_GRID) |
|
|
@ -3541,42 +3537,13 @@ inline void gcode_G28() { |
|
|
|
for (int xCount = xStart; xCount != xStop; xCount += xInc) { |
|
|
|
double xProbe = left_probe_bed_position + xGridSpacing * xCount; |
|
|
|
|
|
|
|
// raise extruder
|
|
|
|
float measured_z, |
|
|
|
z_raise = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS : Z_RAISE_BEFORE_PROBING; |
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOPGM("z_raise = ("); |
|
|
|
if (probePointCounter) |
|
|
|
SERIAL_ECHOPGM("between) "); |
|
|
|
else |
|
|
|
SERIAL_ECHOPGM("before) "); |
|
|
|
SERIAL_ECHOLN(z_raise); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(DELTA) |
|
|
|
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
|
|
|
|
float distance_from_center = sqrt(xProbe * xProbe + yProbe * yProbe); |
|
|
|
if (distance_from_center > DELTA_PROBEABLE_RADIUS) continue; |
|
|
|
#endif //DELTA
|
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) |
|
|
|
const ProbeAction act = ProbeStay; |
|
|
|
#else |
|
|
|
ProbeAction act; |
|
|
|
if (deploy_probe_for_each_reading) // G29 E - Stow between probes
|
|
|
|
act = ProbeDeployAndStow; |
|
|
|
else if (yCount == 0 && xCount == xStart) |
|
|
|
act = ProbeDeploy; |
|
|
|
else if (yCount == auto_bed_leveling_grid_points - 1 && xCount == xStop - xInc) |
|
|
|
act = ProbeStow; |
|
|
|
else |
|
|
|
act = ProbeStay; |
|
|
|
#endif |
|
|
|
|
|
|
|
measured_z = probe_pt(xProbe, yProbe, z_raise, act, verbose_level); |
|
|
|
float measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); |
|
|
|
|
|
|
|
#if DISABLED(DELTA) |
|
|
|
mean += measured_z; |
|
|
@ -3597,10 +3564,39 @@ inline void gcode_G28() { |
|
|
|
} //xProbe
|
|
|
|
} //yProbe
|
|
|
|
|
|
|
|
#else // !AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling"); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Probe at 3 arbitrary points
|
|
|
|
float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_1_Y + home_offset[Y_AXIS], |
|
|
|
stow_probe_after_each, verbose_level), |
|
|
|
z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_2_Y + home_offset[Y_AXIS], |
|
|
|
stow_probe_after_each, verbose_level), |
|
|
|
z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS], |
|
|
|
stow_probe_after_each, verbose_level); |
|
|
|
|
|
|
|
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3); |
|
|
|
|
|
|
|
#endif // !AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
// Raise to Z_RAISE_AFTER_PROBING. Stow the probe.
|
|
|
|
stow_z_probe(); |
|
|
|
|
|
|
|
// Restore state after probing
|
|
|
|
clean_up_after_endstop_or_probe_move(); |
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Calculate leveling, print reports, correct the position
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_GRID) |
|
|
|
#if ENABLED(DELTA) |
|
|
|
|
|
|
|
if (!dryrun) extrapolate_unprobed_bed_level(); |
|
|
@ -3696,41 +3692,7 @@ inline void gcode_G28() { |
|
|
|
} |
|
|
|
} //do_topography_map
|
|
|
|
#endif //!DELTA
|
|
|
|
|
|
|
|
#else // !AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling"); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) |
|
|
|
const ProbeAction p1 = ProbeStay, p2 = ProbeStay, p3 = ProbeStay; |
|
|
|
#else |
|
|
|
// Actions for each probe
|
|
|
|
ProbeAction p1, p2, p3; |
|
|
|
if (deploy_probe_for_each_reading) |
|
|
|
p1 = p2 = p3 = ProbeDeployAndStow; |
|
|
|
else |
|
|
|
p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Probe at 3 arbitrary points
|
|
|
|
float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_1_Y + home_offset[Y_AXIS], |
|
|
|
Z_RAISE_BEFORE_PROBING, |
|
|
|
p1, verbose_level), |
|
|
|
z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_2_Y + home_offset[Y_AXIS], |
|
|
|
Z_RAISE_BETWEEN_PROBINGS, |
|
|
|
p2, verbose_level), |
|
|
|
z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS], |
|
|
|
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS], |
|
|
|
Z_RAISE_BETWEEN_PROBINGS, |
|
|
|
p3, verbose_level); |
|
|
|
|
|
|
|
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3); |
|
|
|
|
|
|
|
#endif // !AUTO_BED_LEVELING_GRID
|
|
|
|
#endif // AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
#if DISABLED(DELTA) |
|
|
|
if (verbose_level > 0) |
|
|
@ -3745,13 +3707,12 @@ inline void gcode_G28() { |
|
|
|
float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
z_tmp = current_position[Z_AXIS], |
|
|
|
real_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane)
|
|
|
|
stepper_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane)
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > z_tmp = ", z_tmp); |
|
|
|
SERIAL_EOL; |
|
|
|
SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > real_z = ", real_z); |
|
|
|
SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > stepper_z = ", stepper_z); |
|
|
|
SERIAL_ECHOPAIR(" ... z_tmp = ", z_tmp); |
|
|
|
SERIAL_EOL; |
|
|
|
} |
|
|
|
#endif |
|
|
@ -3759,28 +3720,6 @@ inline void gcode_G28() { |
|
|
|
// Apply the correction sending the Z probe offset
|
|
|
|
apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp); |
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the current Z position and send it to the planner. |
|
|
|
* |
|
|
|
* >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z |
|
|
|
* (most recent planner.set_position_mm/sync_plan_position) |
|
|
|
* |
|
|
|
* >> zprobe_zoffset : Z distance from nozzle to Z probe |
|
|
|
* (set by default, M851, EEPROM, or Menu) |
|
|
|
* |
|
|
|
* >> Z_RAISE_AFTER_PROBING : The distance the Z probe will have lifted |
|
|
|
* after the last probe |
|
|
|
* |
|
|
|
* >> Should home_offset[Z_AXIS] be included? |
|
|
|
* |
|
|
|
* |
|
|
|
* Discussion: home_offset[Z_AXIS] was applied in G28 to set the |
|
|
|
* starting Z. If Z is not tweaked in G29 -and- the Z probe in G29 is |
|
|
|
* not actually "homing" Z... then perhaps it should not be included |
|
|
|
* here. The purpose of home_offset[] is to adjust for inaccurate |
|
|
|
* endstops, not for reasonably accurate probes. If it were added |
|
|
|
* here, it could be seen as a compensating factor for the Z probe. |
|
|
|
*/ |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOPAIR("> AFTER apply_rotation_xyz > z_tmp = ", z_tmp); |
|
|
@ -3788,30 +3727,16 @@ inline void gcode_G28() { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z) |
|
|
|
#if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) |
|
|
|
+ Z_RAISE_AFTER_PROBING |
|
|
|
#endif |
|
|
|
; |
|
|
|
// current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
|
|
|
|
// Adjust the current Z and send it to the planner.
|
|
|
|
current_position[Z_AXIS] += z_tmp - stepper_z; |
|
|
|
SYNC_PLAN_POSITION_KINEMATIC(); |
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
#endif // !DELTA
|
|
|
|
|
|
|
|
// Final raise of Z axis after probing.
|
|
|
|
raise_z_after_probing(); |
|
|
|
|
|
|
|
// Stow the probe. Servo will raise if needed.
|
|
|
|
stow_z_probe(); |
|
|
|
|
|
|
|
// Restore state after probing
|
|
|
|
clean_up_after_endstop_or_probe_move(); |
|
|
|
|
|
|
|
#ifdef Z_PROBE_END_SCRIPT |
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
@ -3824,9 +3749,7 @@ inline void gcode_G28() { |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
SERIAL_ECHOLNPGM("<<< gcode_G29"); |
|
|
|
} |
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29"); |
|
|
|
#endif |
|
|
|
|
|
|
|
bed_leveling_in_progress = false; |
|
|
@ -3847,12 +3770,10 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
setup_for_endstop_or_probe_move(); |
|
|
|
|
|
|
|
deploy_z_probe(); |
|
|
|
|
|
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
// TODO: clear the leveling matrix or the planner will be set incorrectly
|
|
|
|
float measured_z = run_z_probe(); // clears the ABL non-delta matrix only
|
|
|
|
float measured_z = probe_pt(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
true, 1); |
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("Bed X: "); |
|
|
|
SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001); |
|
|
@ -3862,13 +3783,25 @@ inline void gcode_G28() { |
|
|
|
SERIAL_PROTOCOL(measured_z + 0.0001); |
|
|
|
SERIAL_EOL; |
|
|
|
|
|
|
|
stow_z_probe(); |
|
|
|
|
|
|
|
clean_up_after_endstop_or_probe_move(); |
|
|
|
|
|
|
|
report_current_position(); |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) |
|
|
|
|
|
|
|
/**
|
|
|
|
* G31: Deploy the Z probe |
|
|
|
*/ |
|
|
|
inline void gcode_G31() { deploy_z_probe(); } |
|
|
|
|
|
|
|
/**
|
|
|
|
* G32: Stow the Z probe |
|
|
|
*/ |
|
|
|
inline void gcode_G32() { stow_z_probe(); } |
|
|
|
|
|
|
|
#endif // Z_PROBE_SLED
|
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
|
/**
|
|
|
@ -4210,9 +4143,9 @@ inline void gcode_M42() { |
|
|
|
Y_current = current_position[Y_AXIS]; |
|
|
|
|
|
|
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) |
|
|
|
const bool deploy_probe_for_each_reading = false; |
|
|
|
const bool stow_probe_after_each = false; |
|
|
|
#else |
|
|
|
bool deploy_probe_for_each_reading = code_seen('E'); |
|
|
|
bool stow_probe_after_each = code_seen('E'); |
|
|
|
#endif |
|
|
|
|
|
|
|
float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
@ -4265,24 +4198,8 @@ inline void gcode_M42() { |
|
|
|
|
|
|
|
setup_for_endstop_or_probe_move(); |
|
|
|
|
|
|
|
do_probe_raise(Z_RAISE_BEFORE_PROBING); |
|
|
|
|
|
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
|
|
do_blocking_move_to_xy(X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER), Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER)); |
|
|
|
|
|
|
|
/**
|
|
|
|
* OK, do the initial probe to get us close to the bed. |
|
|
|
* Then retrace the right amount and use that in subsequent probes |
|
|
|
*/ |
|
|
|
|
|
|
|
// Height before each probe (except the first)
|
|
|
|
float z_between = deploy_probe_for_each_reading ? Z_RAISE_BEFORE_PROBING : Z_RAISE_BETWEEN_PROBINGS; |
|
|
|
|
|
|
|
// Deploy the probe and probe the first point
|
|
|
|
probe_pt(X_probe_location, Y_probe_location, |
|
|
|
Z_RAISE_BEFORE_PROBING, |
|
|
|
deploy_probe_for_each_reading ? ProbeDeployAndStow : ProbeDeploy, |
|
|
|
verbose_level); |
|
|
|
// Move to the first point, deploy, and probe
|
|
|
|
probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level); |
|
|
|
|
|
|
|
randomSeed(millis()); |
|
|
|
|
|
|
@ -4302,12 +4219,9 @@ inline void gcode_M42() { |
|
|
|
if (verbose_level > 3) { |
|
|
|
SERIAL_ECHOPAIR("Starting radius: ", radius); |
|
|
|
SERIAL_ECHOPAIR(" angle: ", angle); |
|
|
|
delay(100); |
|
|
|
if (dir > 0) |
|
|
|
SERIAL_ECHO(" Direction: Counter Clockwise \n"); |
|
|
|
else |
|
|
|
SERIAL_ECHO(" Direction: Clockwise \n"); |
|
|
|
delay(100); |
|
|
|
SERIAL_ECHO(" Direction: "); |
|
|
|
if (dir > 0) SERIAL_ECHO("Counter "); |
|
|
|
SERIAL_ECHOLN("Clockwise"); |
|
|
|
} |
|
|
|
|
|
|
|
for (uint8_t l = 0; l < n_legs - 1; l++) { |
|
|
@ -4346,7 +4260,6 @@ inline void gcode_M42() { |
|
|
|
SERIAL_ECHOPAIR("Pulling point towards center:", X_current); |
|
|
|
SERIAL_ECHOPAIR(", ", Y_current); |
|
|
|
SERIAL_EOL; |
|
|
|
delay(50); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
@ -4356,22 +4269,13 @@ inline void gcode_M42() { |
|
|
|
SERIAL_ECHOPAIR("y: ", Y_current); |
|
|
|
SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]); |
|
|
|
SERIAL_EOL; |
|
|
|
delay(55); |
|
|
|
} |
|
|
|
do_blocking_move_to_xy(X_current, Y_current); |
|
|
|
} // n_legs loop
|
|
|
|
} // n_legs
|
|
|
|
|
|
|
|
// The last probe will differ
|
|
|
|
bool last_probe = (n == n_samples - 1); |
|
|
|
|
|
|
|
// Probe a single point
|
|
|
|
sample_set[n] = probe_pt( |
|
|
|
X_probe_location, Y_probe_location, |
|
|
|
z_between, |
|
|
|
deploy_probe_for_each_reading ? ProbeDeployAndStow : last_probe ? ProbeStow : ProbeStay, |
|
|
|
verbose_level |
|
|
|
); |
|
|
|
sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level); |
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current mean for the data points we have so far |
|
|
@ -4397,7 +4301,6 @@ inline void gcode_M42() { |
|
|
|
SERIAL_PROTOCOL((int)n_samples); |
|
|
|
SERIAL_PROTOCOLPGM(" z: "); |
|
|
|
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6); |
|
|
|
delay(50); |
|
|
|
if (verbose_level > 2) { |
|
|
|
SERIAL_PROTOCOLPGM(" mean: "); |
|
|
|
SERIAL_PROTOCOL_F(mean, 6); |
|
|
@ -4408,17 +4311,10 @@ inline void gcode_M42() { |
|
|
|
SERIAL_EOL; |
|
|
|
} |
|
|
|
|
|
|
|
// Raise before the next loop for the legs,
|
|
|
|
// or do the final raise after the last probe
|
|
|
|
if (last_probe) |
|
|
|
do_probe_raise(Z_RAISE_AFTER_PROBING); |
|
|
|
else if (n_legs) { |
|
|
|
do_probe_raise(z_between); |
|
|
|
if (!last_probe) delay(500); |
|
|
|
} |
|
|
|
|
|
|
|
} // End of probe loop
|
|
|
|
|
|
|
|
stow_z_probe(); |
|
|
|
|
|
|
|
if (verbose_level > 0) { |
|
|
|
SERIAL_PROTOCOLPGM("Mean: "); |
|
|
|
SERIAL_PROTOCOL_F(mean, 6); |
|
|
@ -5967,16 +5863,12 @@ inline void gcode_M400() { stepper.synchronize(); } |
|
|
|
/**
|
|
|
|
* M401: Engage Z Servo endstop if available |
|
|
|
*/ |
|
|
|
inline void gcode_M401() { |
|
|
|
deploy_z_probe(); |
|
|
|
} |
|
|
|
inline void gcode_M401() { deploy_z_probe(); } |
|
|
|
|
|
|
|
/**
|
|
|
|
* M402: Retract Z Servo endstop if enabled |
|
|
|
*/ |
|
|
|
inline void gcode_M402() { |
|
|
|
stow_z_probe(); |
|
|
|
} |
|
|
|
inline void gcode_M402() { stow_z_probe(); } |
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
@ -6858,10 +6750,11 @@ void process_next_command() { |
|
|
|
#if ENABLED(Z_PROBE_SLED) |
|
|
|
|
|
|
|
case 31: // G31: dock the sled
|
|
|
|
stow_z_probe(); |
|
|
|
gcode_G31(); |
|
|
|
break; |
|
|
|
|
|
|
|
case 32: // G32: undock the sled
|
|
|
|
deploy_z_probe(); |
|
|
|
gcode_G32(); |
|
|
|
break; |
|
|
|
|
|
|
|
#endif // Z_PROBE_SLED
|
|
|
|