|
@@ -1592,9 +1592,6 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1592
|
1592
|
// - Reset the command timeout
|
1593
|
1593
|
// - Enable the endstops (for endstop moves)
|
1594
|
1594
|
//
|
1595
|
|
-// clean_up_after_endstop_move() restores
|
1596
|
|
-// feedrates, sets endstops back to global state.
|
1597
|
|
-//
|
1598
|
1595
|
static void setup_for_endstop_or_probe_move() {
|
1599
|
1596
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1600
|
1597
|
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() {
|
1619
|
1616
|
}
|
1620
|
1617
|
|
1621
|
1618
|
#if HAS_BED_PROBE
|
1622
|
|
-
|
1623
|
|
- static void clean_up_after_endstop_move() {
|
1624
|
|
- clean_up_after_endstop_or_probe_move();
|
1625
|
|
- endstops.not_homing();
|
1626
|
|
- }
|
1627
|
|
-
|
1628
|
1619
|
#if ENABLED(DELTA)
|
1629
|
1620
|
/**
|
1630
|
1621
|
* Calculate delta, start a line, and set current_position to destination
|
|
@@ -1666,18 +1657,25 @@ static void clean_up_after_endstop_or_probe_move() {
|
1666
|
1657
|
|
1667
|
1658
|
#else
|
1668
|
1659
|
|
1669
|
|
- feedrate = homing_feedrate[Z_AXIS];
|
1670
|
|
-
|
1671
|
|
- current_position[Z_AXIS] = z;
|
1672
|
|
- line_to_current_position();
|
1673
|
|
- stepper.synchronize();
|
|
1660
|
+ // If Z needs to raise, do it before moving XY
|
|
1661
|
+ if (current_position[Z_AXIS] < z) {
|
|
1662
|
+ feedrate = homing_feedrate[Z_AXIS];
|
|
1663
|
+ current_position[Z_AXIS] = z;
|
|
1664
|
+ line_to_current_position();
|
|
1665
|
+ }
|
1674
|
1666
|
|
1675
|
1667
|
feedrate = XY_PROBE_FEEDRATE;
|
1676
|
|
-
|
1677
|
1668
|
current_position[X_AXIS] = x;
|
1678
|
1669
|
current_position[Y_AXIS] = y;
|
1679
|
1670
|
line_to_current_position();
|
1680
|
1671
|
|
|
1672
|
+ // If Z needs to lower, do it after moving XY
|
|
1673
|
+ if (current_position[Z_AXIS] > z) {
|
|
1674
|
+ feedrate = homing_feedrate[Z_AXIS];
|
|
1675
|
+ current_position[Z_AXIS] = z;
|
|
1676
|
+ line_to_current_position();
|
|
1677
|
+ }
|
|
1678
|
+
|
1681
|
1679
|
#endif
|
1682
|
1680
|
|
1683
|
1681
|
stepper.synchronize();
|
|
@@ -1722,11 +1720,6 @@ static void clean_up_after_endstop_or_probe_move() {
|
1722
|
1720
|
}
|
1723
|
1721
|
}
|
1724
|
1722
|
|
1725
|
|
- inline void raise_z_after_probing() {
|
1726
|
|
- #if Z_RAISE_AFTER_PROBING > 0
|
1727
|
|
- do_probe_raise(Z_RAISE_AFTER_PROBING);
|
1728
|
|
- #endif
|
1729
|
|
- }
|
1730
|
1723
|
#endif //HAS_BED_PROBE
|
1731
|
1724
|
|
1732
|
1725
|
#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() {
|
1774
|
1767
|
float oldXpos = current_position[X_AXIS]; // save x position
|
1775
|
1768
|
float old_feedrate = feedrate;
|
1776
|
1769
|
if (dock) {
|
1777
|
|
- raise_z_after_probing(); // raise Z
|
|
1770
|
+ #if Z_RAISE_AFTER_PROBING > 0
|
|
1771
|
+ do_probe_raise(Z_RAISE_AFTER_PROBING);
|
|
1772
|
+ #endif
|
1778
|
1773
|
// Dock sled a bit closer to ensure proper capturing
|
1779
|
1774
|
feedrate = XY_PROBE_FEEDRATE;
|
1780
|
1775
|
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() {
|
1804
|
1799
|
|
1805
|
1800
|
if (endstops.z_probe_enabled) return;
|
1806
|
1801
|
|
|
1802
|
+ // Make room for probe
|
|
1803
|
+ #if Z_RAISE_BEFORE_PROBING > 0
|
|
1804
|
+ do_probe_raise(Z_RAISE_BEFORE_PROBING);
|
|
1805
|
+ #endif
|
|
1806
|
+
|
1807
|
1807
|
#if ENABLED(Z_PROBE_SLED)
|
1808
|
1808
|
|
1809
|
1809
|
dock_sled(false);
|
1810
|
1810
|
|
1811
|
1811
|
#elif HAS_Z_SERVO_ENDSTOP
|
1812
|
1812
|
|
1813
|
|
- // Make room for Z Servo
|
1814
|
|
- do_probe_raise(Z_RAISE_BEFORE_PROBING);
|
1815
|
|
-
|
1816
|
1813
|
// Engage Z Servo endstop if enabled
|
1817
|
1814
|
DEPLOY_Z_SERVO();
|
1818
|
1815
|
|
|
@@ -1906,15 +1903,17 @@ static void clean_up_after_endstop_or_probe_move() {
|
1906
|
1903
|
|
1907
|
1904
|
if (!endstops.z_probe_enabled) return;
|
1908
|
1905
|
|
|
1906
|
+ // Make more room for the servo
|
|
1907
|
+ #if Z_RAISE_AFTER_PROBING > 0
|
|
1908
|
+ do_probe_raise(Z_RAISE_AFTER_PROBING);
|
|
1909
|
+ #endif
|
|
1910
|
+
|
1909
|
1911
|
#if ENABLED(Z_PROBE_SLED)
|
1910
|
1912
|
|
1911
|
1913
|
dock_sled(true);
|
1912
|
1914
|
|
1913
|
1915
|
#elif HAS_Z_SERVO_ENDSTOP
|
1914
|
1916
|
|
1915
|
|
- // Make room for the servo
|
1916
|
|
- do_probe_raise(Z_RAISE_AFTER_PROBING);
|
1917
|
|
-
|
1918
|
1917
|
// Change the Z servo angle
|
1919
|
1918
|
STOW_Z_SERVO();
|
1920
|
1919
|
|
|
@@ -2080,27 +2079,24 @@ static void clean_up_after_endstop_or_probe_move() {
|
2080
|
2079
|
return current_position[Z_AXIS];
|
2081
|
2080
|
}
|
2082
|
2081
|
|
2083
|
|
-#endif // HAS_BED_PROBE
|
2084
|
|
-
|
2085
|
|
-#if HAS_PROBING_PROCEDURE
|
2086
|
|
-
|
2087
|
2082
|
inline void do_blocking_move_to_xy(float x, float y) {
|
2088
|
2083
|
do_blocking_move_to(x, y, current_position[Z_AXIS]);
|
2089
|
2084
|
}
|
2090
|
2085
|
|
2091
|
|
- enum ProbeAction {
|
2092
|
|
- ProbeStay = 0,
|
2093
|
|
- ProbeDeploy = _BV(0),
|
2094
|
|
- ProbeStow = _BV(1),
|
2095
|
|
- ProbeDeployAndStow = (ProbeDeploy | ProbeStow)
|
2096
|
|
- };
|
2097
|
|
-
|
2098
|
|
- // Probe bed height at position (x,y), returns the measured z value
|
2099
|
|
- static float probe_pt(float x, float y, float z_raise, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) {
|
|
2086
|
+ //
|
|
2087
|
+ // - Move to the given XY
|
|
2088
|
+ // - Deploy the probe, if not already deployed
|
|
2089
|
+ // - Probe the bed, get the Z position
|
|
2090
|
+ // - Depending on the 'stow' flag
|
|
2091
|
+ // - Stow the probe, or
|
|
2092
|
+ // - Raise to the BETWEEN height
|
|
2093
|
+ // - Return the probed Z position
|
|
2094
|
+ //
|
|
2095
|
+ static float probe_pt(float x, float y, bool stow = true, int verbose_level = 1) {
|
2100
|
2096
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2101
|
2097
|
if (DEBUGGING(LEVELING)) {
|
2102
|
2098
|
SERIAL_ECHOLNPGM("probe_pt >>>");
|
2103
|
|
- SERIAL_ECHOPAIR("> ProbeAction:", probe_action);
|
|
2099
|
+ SERIAL_ECHOPAIR("> stow:", stow);
|
2104
|
2100
|
SERIAL_EOL;
|
2105
|
2101
|
DEBUG_POS("", current_position);
|
2106
|
2102
|
}
|
|
@@ -2111,39 +2107,37 @@ static void clean_up_after_endstop_or_probe_move() {
|
2111
|
2107
|
// Raise by z_raise, then move the Z probe to the given XY
|
2112
|
2108
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2113
|
2109
|
if (DEBUGGING(LEVELING)) {
|
2114
|
|
- SERIAL_ECHOPAIR("Z Raise by z_raise ", z_raise);
|
2115
|
|
- SERIAL_EOL;
|
2116
|
|
- }
|
2117
|
|
- #endif
|
2118
|
|
- do_probe_raise(z_raise); // this also updates current_position
|
2119
|
|
-
|
2120
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2121
|
|
- if (DEBUGGING(LEVELING)) {
|
2122
|
|
- SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
|
|
2110
|
+ SERIAL_ECHOPAIR("> do_blocking_move_to ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
|
2123
|
2111
|
SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
|
|
2112
|
+ SERIAL_ECHOPAIR(", ", max(current_position[Z_AXIS], Z_RAISE_BETWEEN_PROBINGS));
|
2124
|
2113
|
SERIAL_EOL;
|
2125
|
2114
|
}
|
2126
|
2115
|
#endif
|
2127
|
2116
|
|
2128
|
|
- // this also updates current_position
|
2129
|
2117
|
feedrate = XY_PROBE_FEEDRATE;
|
2130
|
2118
|
do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
|
2131
|
2119
|
|
2132
|
|
- if (probe_action & ProbeDeploy) {
|
2133
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2134
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeDeploy");
|
2135
|
|
- #endif
|
2136
|
|
- deploy_z_probe();
|
2137
|
|
- }
|
|
2120
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2121
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> deploy_z_probe");
|
|
2122
|
+ #endif
|
|
2123
|
+ deploy_z_probe();
|
2138
|
2124
|
|
2139
|
2125
|
float measured_z = run_z_probe();
|
2140
|
2126
|
|
2141
|
|
- if (probe_action & ProbeStow) {
|
|
2127
|
+ if (stow) {
|
2142
|
2128
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2143
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeStow (stow_z_probe will do Z Raise)");
|
|
2129
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> stow_z_probe");
|
2144
|
2130
|
#endif
|
2145
|
2131
|
stow_z_probe();
|
2146
|
2132
|
}
|
|
2133
|
+ #if Z_RAISE_BETWEEN_PROBINGS > 0
|
|
2134
|
+ else {
|
|
2135
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2136
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> do_probe_raise");
|
|
2137
|
+ #endif
|
|
2138
|
+ do_probe_raise(Z_RAISE_BETWEEN_PROBINGS);
|
|
2139
|
+ }
|
|
2140
|
+ #endif
|
2147
|
2141
|
|
2148
|
2142
|
if (verbose_level > 2) {
|
2149
|
2143
|
SERIAL_PROTOCOLPGM("Bed X: ");
|
|
@@ -2164,7 +2158,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2164
|
2158
|
return measured_z;
|
2165
|
2159
|
}
|
2166
|
2160
|
|
2167
|
|
-#endif // AUTO_BED_LEVELING_FEATURE || Z_MIN_PROBE_REPEATABILITY_TEST
|
|
2161
|
+#endif // HAS_BED_PROBE
|
2168
|
2162
|
|
2169
|
2163
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
2170
|
2164
|
|
|
@@ -3383,8 +3377,10 @@ inline void gcode_G28() {
|
3383
|
3377
|
|
3384
|
3378
|
bool dryrun = code_seen('D');
|
3385
|
3379
|
|
3386
|
|
- #if DISABLED(Z_PROBE_SLED) && DISABLED(Z_PROBE_ALLEN_KEY)
|
3387
|
|
- bool deploy_probe_for_each_reading = code_seen('E');
|
|
3380
|
+ #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
|
3381
|
+ const bool stow_probe_after_each = false;
|
|
3382
|
+ #else
|
|
3383
|
+ bool stow_probe_after_each = code_seen('E');
|
3388
|
3384
|
#endif
|
3389
|
3385
|
|
3390
|
3386
|
#if ENABLED(AUTO_BED_LEVELING_GRID)
|
|
@@ -3541,42 +3537,13 @@ inline void gcode_G28() {
|
3541
|
3537
|
for (int xCount = xStart; xCount != xStop; xCount += xInc) {
|
3542
|
3538
|
double xProbe = left_probe_bed_position + xGridSpacing * xCount;
|
3543
|
3539
|
|
3544
|
|
- // raise extruder
|
3545
|
|
- float measured_z,
|
3546
|
|
- z_raise = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS : Z_RAISE_BEFORE_PROBING;
|
3547
|
|
-
|
3548
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
3549
|
|
- if (DEBUGGING(LEVELING)) {
|
3550
|
|
- SERIAL_ECHOPGM("z_raise = (");
|
3551
|
|
- if (probePointCounter)
|
3552
|
|
- SERIAL_ECHOPGM("between) ");
|
3553
|
|
- else
|
3554
|
|
- SERIAL_ECHOPGM("before) ");
|
3555
|
|
- SERIAL_ECHOLN(z_raise);
|
3556
|
|
- }
|
3557
|
|
- #endif
|
3558
|
|
-
|
3559
|
3540
|
#if ENABLED(DELTA)
|
3560
|
3541
|
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
|
3561
|
3542
|
float distance_from_center = sqrt(xProbe * xProbe + yProbe * yProbe);
|
3562
|
3543
|
if (distance_from_center > DELTA_PROBEABLE_RADIUS) continue;
|
3563
|
3544
|
#endif //DELTA
|
3564
|
3545
|
|
3565
|
|
- #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
3566
|
|
- const ProbeAction act = ProbeStay;
|
3567
|
|
- #else
|
3568
|
|
- ProbeAction act;
|
3569
|
|
- if (deploy_probe_for_each_reading) // G29 E - Stow between probes
|
3570
|
|
- act = ProbeDeployAndStow;
|
3571
|
|
- else if (yCount == 0 && xCount == xStart)
|
3572
|
|
- act = ProbeDeploy;
|
3573
|
|
- else if (yCount == auto_bed_leveling_grid_points - 1 && xCount == xStop - xInc)
|
3574
|
|
- act = ProbeStow;
|
3575
|
|
- else
|
3576
|
|
- act = ProbeStay;
|
3577
|
|
- #endif
|
3578
|
|
-
|
3579
|
|
- measured_z = probe_pt(xProbe, yProbe, z_raise, act, verbose_level);
|
|
3546
|
+ float measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
|
3580
|
3547
|
|
3581
|
3548
|
#if DISABLED(DELTA)
|
3582
|
3549
|
mean += measured_z;
|
|
@@ -3597,10 +3564,39 @@ inline void gcode_G28() {
|
3597
|
3564
|
} //xProbe
|
3598
|
3565
|
} //yProbe
|
3599
|
3566
|
|
|
3567
|
+ #else // !AUTO_BED_LEVELING_GRID
|
|
3568
|
+
|
3600
|
3569
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3601
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
|
|
3570
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
|
3602
|
3571
|
#endif
|
3603
|
3572
|
|
|
3573
|
+ // Probe at 3 arbitrary points
|
|
3574
|
+ float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
|
|
3575
|
+ ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
|
|
3576
|
+ stow_probe_after_each, verbose_level),
|
|
3577
|
+ z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
|
|
3578
|
+ ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
|
|
3579
|
+ stow_probe_after_each, verbose_level),
|
|
3580
|
+ z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
|
|
3581
|
+ ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
|
|
3582
|
+ stow_probe_after_each, verbose_level);
|
|
3583
|
+
|
|
3584
|
+ if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
3585
|
+
|
|
3586
|
+ #endif // !AUTO_BED_LEVELING_GRID
|
|
3587
|
+
|
|
3588
|
+ // Raise to Z_RAISE_AFTER_PROBING. Stow the probe.
|
|
3589
|
+ stow_z_probe();
|
|
3590
|
+
|
|
3591
|
+ // Restore state after probing
|
|
3592
|
+ clean_up_after_endstop_or_probe_move();
|
|
3593
|
+
|
|
3594
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
3595
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
|
|
3596
|
+ #endif
|
|
3597
|
+
|
|
3598
|
+ // Calculate leveling, print reports, correct the position
|
|
3599
|
+ #if ENABLED(AUTO_BED_LEVELING_GRID)
|
3604
|
3600
|
#if ENABLED(DELTA)
|
3605
|
3601
|
|
3606
|
3602
|
if (!dryrun) extrapolate_unprobed_bed_level();
|
|
@@ -3696,41 +3692,7 @@ inline void gcode_G28() {
|
3696
|
3692
|
}
|
3697
|
3693
|
} //do_topography_map
|
3698
|
3694
|
#endif //!DELTA
|
3699
|
|
-
|
3700
|
|
- #else // !AUTO_BED_LEVELING_GRID
|
3701
|
|
-
|
3702
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
3703
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
|
3704
|
|
- #endif
|
3705
|
|
-
|
3706
|
|
- #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
3707
|
|
- const ProbeAction p1 = ProbeStay, p2 = ProbeStay, p3 = ProbeStay;
|
3708
|
|
- #else
|
3709
|
|
- // Actions for each probe
|
3710
|
|
- ProbeAction p1, p2, p3;
|
3711
|
|
- if (deploy_probe_for_each_reading)
|
3712
|
|
- p1 = p2 = p3 = ProbeDeployAndStow;
|
3713
|
|
- else
|
3714
|
|
- p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
|
3715
|
|
- #endif
|
3716
|
|
-
|
3717
|
|
- // Probe at 3 arbitrary points
|
3718
|
|
- float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
|
3719
|
|
- ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
|
3720
|
|
- Z_RAISE_BEFORE_PROBING,
|
3721
|
|
- p1, verbose_level),
|
3722
|
|
- z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
|
3723
|
|
- ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
|
3724
|
|
- Z_RAISE_BETWEEN_PROBINGS,
|
3725
|
|
- p2, verbose_level),
|
3726
|
|
- z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
|
3727
|
|
- ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
|
3728
|
|
- Z_RAISE_BETWEEN_PROBINGS,
|
3729
|
|
- p3, verbose_level);
|
3730
|
|
-
|
3731
|
|
- if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
3732
|
|
-
|
3733
|
|
- #endif // !AUTO_BED_LEVELING_GRID
|
|
3695
|
+ #endif // AUTO_BED_LEVELING_GRID
|
3734
|
3696
|
|
3735
|
3697
|
#if DISABLED(DELTA)
|
3736
|
3698
|
if (verbose_level > 0)
|
|
@@ -3745,13 +3707,12 @@ inline void gcode_G28() {
|
3745
|
3707
|
float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
|
3746
|
3708
|
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
|
3747
|
3709
|
z_tmp = current_position[Z_AXIS],
|
3748
|
|
- real_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane)
|
|
3710
|
+ stepper_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane)
|
3749
|
3711
|
|
3750
|
3712
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3751
|
3713
|
if (DEBUGGING(LEVELING)) {
|
3752
|
|
- SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > z_tmp = ", z_tmp);
|
3753
|
|
- SERIAL_EOL;
|
3754
|
|
- SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > real_z = ", real_z);
|
|
3714
|
+ SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > stepper_z = ", stepper_z);
|
|
3715
|
+ SERIAL_ECHOPAIR(" ... z_tmp = ", z_tmp);
|
3755
|
3716
|
SERIAL_EOL;
|
3756
|
3717
|
}
|
3757
|
3718
|
#endif
|
|
@@ -3759,28 +3720,6 @@ inline void gcode_G28() {
|
3759
|
3720
|
// Apply the correction sending the Z probe offset
|
3760
|
3721
|
apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp);
|
3761
|
3722
|
|
3762
|
|
- /*
|
3763
|
|
- * Get the current Z position and send it to the planner.
|
3764
|
|
- *
|
3765
|
|
- * >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z
|
3766
|
|
- * (most recent planner.set_position_mm/sync_plan_position)
|
3767
|
|
- *
|
3768
|
|
- * >> zprobe_zoffset : Z distance from nozzle to Z probe
|
3769
|
|
- * (set by default, M851, EEPROM, or Menu)
|
3770
|
|
- *
|
3771
|
|
- * >> Z_RAISE_AFTER_PROBING : The distance the Z probe will have lifted
|
3772
|
|
- * after the last probe
|
3773
|
|
- *
|
3774
|
|
- * >> Should home_offset[Z_AXIS] be included?
|
3775
|
|
- *
|
3776
|
|
- *
|
3777
|
|
- * Discussion: home_offset[Z_AXIS] was applied in G28 to set the
|
3778
|
|
- * starting Z. If Z is not tweaked in G29 -and- the Z probe in G29 is
|
3779
|
|
- * not actually "homing" Z... then perhaps it should not be included
|
3780
|
|
- * here. The purpose of home_offset[] is to adjust for inaccurate
|
3781
|
|
- * endstops, not for reasonably accurate probes. If it were added
|
3782
|
|
- * here, it could be seen as a compensating factor for the Z probe.
|
3783
|
|
- */
|
3784
|
3723
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3785
|
3724
|
if (DEBUGGING(LEVELING)) {
|
3786
|
3725
|
SERIAL_ECHOPAIR("> AFTER apply_rotation_xyz > z_tmp = ", z_tmp);
|
|
@@ -3788,30 +3727,16 @@ inline void gcode_G28() {
|
3788
|
3727
|
}
|
3789
|
3728
|
#endif
|
3790
|
3729
|
|
3791
|
|
- current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z)
|
3792
|
|
- #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)
|
3793
|
|
- + Z_RAISE_AFTER_PROBING
|
3794
|
|
- #endif
|
3795
|
|
- ;
|
3796
|
|
- // current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
|
|
3730
|
+ // Adjust the current Z and send it to the planner.
|
|
3731
|
+ current_position[Z_AXIS] += z_tmp - stepper_z;
|
3797
|
3732
|
SYNC_PLAN_POSITION_KINEMATIC();
|
3798
|
3733
|
|
3799
|
3734
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3800
|
3735
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position);
|
3801
|
3736
|
#endif
|
3802
|
3737
|
}
|
3803
|
|
-
|
3804
|
3738
|
#endif // !DELTA
|
3805
|
3739
|
|
3806
|
|
- // Final raise of Z axis after probing.
|
3807
|
|
- raise_z_after_probing();
|
3808
|
|
-
|
3809
|
|
- // Stow the probe. Servo will raise if needed.
|
3810
|
|
- stow_z_probe();
|
3811
|
|
-
|
3812
|
|
- // Restore state after probing
|
3813
|
|
- clean_up_after_endstop_or_probe_move();
|
3814
|
|
-
|
3815
|
3740
|
#ifdef Z_PROBE_END_SCRIPT
|
3816
|
3741
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3817
|
3742
|
if (DEBUGGING(LEVELING)) {
|
|
@@ -3824,9 +3749,7 @@ inline void gcode_G28() {
|
3824
|
3749
|
#endif
|
3825
|
3750
|
|
3826
|
3751
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3827
|
|
- if (DEBUGGING(LEVELING)) {
|
3828
|
|
- SERIAL_ECHOLNPGM("<<< gcode_G29");
|
3829
|
|
- }
|
|
3752
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
|
3830
|
3753
|
#endif
|
3831
|
3754
|
|
3832
|
3755
|
bed_leveling_in_progress = false;
|
|
@@ -3847,12 +3770,10 @@ inline void gcode_G28() {
|
3847
|
3770
|
|
3848
|
3771
|
setup_for_endstop_or_probe_move();
|
3849
|
3772
|
|
3850
|
|
- deploy_z_probe();
|
3851
|
|
-
|
3852
|
|
- stepper.synchronize();
|
3853
|
|
-
|
3854
|
3773
|
// TODO: clear the leveling matrix or the planner will be set incorrectly
|
3855
|
|
- float measured_z = run_z_probe(); // clears the ABL non-delta matrix only
|
|
3774
|
+ float measured_z = probe_pt(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
|
|
3775
|
+ current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
|
|
3776
|
+ true, 1);
|
3856
|
3777
|
|
3857
|
3778
|
SERIAL_PROTOCOLPGM("Bed X: ");
|
3858
|
3779
|
SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
|
|
@@ -3862,13 +3783,25 @@ inline void gcode_G28() {
|
3862
|
3783
|
SERIAL_PROTOCOL(measured_z + 0.0001);
|
3863
|
3784
|
SERIAL_EOL;
|
3864
|
3785
|
|
3865
|
|
- stow_z_probe();
|
3866
|
|
-
|
3867
|
3786
|
clean_up_after_endstop_or_probe_move();
|
3868
|
3787
|
|
3869
|
3788
|
report_current_position();
|
3870
|
3789
|
}
|
3871
|
3790
|
|
|
3791
|
+ #if ENABLED(Z_PROBE_SLED)
|
|
3792
|
+
|
|
3793
|
+ /**
|
|
3794
|
+ * G31: Deploy the Z probe
|
|
3795
|
+ */
|
|
3796
|
+ inline void gcode_G31() { deploy_z_probe(); }
|
|
3797
|
+
|
|
3798
|
+ /**
|
|
3799
|
+ * G32: Stow the Z probe
|
|
3800
|
+ */
|
|
3801
|
+ inline void gcode_G32() { stow_z_probe(); }
|
|
3802
|
+
|
|
3803
|
+ #endif // Z_PROBE_SLED
|
|
3804
|
+
|
3872
|
3805
|
#endif // HAS_BED_PROBE
|
3873
|
3806
|
|
3874
|
3807
|
/**
|
|
@@ -4210,9 +4143,9 @@ inline void gcode_M42() {
|
4210
|
4143
|
Y_current = current_position[Y_AXIS];
|
4211
|
4144
|
|
4212
|
4145
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
4213
|
|
- const bool deploy_probe_for_each_reading = false;
|
|
4146
|
+ const bool stow_probe_after_each = false;
|
4214
|
4147
|
#else
|
4215
|
|
- bool deploy_probe_for_each_reading = code_seen('E');
|
|
4148
|
+ bool stow_probe_after_each = code_seen('E');
|
4216
|
4149
|
#endif
|
4217
|
4150
|
|
4218
|
4151
|
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() {
|
4265
|
4198
|
|
4266
|
4199
|
setup_for_endstop_or_probe_move();
|
4267
|
4200
|
|
4268
|
|
- do_probe_raise(Z_RAISE_BEFORE_PROBING);
|
4269
|
|
-
|
4270
|
|
- feedrate = XY_PROBE_FEEDRATE;
|
4271
|
|
- do_blocking_move_to_xy(X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER), Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER));
|
4272
|
|
-
|
4273
|
|
- /**
|
4274
|
|
- * OK, do the initial probe to get us close to the bed.
|
4275
|
|
- * Then retrace the right amount and use that in subsequent probes
|
4276
|
|
- */
|
4277
|
|
-
|
4278
|
|
- // Height before each probe (except the first)
|
4279
|
|
- float z_between = deploy_probe_for_each_reading ? Z_RAISE_BEFORE_PROBING : Z_RAISE_BETWEEN_PROBINGS;
|
4280
|
|
-
|
4281
|
|
- // Deploy the probe and probe the first point
|
4282
|
|
- probe_pt(X_probe_location, Y_probe_location,
|
4283
|
|
- Z_RAISE_BEFORE_PROBING,
|
4284
|
|
- deploy_probe_for_each_reading ? ProbeDeployAndStow : ProbeDeploy,
|
4285
|
|
- verbose_level);
|
|
4201
|
+ // Move to the first point, deploy, and probe
|
|
4202
|
+ probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
|
4286
|
4203
|
|
4287
|
4204
|
randomSeed(millis());
|
4288
|
4205
|
|
|
@@ -4302,12 +4219,9 @@ inline void gcode_M42() {
|
4302
|
4219
|
if (verbose_level > 3) {
|
4303
|
4220
|
SERIAL_ECHOPAIR("Starting radius: ", radius);
|
4304
|
4221
|
SERIAL_ECHOPAIR(" angle: ", angle);
|
4305
|
|
- delay(100);
|
4306
|
|
- if (dir > 0)
|
4307
|
|
- SERIAL_ECHO(" Direction: Counter Clockwise \n");
|
4308
|
|
- else
|
4309
|
|
- SERIAL_ECHO(" Direction: Clockwise \n");
|
4310
|
|
- delay(100);
|
|
4222
|
+ SERIAL_ECHO(" Direction: ");
|
|
4223
|
+ if (dir > 0) SERIAL_ECHO("Counter ");
|
|
4224
|
+ SERIAL_ECHOLN("Clockwise");
|
4311
|
4225
|
}
|
4312
|
4226
|
|
4313
|
4227
|
for (uint8_t l = 0; l < n_legs - 1; l++) {
|
|
@@ -4346,7 +4260,6 @@ inline void gcode_M42() {
|
4346
|
4260
|
SERIAL_ECHOPAIR("Pulling point towards center:", X_current);
|
4347
|
4261
|
SERIAL_ECHOPAIR(", ", Y_current);
|
4348
|
4262
|
SERIAL_EOL;
|
4349
|
|
- delay(50);
|
4350
|
4263
|
}
|
4351
|
4264
|
}
|
4352
|
4265
|
#endif
|
|
@@ -4356,22 +4269,13 @@ inline void gcode_M42() {
|
4356
|
4269
|
SERIAL_ECHOPAIR("y: ", Y_current);
|
4357
|
4270
|
SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]);
|
4358
|
4271
|
SERIAL_EOL;
|
4359
|
|
- delay(55);
|
4360
|
4272
|
}
|
4361
|
4273
|
do_blocking_move_to_xy(X_current, Y_current);
|
4362
|
4274
|
} // n_legs loop
|
4363
|
4275
|
} // n_legs
|
4364
|
4276
|
|
4365
|
|
- // The last probe will differ
|
4366
|
|
- bool last_probe = (n == n_samples - 1);
|
4367
|
|
-
|
4368
|
4277
|
// Probe a single point
|
4369
|
|
- sample_set[n] = probe_pt(
|
4370
|
|
- X_probe_location, Y_probe_location,
|
4371
|
|
- z_between,
|
4372
|
|
- deploy_probe_for_each_reading ? ProbeDeployAndStow : last_probe ? ProbeStow : ProbeStay,
|
4373
|
|
- verbose_level
|
4374
|
|
- );
|
|
4278
|
+ sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
|
4375
|
4279
|
|
4376
|
4280
|
/**
|
4377
|
4281
|
* Get the current mean for the data points we have so far
|
|
@@ -4397,7 +4301,6 @@ inline void gcode_M42() {
|
4397
|
4301
|
SERIAL_PROTOCOL((int)n_samples);
|
4398
|
4302
|
SERIAL_PROTOCOLPGM(" z: ");
|
4399
|
4303
|
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
|
4400
|
|
- delay(50);
|
4401
|
4304
|
if (verbose_level > 2) {
|
4402
|
4305
|
SERIAL_PROTOCOLPGM(" mean: ");
|
4403
|
4306
|
SERIAL_PROTOCOL_F(mean, 6);
|
|
@@ -4408,17 +4311,10 @@ inline void gcode_M42() {
|
4408
|
4311
|
SERIAL_EOL;
|
4409
|
4312
|
}
|
4410
|
4313
|
|
4411
|
|
- // Raise before the next loop for the legs,
|
4412
|
|
- // or do the final raise after the last probe
|
4413
|
|
- if (last_probe)
|
4414
|
|
- do_probe_raise(Z_RAISE_AFTER_PROBING);
|
4415
|
|
- else if (n_legs) {
|
4416
|
|
- do_probe_raise(z_between);
|
4417
|
|
- if (!last_probe) delay(500);
|
4418
|
|
- }
|
4419
|
|
-
|
4420
|
4314
|
} // End of probe loop
|
4421
|
4315
|
|
|
4316
|
+ stow_z_probe();
|
|
4317
|
+
|
4422
|
4318
|
if (verbose_level > 0) {
|
4423
|
4319
|
SERIAL_PROTOCOLPGM("Mean: ");
|
4424
|
4320
|
SERIAL_PROTOCOL_F(mean, 6);
|
|
@@ -5967,16 +5863,12 @@ inline void gcode_M400() { stepper.synchronize(); }
|
5967
|
5863
|
/**
|
5968
|
5864
|
* M401: Engage Z Servo endstop if available
|
5969
|
5865
|
*/
|
5970
|
|
- inline void gcode_M401() {
|
5971
|
|
- deploy_z_probe();
|
5972
|
|
- }
|
|
5866
|
+ inline void gcode_M401() { deploy_z_probe(); }
|
5973
|
5867
|
|
5974
|
5868
|
/**
|
5975
|
5869
|
* M402: Retract Z Servo endstop if enabled
|
5976
|
5870
|
*/
|
5977
|
|
- inline void gcode_M402() {
|
5978
|
|
- stow_z_probe();
|
5979
|
|
- }
|
|
5871
|
+ inline void gcode_M402() { stow_z_probe(); }
|
5980
|
5872
|
|
5981
|
5873
|
#endif // HAS_BED_PROBE
|
5982
|
5874
|
|
|
@@ -6858,10 +6750,11 @@ void process_next_command() {
|
6858
|
6750
|
#if ENABLED(Z_PROBE_SLED)
|
6859
|
6751
|
|
6860
|
6752
|
case 31: // G31: dock the sled
|
6861
|
|
- stow_z_probe();
|
|
6753
|
+ gcode_G31();
|
6862
|
6754
|
break;
|
|
6755
|
+
|
6863
|
6756
|
case 32: // G32: undock the sled
|
6864
|
|
- deploy_z_probe();
|
|
6757
|
+ gcode_G32();
|
6865
|
6758
|
break;
|
6866
|
6759
|
|
6867
|
6760
|
#endif // Z_PROBE_SLED
|