浏览代码

Merge pull request #8575 from thinkyhead/kuru_to_upstream

[2.0.x] Make MBL work more like PROBE_MANUALLY
Scott Lahteine 7 年前
父节点
当前提交
47099af3ec
没有帐户链接到提交者的电子邮件
共有 4 个文件被更改,包括 69 次插入129 次删除
  1. 5
    4
      Marlin/src/feature/bedlevel/bedlevel.cpp
  2. 17
    18
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  3. 44
    106
      Marlin/src/lcd/ultralcd.cpp
  4. 3
    1
      Marlin/src/lcd/ultralcd.h

+ 5
- 4
Marlin/src/feature/bedlevel/bedlevel.cpp 查看文件

@@ -36,9 +36,10 @@
36 36
 
37 37
 #if ENABLED(PROBE_MANUALLY)
38 38
   bool g29_in_progress = false;
39
-  #if ENABLED(LCD_BED_LEVELING)
40
-    #include "../../lcd/ultralcd.h"
41
-  #endif
39
+#endif
40
+
41
+#if ENABLED(LCD_BED_LEVELING)
42
+  #include "../../lcd/ultralcd.h"
42 43
 #endif
43 44
 
44 45
 #if ENABLED(G26_MESH_VALIDATION)
@@ -273,7 +274,7 @@ void reset_bed_level() {
273 274
     current_position[X_AXIS] = rx;
274 275
     current_position[Y_AXIS] = ry;
275 276
 
276
-    #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
277
+    #if ENABLED(LCD_BED_LEVELING)
277 278
       lcd_wait_for_move = false;
278 279
     #endif
279 280
   }

+ 17
- 18
Marlin/src/gcode/bedlevel/mbl/G29.cpp 查看文件

@@ -41,18 +41,6 @@
41 41
 // Save 130 bytes with non-duplication of PSTR
42 42
 void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
43 43
 
44
-void mesh_probing_done() {
45
-  mbl.has_mesh = true;
46
-  gcode.home_all_axes();
47
-  set_bed_leveling_enabled(true);
48
-  #if ENABLED(MESH_G28_REST_ORIGIN)
49
-    current_position[Z_AXIS] = Z_MIN_POS;
50
-    set_destination_from_current();
51
-    buffer_line_to_destination(homing_feedrate(Z_AXIS));
52
-    stepper.synchronize();
53
-  #endif
54
-}
55
-
56 44
 /**
57 45
  * G29: Mesh-based Z probe, probes a grid and produces a
58 46
  *      mesh to compensate for variable bed height
@@ -102,7 +90,7 @@ void GcodeSuite::G29() {
102 90
     case MeshStart:
103 91
       mbl.reset();
104 92
       mbl_probe_index = 0;
105
-      enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
93
+      enqueue_and_echo_commands_P(lcd_wait_for_move ? PSTR("G29 S2") : PSTR("G28\nG29 S2"));
106 94
       break;
107 95
 
108 96
     case MeshNext:
@@ -148,7 +136,15 @@ void GcodeSuite::G29() {
148 136
         SERIAL_PROTOCOLLNPGM("Mesh probing done.");
149 137
         BUZZ(100, 659);
150 138
         BUZZ(100, 698);
151
-        mesh_probing_done();
139
+        mbl.has_mesh = true;
140
+        gcode.home_all_axes();
141
+        set_bed_leveling_enabled(true);
142
+        #if ENABLED(MESH_G28_REST_ORIGIN)
143
+          current_position[Z_AXIS] = Z_MIN_POS;
144
+          set_destination_from_current();
145
+          buffer_line_to_destination(homing_feedrate(Z_AXIS));
146
+          stepper.synchronize();
147
+        #endif
152 148
       }
153 149
       break;
154 150
 
@@ -177,9 +173,8 @@ void GcodeSuite::G29() {
177 173
         return;
178 174
       }
179 175
 
180
-      if (parser.seenval('Z')) {
176
+      if (parser.seenval('Z'))
181 177
         mbl.z_values[px][py] = parser.value_linear_units();
182
-      }
183 178
       else {
184 179
         SERIAL_CHAR('Z'); echo_not_entered();
185 180
         return;
@@ -187,9 +182,8 @@ void GcodeSuite::G29() {
187 182
       break;
188 183
 
189 184
     case MeshSetZOffset:
190
-      if (parser.seenval('Z')) {
185
+      if (parser.seenval('Z'))
191 186
         mbl.z_offset = parser.value_linear_units();
192
-      }
193 187
       else {
194 188
         SERIAL_CHAR('Z'); echo_not_entered();
195 189
         return;
@@ -202,6 +196,11 @@ void GcodeSuite::G29() {
202 196
 
203 197
   } // switch(state)
204 198
 
199
+  if (state == MeshStart || state == MeshNext) {
200
+    SERIAL_PROTOCOLPAIR("MBL G29 point ", min(mbl_probe_index, GRID_MAX_POINTS));
201
+    SERIAL_PROTOCOLLNPAIR(" of ", int(GRID_MAX_POINTS));
202
+  }
203
+
205 204
   report_current_position();
206 205
 }
207 206
 

+ 44
- 106
Marlin/src/lcd/ultralcd.cpp 查看文件

@@ -215,7 +215,6 @@ uint16_t max_display_update_time = 0;
215 215
 
216 216
   #if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
217 217
     #include "../feature/bedlevel/mbl/mesh_bed_leveling.h"
218
-    extern void mesh_probing_done();
219 218
   #endif
220 219
 
221 220
   ////////////////////////////////////////////
@@ -1742,58 +1741,33 @@ void kill_screen(const char* lcd_msg) {
1742 1741
       #endif
1743 1742
     );
1744 1743
 
1744
+    bool lcd_wait_for_move;
1745
+
1746
+    //
1747
+    // Bed leveling is done. Wait for G29 to complete.
1748
+    // A flag is used so that this can release control
1749
+    // and allow the command queue to be processed.
1750
+    //
1751
+    // When G29 finishes the last move:
1752
+    // - Raise Z to the "manual probe height"
1753
+    // - Don't return until done.
1745 1754
     //
1746
-    // Raise Z to the "manual probe height"
1747
-    // Don't return until done.
1748 1755
     // ** This blocks the command queue! **
1749 1756
     //
1750
-    void _lcd_after_probing() {
1751
-      #if MANUAL_PROBE_HEIGHT > 0
1752
-        line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1753
-      #endif
1754
-      // Display "Done" screen and wait for moves to complete
1755
-      #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1756
-        lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1757
-      #endif
1758
-      lcd_goto_previous_menu();
1759
-      lcd_completion_feedback();
1760
-      defer_return_to_status = false;
1761
-      //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
1762
-    }
1763
-
1764
-    #if ENABLED(MESH_BED_LEVELING)
1765
-
1766
-      // Utility to go to the next mesh point
1767
-      inline void _manual_probe_goto_xy(const float &rx, const float &ry) {
1768
-        #if MANUAL_PROBE_HEIGHT > 0
1769
-          const float prev_z = current_position[Z_AXIS];
1757
+    void _lcd_level_bed_done() {
1758
+      if (!lcd_wait_for_move) {
1759
+        #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
1760
+          // Display "Done" screen and wait for moves to complete
1770 1761
           line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1762
+          lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1771 1763
         #endif
1772
-        current_position[X_AXIS] = rx;
1773
-        current_position[Y_AXIS] = ry;
1774
-        planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1775
-        #if MANUAL_PROBE_HEIGHT > 0
1776
-          line_to_z(prev_z);
1777
-        #endif
1778
-        lcd_synchronize();
1779
-      }
1780
-
1781
-    #elif ENABLED(PROBE_MANUALLY)
1782
-
1783
-      bool lcd_wait_for_move;
1784
-
1785
-      //
1786
-      // Bed leveling is done. Wait for G29 to complete.
1787
-      // A flag is used so that this can release control
1788
-      // and allow the command queue to be processed.
1789
-      //
1790
-      void _lcd_level_bed_done() {
1791
-        if (!lcd_wait_for_move) _lcd_after_probing();
1792
-        if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
1793
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1764
+        lcd_goto_previous_menu();
1765
+        lcd_completion_feedback();
1766
+        defer_return_to_status = false;
1794 1767
       }
1795
-
1796
-    #endif
1768
+      if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
1769
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1770
+    }
1797 1771
 
1798 1772
     void _lcd_level_goto_next_point();
1799 1773
 
@@ -1806,46 +1780,24 @@ void kill_screen(const char* lcd_msg) {
1806 1780
       if (lcd_clicked) {
1807 1781
 
1808 1782
         //
1809
-        // Save the current Z position
1783
+        // Save the current Z position and move
1810 1784
         //
1811 1785
 
1812
-        #if ENABLED(MESH_BED_LEVELING)
1813
-
1814
-          //
1815
-          // MBL records the position but doesn't move to the next one
1816
-          //
1817
-
1818
-          mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
1819
-
1820
-        #endif
1821
-
1822 1786
         // If done...
1823 1787
         if (++manual_probe_index >= total_probe_points) {
1824
-
1788
+          //
1789
+          // The last G29 records the point and enables bed leveling
1790
+          //
1791
+          lcd_wait_for_move = true;
1792
+          lcd_goto_screen(_lcd_level_bed_done);
1825 1793
           #if ENABLED(PROBE_MANUALLY)
1826
-
1827
-            //
1828
-            // The last G29 will record and enable but not move.
1829
-            //
1830
-            lcd_wait_for_move = true;
1831 1794
             enqueue_and_echo_commands_P(PSTR("G29 V1"));
1832
-            lcd_goto_screen(_lcd_level_bed_done);
1833
-
1834 1795
           #elif ENABLED(MESH_BED_LEVELING)
1835
-
1836
-            _lcd_after_probing();
1837
-
1838
-            mbl.has_mesh = true;
1839
-            mesh_probing_done();
1840
-
1796
+            enqueue_and_echo_commands_P(PSTR("G29 S2"));
1841 1797
           #endif
1842
-
1843 1798
         }
1844
-        else {
1845
-          // MESH_BED_LEVELING: Z already stored, just move
1846
-          //    PROBE_MANUALLY: Send G29 to record Z, then move
1799
+        else
1847 1800
           _lcd_level_goto_next_point();
1848
-        }
1849 1801
 
1850 1802
         return;
1851 1803
       }
@@ -1873,7 +1825,6 @@ void kill_screen(const char* lcd_msg) {
1873 1825
     /**
1874 1826
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
1875 1827
      */
1876
-
1877 1828
     void _lcd_level_bed_moving() {
1878 1829
       if (lcdDrawUpdate) {
1879 1830
         char msg[10];
@@ -1881,36 +1832,22 @@ void kill_screen(const char* lcd_msg) {
1881 1832
         lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
1882 1833
       }
1883 1834
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
1884
-      #if ENABLED(PROBE_MANUALLY)
1885
-        if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
1886
-      #endif
1835
+      if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
1887 1836
     }
1888 1837
 
1889 1838
     /**
1890 1839
      * Step 5: Initiate a move to the next point
1891 1840
      */
1892 1841
     void _lcd_level_goto_next_point() {
1893
-
1894 1842
       // Set the menu to display ahead of blocking call
1895 1843
       lcd_goto_screen(_lcd_level_bed_moving);
1896 1844
 
1897
-      #if ENABLED(MESH_BED_LEVELING)
1898
-
1899
-        int8_t px, py;
1900
-        mbl.zigzag(manual_probe_index, px, py);
1901
-
1902
-        // Controls the loop until the move is done
1903
-        _manual_probe_goto_xy(mbl.index_to_xpos[px], mbl.index_to_ypos[py]);
1904
-
1905
-        // After the blocking function returns, change menus
1906
-        lcd_goto_screen(_lcd_level_bed_get_z);
1907
-
1908
-      #elif ENABLED(PROBE_MANUALLY)
1909
-
1910
-        // G29 Records Z, moves, and signals when it pauses
1911
-        lcd_wait_for_move = true;
1845
+      // G29 Records Z, moves, and signals when it pauses
1846
+      lcd_wait_for_move = true;
1847
+      #if ENABLED(PROBE_MANUALLY)
1912 1848
         enqueue_and_echo_commands_P(PSTR("G29 V1"));
1913
-
1849
+      #elif ENABLED(MESH_BED_LEVELING)
1850
+        enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
1914 1851
       #endif
1915 1852
     }
1916 1853
 
@@ -1976,11 +1913,15 @@ void kill_screen(const char* lcd_msg) {
1976 1913
       START_MENU();
1977 1914
       MENU_BACK(MSG_PREPARE);
1978 1915
 
1979
-      if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1980
-        MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1981
-      else if (leveling_is_valid()) {
1982
-        MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
1983
-      }
1916
+      #if DISABLED(MESH_BED_LEVELING)
1917
+        if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1918
+          MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1919
+        else
1920
+      #endif
1921
+        if (leveling_is_valid()) {
1922
+          new_level_state = planner.leveling_active;
1923
+          MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
1924
+        }
1984 1925
 
1985 1926
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1986 1927
         MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
@@ -2016,9 +1957,6 @@ void kill_screen(const char* lcd_msg) {
2016 1957
 
2017 1958
     void _lcd_goto_bed_leveling() {
2018 1959
       lcd_goto_screen(lcd_bed_leveling);
2019
-      #if ENABLED(LCD_BED_LEVELING)
2020
-        new_level_state = planner.leveling_active;
2021
-      #endif
2022 1960
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2023 1961
         new_z_fade_height = planner.z_fade_height;
2024 1962
       #endif

+ 3
- 1
Marlin/src/lcd/ultralcd.h 查看文件

@@ -40,8 +40,10 @@
40 40
 
41 41
   extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
42 42
 
43
-  #if ENABLED(LCD_BED_LEVELING) && ENABLED(PROBE_MANUALLY)
43
+  #if ENABLED(LCD_BED_LEVELING)
44 44
     extern bool lcd_wait_for_move;
45
+  #else
46
+    constexpr bool lcd_wait_for_move = false;
45 47
   #endif
46 48
 
47 49
   int16_t lcd_strlen(const char* s);

正在加载...
取消
保存