Browse Source

Merge pull request #4100 from thinkyhead/rc_z_deploy

Use deploy/stow with FIX_MOUNTED_PROBE too
Scott Lahteine 8 years ago
parent
commit
71534dc11f
2 changed files with 403 additions and 372 deletions
  1. 24
    2
      .travis.yml
  2. 379
    370
      Marlin/Marlin_main.cpp

+ 24
- 2
.travis.yml View File

@@ -90,13 +90,35 @@ script:
90 90
   - opt_enable PIDTEMPBED
91 91
   - build_marlin
92 92
   #
93
-  # Test a Servo Probe without leveling
93
+  # Test a "Fix Mounted" Probe
94
+  #
95
+  - restore_configs
96
+  - opt_enable FIX_MOUNTED_PROBE
97
+  - build_marlin
98
+  #
99
+  # ...with AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE
100
+  #
101
+  - opt_enable AUTO_BED_LEVELING_FEATURE DEBUG_LEVELING_FEATURE
102
+  - build_marlin
103
+  #
104
+  # Test a Mechanical Probe
105
+  #
106
+  - restore_configs
107
+  - opt_enable MECHANICAL_PROBE
108
+  - build_marlin
109
+  #
110
+  # ...with AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE
111
+  #
112
+  - opt_enable AUTO_BED_LEVELING_FEATURE DEBUG_LEVELING_FEATURE
113
+  - build_marlin
114
+  #
115
+  # Test a Servo Probe
94 116
   #
95 117
   - restore_configs
96 118
   - opt_enable NUM_SERVOS Z_ENDSTOP_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE
97 119
   - build_marlin
98 120
   #
99
-  # Test AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE with a Servo Probe
121
+  # ...with AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE
100 122
   #
101 123
   - opt_enable AUTO_BED_LEVELING_FEATURE DEBUG_LEVELING_FEATURE
102 124
   - build_marlin

+ 379
- 370
Marlin/Marlin_main.cpp View File

@@ -1570,6 +1570,18 @@ inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[
1570 1570
 inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
1571 1571
 inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
1572 1572
 
1573
+//
1574
+// Prepare to do endstop or probe moves
1575
+// with custom feedrates.
1576
+//
1577
+//  - Save current feedrates
1578
+//  - Reset the rate multiplier
1579
+//  - Enable the endstops
1580
+//  - Reset the command timeout
1581
+//
1582
+// clean_up_after_endstop_move() restores
1583
+// feedrates, sets endstops back to global state.
1584
+//
1573 1585
 static void setup_for_endstop_move() {
1574 1586
   saved_feedrate = feedrate;
1575 1587
   saved_feedrate_multiplier = feedrate_multiplier;
@@ -1583,6 +1595,16 @@ static void setup_for_endstop_move() {
1583 1595
 
1584 1596
 #if HAS_BED_PROBE
1585 1597
 
1598
+  static void clean_up_after_endstop_move() {
1599
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
1600
+      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("clean_up_after_endstop_move > endstops.not_homing()");
1601
+    #endif
1602
+    endstops.not_homing();
1603
+    feedrate = saved_feedrate;
1604
+    feedrate_multiplier = saved_feedrate_multiplier;
1605
+    refresh_cmd_timeout();
1606
+  }
1607
+
1586 1608
   #if ENABLED(DELTA)
1587 1609
     /**
1588 1610
      * Calculate delta, start a line, and set current_position to destination
@@ -1655,6 +1677,10 @@ static void setup_for_endstop_move() {
1655 1677
     feedrate = old_feedrate;
1656 1678
   }
1657 1679
 
1680
+  inline void do_blocking_move_to_x(float x) {
1681
+    do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
1682
+  }
1683
+
1658 1684
   inline void do_blocking_move_to_z(float z) {
1659 1685
     do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
1660 1686
   }
@@ -1684,174 +1710,7 @@ static void setup_for_endstop_move() {
1684 1710
 
1685 1711
 #endif
1686 1712
 
1687
-#if ENABLED(AUTO_BED_LEVELING_FEATURE)
1688
-
1689
-  #if ENABLED(AUTO_BED_LEVELING_GRID)
1690
-
1691
-    #if DISABLED(DELTA)
1692
-
1693
-      static void set_bed_level_equation_lsq(double* plane_equation_coefficients) {
1694
-
1695
-        //planner.bed_level_matrix.debug("bed level before");
1696
-
1697
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
1698
-          planner.bed_level_matrix.set_to_identity();
1699
-          if (DEBUGGING(LEVELING)) {
1700
-            vector_3 uncorrected_position = planner.adjusted_position();
1701
-            DEBUG_POS(">>> set_bed_level_equation_lsq", uncorrected_position);
1702
-            DEBUG_POS(">>> set_bed_level_equation_lsq", current_position);
1703
-          }
1704
-        #endif
1705
-
1706
-        vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
1707
-        planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1708
-
1709
-        vector_3 corrected_position = planner.adjusted_position();
1710
-        current_position[X_AXIS] = corrected_position.x;
1711
-        current_position[Y_AXIS] = corrected_position.y;
1712
-        current_position[Z_AXIS] = corrected_position.z;
1713
-
1714
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
1715
-          if (DEBUGGING(LEVELING)) DEBUG_POS("<<< set_bed_level_equation_lsq", corrected_position);
1716
-        #endif
1717
-
1718
-        sync_plan_position();
1719
-      }
1720
-
1721
-    #endif // !DELTA
1722
-
1723
-  #else // !AUTO_BED_LEVELING_GRID
1724
-
1725
-    static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
1726
-
1727
-      planner.bed_level_matrix.set_to_identity();
1728
-
1729
-      vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
1730
-      vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
1731
-      vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
1732
-      vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal();
1733
-
1734
-      if (planeNormal.z < 0) {
1735
-        planeNormal.x = -planeNormal.x;
1736
-        planeNormal.y = -planeNormal.y;
1737
-        planeNormal.z = -planeNormal.z;
1738
-      }
1739
-
1740
-      planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1741
-
1742
-      vector_3 corrected_position = planner.adjusted_position();
1743
-
1744
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1745
-        if (DEBUGGING(LEVELING)) {
1746
-          vector_3 uncorrected_position = corrected_position;
1747
-          DEBUG_POS("set_bed_level_equation_3pts", uncorrected_position);
1748
-        }
1749
-      #endif
1750
-
1751
-      current_position[X_AXIS] = corrected_position.x;
1752
-      current_position[Y_AXIS] = corrected_position.y;
1753
-      current_position[Z_AXIS] = corrected_position.z;
1754
-
1755
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1756
-        if (DEBUGGING(LEVELING)) DEBUG_POS("set_bed_level_equation_3pts", corrected_position);
1757
-      #endif
1758
-
1759
-      sync_plan_position();
1760
-    }
1761
-
1762
-  #endif // !AUTO_BED_LEVELING_GRID
1763
-
1764
-  static void run_z_probe() {
1765
-
1766
-    float old_feedrate = feedrate;
1767
-
1768
-    /**
1769
-     * To prevent stepper_inactive_time from running out and
1770
-     * EXTRUDER_RUNOUT_PREVENT from extruding
1771
-     */
1772
-    refresh_cmd_timeout();
1773
-
1774
-    #if ENABLED(DELTA)
1775
-
1776
-      float start_z = current_position[Z_AXIS];
1777
-      long start_steps = stepper.position(Z_AXIS);
1778
-
1779
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1780
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("run_z_probe (DELTA) 1");
1781
-      #endif
1782
-
1783
-      // move down slowly until you find the bed
1784
-      feedrate = homing_feedrate[Z_AXIS] / 4;
1785
-      destination[Z_AXIS] = -10;
1786
-      prepare_move_to_destination_raw(); // this will also set_current_to_destination
1787
-      stepper.synchronize();
1788
-      endstops.hit_on_purpose(); // clear endstop hit flags
1789
-
1790
-      /**
1791
-       * We have to let the planner know where we are right now as it
1792
-       * is not where we said to go.
1793
-       */
1794
-      long stop_steps = stepper.position(Z_AXIS);
1795
-      float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_mm[Z_AXIS];
1796
-      current_position[Z_AXIS] = mm;
1797
-
1798
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1799
-        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe (DELTA) 2", current_position);
1800
-      #endif
1801
-
1802
-      sync_plan_position_delta();
1803
-
1804
-    #else // !DELTA
1805
-
1806
-      planner.bed_level_matrix.set_to_identity();
1807
-      feedrate = homing_feedrate[Z_AXIS];
1808
-
1809
-      // Move down until the Z probe (or endstop?) is triggered
1810
-      float zPosition = -(Z_MAX_LENGTH + 10);
1811
-      line_to_z(zPosition);
1812
-      stepper.synchronize();
1813
-
1814
-      // Tell the planner where we ended up - Get this from the stepper handler
1815
-      zPosition = stepper.get_axis_position_mm(Z_AXIS);
1816
-      planner.set_position_mm(
1817
-        current_position[X_AXIS], current_position[Y_AXIS], zPosition,
1818
-        current_position[E_AXIS]
1819
-      );
1820
-
1821
-      // move up the retract distance
1822
-      zPosition += home_bump_mm(Z_AXIS);
1823
-      line_to_z(zPosition);
1824
-      stepper.synchronize();
1825
-      endstops.hit_on_purpose(); // clear endstop hit flags
1826
-
1827
-      // move back down slowly to find bed
1828
-      set_homing_bump_feedrate(Z_AXIS);
1829
-
1830
-      zPosition -= home_bump_mm(Z_AXIS) * 2;
1831
-      line_to_z(zPosition);
1832
-      stepper.synchronize();
1833
-      endstops.hit_on_purpose(); // clear endstop hit flags
1834
-
1835
-      // Get the current stepper position after bumping an endstop
1836
-      current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
1837
-      sync_plan_position();
1838
-
1839
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1840
-        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
1841
-      #endif
1842
-
1843
-    #endif // !DELTA
1844
-
1845
-    feedrate = old_feedrate;
1846
-  }
1847
-
1848
-  inline void do_blocking_move_to_xy(float x, float y) {
1849
-    do_blocking_move_to(x, y, current_position[Z_AXIS]);
1850
-  }
1851
-
1852
-  inline void do_blocking_move_to_x(float x) {
1853
-    do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
1854
-  }
1713
+#if HAS_BED_PROBE
1855 1714
 
1856 1715
   inline void raise_z_after_probing() {
1857 1716
     #if Z_RAISE_AFTER_PROBING > 0
@@ -1861,18 +1720,54 @@ static void setup_for_endstop_move() {
1861 1720
       do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
1862 1721
     #endif
1863 1722
   }
1723
+#endif
1864 1724
 
1865
-  static void clean_up_after_endstop_move() {
1725
+#if ENABLED(Z_PROBE_SLED)
1726
+
1727
+  #ifndef SLED_DOCKING_OFFSET
1728
+    #define SLED_DOCKING_OFFSET 0
1729
+  #endif
1730
+
1731
+  /**
1732
+   * Method to dock/undock a sled designed by Charles Bell.
1733
+   *
1734
+   * dock[in]     If true, move to MAX_X and engage the electromagnet
1735
+   * offset[in]   The additional distance to move to adjust docking location
1736
+   */
1737
+  static void dock_sled(bool dock, int offset = 0) {
1866 1738
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1867
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > endstops.not_homing()");
1739
+      if (DEBUGGING(LEVELING)) {
1740
+        SERIAL_ECHOPAIR("dock_sled(", dock);
1741
+        SERIAL_ECHOLNPGM(")");
1742
+      }
1868 1743
     #endif
1869
-    endstops.not_homing();
1870
-    feedrate = saved_feedrate;
1871
-    feedrate_multiplier = saved_feedrate_multiplier;
1872
-    refresh_cmd_timeout();
1744
+
1745
+    if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
1746
+      axis_unhomed_error(true);
1747
+      return;
1748
+    }
1749
+
1750
+    if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
1751
+
1752
+    float oldXpos = current_position[X_AXIS]; // save x position
1753
+    if (dock) {
1754
+      raise_z_after_probing(); // raise Z
1755
+      // Dock sled a bit closer to ensure proper capturing
1756
+      do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
1757
+      digitalWrite(SLED_PIN, LOW); // turn off magnet
1758
+    }
1759
+    else {
1760
+      float z_loc = current_position[Z_AXIS];
1761
+      if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1762
+      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
1763
+      digitalWrite(SLED_PIN, HIGH); // turn on magnet
1764
+    }
1765
+    do_blocking_move_to_x(oldXpos); // return to position before docking
1873 1766
   }
1874 1767
 
1875
-  #if HAS_BED_PROBE
1768
+#endif // Z_PROBE_SLED
1769
+
1770
+#if HAS_BED_PROBE
1876 1771
 
1877 1772
   static void deploy_z_probe() {
1878 1773
 
@@ -1882,7 +1777,11 @@ static void setup_for_endstop_move() {
1882 1777
 
1883 1778
     if (endstops.z_probe_enabled) return;
1884 1779
 
1885
-    #if HAS_Z_SERVO_ENDSTOP
1780
+    #if ENABLED(Z_PROBE_SLED)
1781
+
1782
+      dock_sled(false);
1783
+
1784
+    #elif HAS_Z_SERVO_ENDSTOP
1886 1785
 
1887 1786
       // Make room for Z Servo
1888 1787
       raise_z_for_servo(Z_RAISE_BEFORE_PROBING);
@@ -1964,101 +1863,284 @@ static void setup_for_endstop_move() {
1964 1863
           stop();
1965 1864
         }
1966 1865
 
1967
-    #endif // Z_PROBE_ALLEN_KEY
1866
+    #elif ENABLED(FIX_MOUNTED_PROBE)
1867
+
1868
+      // Nothing to be done. Just enable_z_probe below...
1869
+
1870
+    #endif
1871
+
1872
+    endstops.enable_z_probe();
1873
+  }
1874
+
1875
+  static void stow_z_probe() {
1876
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
1877
+      if (DEBUGGING(LEVELING)) DEBUG_POS("stow_z_probe", current_position);
1878
+    #endif
1879
+
1880
+    if (!endstops.z_probe_enabled) return;
1881
+
1882
+    #if ENABLED(Z_PROBE_SLED)
1883
+
1884
+      dock_sled(true);
1885
+
1886
+    #elif HAS_Z_SERVO_ENDSTOP
1887
+
1888
+      // Make room for the servo
1889
+      raise_z_for_servo(Z_RAISE_AFTER_PROBING);
1890
+
1891
+      // Change the Z servo angle
1892
+      STOW_Z_SERVO();
1893
+
1894
+    #elif ENABLED(Z_PROBE_ALLEN_KEY)
1895
+
1896
+      float old_feedrate = feedrate;
1897
+
1898
+      // Move up for safety
1899
+      feedrate = Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE;
1900
+
1901
+      #if Z_RAISE_AFTER_PROBING > 0
1902
+        destination[Z_AXIS] = current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING;
1903
+        prepare_move_to_destination_raw(); // this will also set_current_to_destination
1904
+      #endif
1905
+
1906
+      // Move to the start position to initiate retraction
1907
+      destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_X;
1908
+      destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Y;
1909
+      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Z;
1910
+      prepare_move_to_destination_raw();
1911
+
1912
+      // Move the nozzle down to push the Z probe into retracted position
1913
+      if (Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE)
1914
+        feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
1915
+      if (Z_PROBE_ALLEN_KEY_STOW_2_X != Z_PROBE_ALLEN_KEY_STOW_1_X)
1916
+        destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_X;
1917
+      if (Z_PROBE_ALLEN_KEY_STOW_2_Y != Z_PROBE_ALLEN_KEY_STOW_1_Y)
1918
+        destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Y;
1919
+      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Z;
1920
+      prepare_move_to_destination_raw();
1921
+
1922
+      // Move up for safety
1923
+      if (Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE)
1924
+        feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
1925
+      if (Z_PROBE_ALLEN_KEY_STOW_3_X != Z_PROBE_ALLEN_KEY_STOW_2_X)
1926
+        destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_X;
1927
+      if (Z_PROBE_ALLEN_KEY_STOW_3_Y != Z_PROBE_ALLEN_KEY_STOW_2_Y)
1928
+        destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Y;
1929
+      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Z;
1930
+      prepare_move_to_destination_raw();
1931
+
1932
+      // Home XY for safety
1933
+      feedrate = homing_feedrate[X_AXIS] / 2;
1934
+      destination[X_AXIS] = 0;
1935
+      destination[Y_AXIS] = 0;
1936
+      prepare_move_to_destination_raw(); // this will also set_current_to_destination
1937
+
1938
+      feedrate = old_feedrate;
1939
+
1940
+      stepper.synchronize();
1941
+
1942
+      #if ENABLED(Z_MIN_PROBE_ENDSTOP)
1943
+        bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING);
1944
+        if (!z_probe_endstop)
1945
+      #else
1946
+        bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
1947
+        if (!z_min_endstop)
1948
+      #endif
1949
+        {
1950
+          if (IsRunning()) {
1951
+            SERIAL_ERROR_START;
1952
+            SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
1953
+            LCD_ALERTMESSAGEPGM("Err: ZPROBE");
1954
+          }
1955
+          stop();
1956
+        }
1957
+
1958
+    #elif ENABLED(FIX_MOUNTED_PROBE)
1959
+
1960
+      // Nothing to do here. Just clear endstops.z_probe_enabled
1961
+
1962
+    #endif
1963
+
1964
+    endstops.enable_z_probe(false);
1965
+  }
1966
+
1967
+#endif // HAS_BED_PROBE
1968
+
1969
+#if ENABLED(AUTO_BED_LEVELING_FEATURE)
1970
+
1971
+  #if ENABLED(AUTO_BED_LEVELING_GRID)
1972
+
1973
+    #if DISABLED(DELTA)
1974
+
1975
+      static void set_bed_level_equation_lsq(double* plane_equation_coefficients) {
1976
+
1977
+        //planner.bed_level_matrix.debug("bed level before");
1978
+
1979
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
1980
+          planner.bed_level_matrix.set_to_identity();
1981
+          if (DEBUGGING(LEVELING)) {
1982
+            vector_3 uncorrected_position = planner.adjusted_position();
1983
+            DEBUG_POS(">>> set_bed_level_equation_lsq", uncorrected_position);
1984
+            DEBUG_POS(">>> set_bed_level_equation_lsq", current_position);
1985
+          }
1986
+        #endif
1987
+
1988
+        vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
1989
+        planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1990
+
1991
+        vector_3 corrected_position = planner.adjusted_position();
1992
+        current_position[X_AXIS] = corrected_position.x;
1993
+        current_position[Y_AXIS] = corrected_position.y;
1994
+        current_position[Z_AXIS] = corrected_position.z;
1995
+
1996
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
1997
+          if (DEBUGGING(LEVELING)) DEBUG_POS("<<< set_bed_level_equation_lsq", corrected_position);
1998
+        #endif
1999
+
2000
+        sync_plan_position();
2001
+      }
2002
+
2003
+    #endif // !DELTA
2004
+
2005
+  #else // !AUTO_BED_LEVELING_GRID
2006
+
2007
+    static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
2008
+
2009
+      planner.bed_level_matrix.set_to_identity();
2010
+
2011
+      vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
2012
+      vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
2013
+      vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
2014
+      vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal();
2015
+
2016
+      if (planeNormal.z < 0) {
2017
+        planeNormal.x = -planeNormal.x;
2018
+        planeNormal.y = -planeNormal.y;
2019
+        planeNormal.z = -planeNormal.z;
2020
+      }
2021
+
2022
+      planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
2023
+
2024
+      vector_3 corrected_position = planner.adjusted_position();
2025
+
2026
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2027
+        if (DEBUGGING(LEVELING)) {
2028
+          vector_3 uncorrected_position = corrected_position;
2029
+          DEBUG_POS("set_bed_level_equation_3pts", uncorrected_position);
2030
+        }
2031
+      #endif
2032
+
2033
+      current_position[X_AXIS] = corrected_position.x;
2034
+      current_position[Y_AXIS] = corrected_position.y;
2035
+      current_position[Z_AXIS] = corrected_position.z;
1968 2036
 
1969
-    #if ENABLED(FIX_MOUNTED_PROBE)
1970
-      // Nothing to be done. Just enable_z_probe below...
1971
-    #endif
2037
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2038
+        if (DEBUGGING(LEVELING)) DEBUG_POS("set_bed_level_equation_3pts", corrected_position);
2039
+      #endif
1972 2040
 
1973
-    endstops.enable_z_probe();
2041
+      sync_plan_position();
2042
+    }
1974 2043
 
1975
-  }
2044
+  #endif // !AUTO_BED_LEVELING_GRID
1976 2045
 
1977
-  static void stow_z_probe() {
1978
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1979
-      if (DEBUGGING(LEVELING)) DEBUG_POS("stow_z_probe", current_position);
1980
-    #endif
2046
+#endif // AUTO_BED_LEVELING_FEATURE
1981 2047
 
1982
-    if (!endstops.z_probe_enabled) return;
2048
+#if HAS_BED_PROBE
1983 2049
 
1984
-    #if HAS_Z_SERVO_ENDSTOP
2050
+  static void run_z_probe() {
1985 2051
 
1986
-      // Make room for the servo
1987
-      raise_z_for_servo(Z_RAISE_AFTER_PROBING);
2052
+    float old_feedrate = feedrate;
1988 2053
 
1989
-      // Change the Z servo angle
1990
-      STOW_Z_SERVO();
2054
+    /**
2055
+     * To prevent stepper_inactive_time from running out and
2056
+     * EXTRUDER_RUNOUT_PREVENT from extruding
2057
+     */
2058
+    refresh_cmd_timeout();
1991 2059
 
1992
-    #elif ENABLED(Z_PROBE_ALLEN_KEY)
2060
+    #if ENABLED(DELTA)
1993 2061
 
1994
-      float old_feedrate = feedrate;
2062
+      float start_z = current_position[Z_AXIS];
2063
+      long start_steps = stepper.position(Z_AXIS);
1995 2064
 
1996
-      // Move up for safety
1997
-      feedrate = Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE;
2065
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2066
+        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("run_z_probe (DELTA) 1");
2067
+      #endif
1998 2068
 
1999
-      #if Z_RAISE_AFTER_PROBING > 0
2000
-        destination[Z_AXIS] = current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING;
2001
-        prepare_move_to_destination_raw(); // this will also set_current_to_destination
2069
+      // move down slowly until you find the bed
2070
+      feedrate = homing_feedrate[Z_AXIS] / 4;
2071
+      destination[Z_AXIS] = -10;
2072
+      prepare_move_to_destination_raw(); // this will also set_current_to_destination
2073
+      stepper.synchronize();
2074
+      endstops.hit_on_purpose(); // clear endstop hit flags
2075
+
2076
+      /**
2077
+       * We have to let the planner know where we are right now as it
2078
+       * is not where we said to go.
2079
+       */
2080
+      long stop_steps = stepper.position(Z_AXIS);
2081
+      float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_mm[Z_AXIS];
2082
+      current_position[Z_AXIS] = mm;
2083
+
2084
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2085
+        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe (DELTA) 2", current_position);
2002 2086
       #endif
2003 2087
 
2004
-      // Move to the start position to initiate retraction
2005
-      destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_X;
2006
-      destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Y;
2007
-      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Z;
2008
-      prepare_move_to_destination_raw();
2088
+      sync_plan_position_delta();
2009 2089
 
2010
-      // Move the nozzle down to push the Z probe into retracted position
2011
-      if (Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE)
2012
-        feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
2013
-      if (Z_PROBE_ALLEN_KEY_STOW_2_X != Z_PROBE_ALLEN_KEY_STOW_1_X)
2014
-        destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_X;
2015
-      if (Z_PROBE_ALLEN_KEY_STOW_2_Y != Z_PROBE_ALLEN_KEY_STOW_1_Y)
2016
-        destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Y;
2017
-      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Z;
2018
-      prepare_move_to_destination_raw();
2090
+    #else // !DELTA
2019 2091
 
2020
-      // Move up for safety
2021
-      if (Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE)
2022
-        feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
2023
-      if (Z_PROBE_ALLEN_KEY_STOW_3_X != Z_PROBE_ALLEN_KEY_STOW_2_X)
2024
-        destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_X;
2025
-      if (Z_PROBE_ALLEN_KEY_STOW_3_Y != Z_PROBE_ALLEN_KEY_STOW_2_Y)
2026
-        destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Y;
2027
-      destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Z;
2028
-      prepare_move_to_destination_raw();
2092
+      #if ENABLED(AUTO_BED_LEVELING_FEATURE)
2093
+        planner.bed_level_matrix.set_to_identity();
2094
+      #endif
2029 2095
 
2030
-      // Home XY for safety
2031
-      feedrate = homing_feedrate[X_AXIS] / 2;
2032
-      destination[X_AXIS] = 0;
2033
-      destination[Y_AXIS] = 0;
2034
-      prepare_move_to_destination_raw(); // this will also set_current_to_destination
2096
+      feedrate = homing_feedrate[Z_AXIS];
2035 2097
 
2036
-      feedrate = old_feedrate;
2098
+      // Move down until the Z probe (or endstop?) is triggered
2099
+      float zPosition = -(Z_MAX_LENGTH + 10);
2100
+      line_to_z(zPosition);
2101
+      stepper.synchronize();
2102
+
2103
+      // Tell the planner where we ended up - Get this from the stepper handler
2104
+      zPosition = stepper.get_axis_position_mm(Z_AXIS);
2105
+      planner.set_position_mm(
2106
+        current_position[X_AXIS], current_position[Y_AXIS], zPosition,
2107
+        current_position[E_AXIS]
2108
+      );
2109
+
2110
+      // move up the retract distance
2111
+      zPosition += home_bump_mm(Z_AXIS);
2112
+      line_to_z(zPosition);
2113
+      stepper.synchronize();
2114
+      endstops.hit_on_purpose(); // clear endstop hit flags
2115
+
2116
+      // move back down slowly to find bed
2117
+      set_homing_bump_feedrate(Z_AXIS);
2037 2118
 
2119
+      zPosition -= home_bump_mm(Z_AXIS) * 2;
2120
+      line_to_z(zPosition);
2038 2121
       stepper.synchronize();
2122
+      endstops.hit_on_purpose(); // clear endstop hit flags
2039 2123
 
2040
-      #if ENABLED(Z_MIN_PROBE_ENDSTOP)
2041
-        bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING);
2042
-        if (!z_probe_endstop)
2043
-      #else
2044
-        bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
2045
-        if (!z_min_endstop)
2124
+      // Get the current stepper position after bumping an endstop
2125
+      current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
2126
+      sync_plan_position();
2127
+
2128
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2129
+        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
2046 2130
       #endif
2047
-        {
2048
-          if (IsRunning()) {
2049
-            SERIAL_ERROR_START;
2050
-            SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
2051
-            LCD_ALERTMESSAGEPGM("Err: ZPROBE");
2052
-          }
2053
-          stop();
2054
-        }
2055
-    #elif ENABLED(FIX_MOUNTED_PROBE)
2056
-      // Nothing to do here. Just clear endstops.z_probe_enabled
2057
-    #endif
2058 2131
 
2059
-    endstops.enable_z_probe(false);
2132
+    #endif // !DELTA
2133
+
2134
+    feedrate = old_feedrate;
2135
+  }
2136
+
2137
+#endif // HAS_BED_PROBE
2138
+
2139
+#if ENABLED(AUTO_BED_LEVELING_FEATURE)
2140
+
2141
+  inline void do_blocking_move_to_xy(float x, float y) {
2142
+    do_blocking_move_to(x, y, current_position[Z_AXIS]);
2060 2143
   }
2061
-  #endif // HAS_BED_PROBE
2062 2144
 
2063 2145
   enum ProbeAction {
2064 2146
     ProbeStay          = 0,
@@ -2226,55 +2308,6 @@ static void setup_for_endstop_move() {
2226 2308
   }
2227 2309
 #endif
2228 2310
 
2229
-#if ENABLED(Z_PROBE_SLED)
2230
-
2231
-  #ifndef SLED_DOCKING_OFFSET
2232
-    #define SLED_DOCKING_OFFSET 0
2233
-  #endif
2234
-
2235
-  /**
2236
-   * Method to dock/undock a sled designed by Charles Bell.
2237
-   *
2238
-   * dock[in]     If true, move to MAX_X and engage the electromagnet
2239
-   * offset[in]   The additional distance to move to adjust docking location
2240
-   */
2241
-  static void dock_sled(bool dock, int offset = 0) {
2242
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
2243
-      if (DEBUGGING(LEVELING)) {
2244
-        SERIAL_ECHOPAIR("dock_sled(", dock);
2245
-        SERIAL_ECHOLNPGM(")");
2246
-      }
2247
-    #endif
2248
-
2249
-    if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
2250
-      axis_unhomed_error(true);
2251
-      return;
2252
-    }
2253
-
2254
-    if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
2255
-
2256
-    float oldXpos = current_position[X_AXIS]; // save x position
2257
-    if (dock) {
2258
-      raise_z_after_probing(); // raise Z
2259
-      // Dock sled a bit closer to ensure proper capturing
2260
-      do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
2261
-      digitalWrite(SLED_PIN, LOW); // turn off magnet
2262
-    }
2263
-    else {
2264
-      float z_loc = current_position[Z_AXIS];
2265
-      if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
2266
-      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
2267
-      digitalWrite(SLED_PIN, HIGH); // turn on magnet
2268
-    }
2269
-    do_blocking_move_to_x(oldXpos); // return to position before docking
2270
-
2271
-    endstops.enable_z_probe(!dock); // logically disable docked probe
2272
-  }
2273
-
2274
-#endif // Z_PROBE_SLED
2275
-
2276
-
2277
-
2278 2311
 /**
2279 2312
  * Home an individual axis
2280 2313
  */
@@ -2303,24 +2336,13 @@ static void homeaxis(AxisEnum axis) {
2303 2336
     current_position[axis] = 0;
2304 2337
     sync_plan_position();
2305 2338
 
2306
-    #if ENABLED(Z_PROBE_SLED)
2307
-      #define _Z_DEPLOY           (dock_sled(false))
2308
-      #define _Z_STOW             (dock_sled(true))
2309
-    #elif ENABLED(AUTO_BED_LEVELING_FEATURE) && (HAS_Z_SERVO_ENDSTOP || ENABLED(FIX_MOUNTED_PROBE))
2310
-      #define _Z_DEPLOY           (deploy_z_probe())
2311
-      #define _Z_STOW             (stow_z_probe())
2312
-    #elif HAS_Z_SERVO_ENDSTOP
2313
-      #define _Z_DEPLOY           do{ raise_z_for_servo(Z_RAISE_BEFORE_PROBING); DEPLOY_Z_SERVO(); endstops.z_probe_enabled = true; }while(0)
2314
-      #define _Z_STOW             do{ raise_z_for_servo(Z_RAISE_AFTER_PROBING); STOW_Z_SERVO(); endstops.z_probe_enabled = false; }while(0)
2315
-    #endif
2316
-
2317 2339
     // Homing Z towards the bed? Deploy the Z probe or endstop.
2318
-    #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE)
2340
+    #if HAS_BED_PROBE
2319 2341
       if (axis == Z_AXIS && axis_home_dir < 0) {
2320 2342
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2321
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_DEPLOY));
2343
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > deploy_z_probe()");
2322 2344
         #endif
2323
-        _Z_DEPLOY;
2345
+        deploy_z_probe();
2324 2346
       }
2325 2347
     #endif
2326 2348
 
@@ -2438,12 +2460,12 @@ static void homeaxis(AxisEnum axis) {
2438 2460
     axis_homed[axis] = true;
2439 2461
 
2440 2462
     // Put away the Z probe
2441
-    #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE)
2463
+    #if HAS_BED_PROBE
2442 2464
       if (axis == Z_AXIS && axis_home_dir < 0) {
2443 2465
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2444
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_STOW));
2466
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > stow_z_probe()");
2445 2467
         #endif
2446
-        _Z_STOW;
2468
+        stow_z_probe();
2447 2469
       }
2448 2470
     #endif
2449 2471
 
@@ -3465,9 +3487,7 @@ inline void gcode_G28() {
3465 3487
       #endif // !DELTA
3466 3488
     }
3467 3489
 
3468
-    #if ENABLED(Z_PROBE_SLED)
3469
-      dock_sled(false); // engage (un-dock) the Z probe
3470
-    #elif ENABLED(FIX_MOUNTED_PROBE) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_ALLEN_KEY) || (ENABLED(DELTA) && HAS_Z_SERVO_ENDSTOP)
3490
+    #if HAS_BED_PROBE
3471 3491
       deploy_z_probe();
3472 3492
     #endif
3473 3493
 
@@ -3718,14 +3738,7 @@ inline void gcode_G28() {
3718 3738
 
3719 3739
     #endif // !AUTO_BED_LEVELING_GRID
3720 3740
 
3721
-    #if ENABLED(DELTA)
3722
-      // Allen Key Probe for Delta
3723
-      #if ENABLED(Z_PROBE_ALLEN_KEY) || HAS_Z_SERVO_ENDSTOP
3724
-        stow_z_probe();
3725
-      #else
3726
-        raise_z_after_probing(); // for non Allen Key probes, such as simple mechanical probe
3727
-      #endif
3728
-    #else // !DELTA
3741
+    #if DISABLED(DELTA)
3729 3742
       if (verbose_level > 0)
3730 3743
         planner.bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
3731 3744
 
@@ -3785,7 +3798,7 @@ inline void gcode_G28() {
3785 3798
           #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)
3786 3799
              + Z_RAISE_AFTER_PROBING
3787 3800
           #endif
3788
-          ;
3801
+        ;
3789 3802
         // current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
3790 3803
         sync_plan_position();
3791 3804
 
@@ -3793,19 +3806,16 @@ inline void gcode_G28() {
3793 3806
           if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position);
3794 3807
         #endif
3795 3808
       }
3796
-
3797
-      // Sled assembly for Cartesian bots
3798
-      #if ENABLED(Z_PROBE_SLED)
3799
-        dock_sled(true); // dock the sled
3800
-      #elif !HAS_Z_SERVO_ENDSTOP && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED)
3801
-        // Raise Z axis for non-delta and non servo based probes
3802
-        raise_z_after_probing();
3803
-      #endif
3804
-
3805 3809
     #endif // !DELTA
3806 3810
 
3807
-    #if ENABLED(MECHANICAL_PROBE)
3811
+    #if DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED) && !HAS_Z_SERVO_ENDSTOP
3812
+      raise_z_after_probing();
3813
+    #endif
3814
+
3815
+    #if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(MECHANICAL_PROBE)
3808 3816
       stow_z_probe();
3817
+    #else
3818
+      endstops.enable_z_probe(false);
3809 3819
     #endif
3810 3820
 
3811 3821
     #ifdef Z_PROBE_END_SCRIPT
@@ -3816,9 +3826,6 @@ inline void gcode_G28() {
3816 3826
         }
3817 3827
       #endif
3818 3828
       enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
3819
-      #if HAS_BED_PROBE
3820
-        endstops.enable_z_probe(false);
3821
-      #endif
3822 3829
       stepper.synchronize();
3823 3830
     #endif
3824 3831
 
@@ -3835,38 +3842,40 @@ inline void gcode_G28() {
3835 3842
     KEEPALIVE_STATE(IN_HANDLER);
3836 3843
   }
3837 3844
 
3838
-  #if DISABLED(Z_PROBE_SLED) // could be avoided
3845
+#endif //AUTO_BED_LEVELING_FEATURE
3839 3846
 
3840
-    /**
3841
-     * G30: Do a single Z probe at the current XY
3842
-     */
3843
-    inline void gcode_G30() {
3844
-      deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed here.
3847
+#if HAS_BED_PROBE
3845 3848
 
3846
-      stepper.synchronize();
3847
-      // TODO: clear the leveling matrix or the planner will be set incorrectly
3848
-      setup_for_endstop_move(); // Too late. Must be done before deploying.
3849
+  /**
3850
+   * G30: Do a single Z probe at the current XY
3851
+   */
3852
+  inline void gcode_G30() {
3849 3853
 
3850
-      run_z_probe();
3854
+    setup_for_endstop_move();
3851 3855
 
3852
-      SERIAL_PROTOCOLPGM("Bed X: ");
3853
-      SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
3854
-      SERIAL_PROTOCOLPGM(" Y: ");
3855
-      SERIAL_PROTOCOL(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
3856
-      SERIAL_PROTOCOLPGM(" Z: ");
3857
-      SERIAL_PROTOCOL(current_position[Z_AXIS] + 0.0001);
3858
-      SERIAL_EOL;
3856
+    deploy_z_probe();
3859 3857
 
3860
-      clean_up_after_endstop_move(); // Too early. must be done after the stowing.
3858
+    stepper.synchronize();
3861 3859
 
3862
-      stow_z_probe(); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed here.
3860
+    // TODO: clear the leveling matrix or the planner will be set incorrectly
3861
+    run_z_probe(); // clears the ABL non-delta matrix only
3863 3862
 
3864
-      report_current_position();
3865
-    }
3863
+    SERIAL_PROTOCOLPGM("Bed X: ");
3864
+    SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
3865
+    SERIAL_PROTOCOLPGM(" Y: ");
3866
+    SERIAL_PROTOCOL(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
3867
+    SERIAL_PROTOCOLPGM(" Z: ");
3868
+    SERIAL_PROTOCOL(current_position[Z_AXIS] + 0.0001);
3869
+    SERIAL_EOL;
3866 3870
 
3867
-  #endif //!Z_PROBE_SLED
3871
+    stow_z_probe();
3868 3872
 
3869
-#endif //AUTO_BED_LEVELING_FEATURE
3873
+    clean_up_after_endstop_move();
3874
+
3875
+    report_current_position();
3876
+  }
3877
+
3878
+#endif // HAS_BED_PROBE
3870 3879
 
3871 3880
 /**
3872 3881
  * G92: Set current position to given X Y Z E
@@ -6872,24 +6881,24 @@ void process_next_command() {
6872 6881
           break;
6873 6882
       #endif
6874 6883
 
6875
-      #if ENABLED(AUTO_BED_LEVELING_FEATURE)
6876
-
6877
-        #if DISABLED(Z_PROBE_SLED)
6884
+      #if HAS_BED_PROBE
6878 6885
 
6879
-          case 30: // G30 Single Z probe
6880
-            gcode_G30();
6881
-            break;
6886
+        case 30: // G30 Single Z probe
6887
+          gcode_G30();
6888
+          break;
6882 6889
 
6883
-        #else // Z_PROBE_SLED
6890
+        #if ENABLED(Z_PROBE_SLED)
6884 6891
 
6885 6892
             case 31: // G31: dock the sled
6893
+              stow_z_probe();
6894
+              break;
6886 6895
             case 32: // G32: undock the sled
6887
-              dock_sled(codenum == 31);
6896
+              deploy_z_probe();
6888 6897
               break;
6889 6898
 
6890 6899
         #endif // Z_PROBE_SLED
6891 6900
 
6892
-      #endif // AUTO_BED_LEVELING_FEATURE
6901
+      #endif // HAS_BED_PROBE
6893 6902
 
6894 6903
       case 90: // G90
6895 6904
         relative_mode = false;

Loading…
Cancel
Save