소스 검색

Make MBL work more like PROBE_MANUALLY

Scott Lahteine 6 년 전
부모
커밋
915c4b9ce2
2개의 변경된 파일71개의 추가작업 그리고 128개의 파일을 삭제
  1. 27
    20
      Marlin/Marlin_main.cpp
  2. 44
    108
      Marlin/ultralcd.cpp

+ 27
- 20
Marlin/Marlin_main.cpp 파일 보기

@@ -4260,8 +4260,10 @@ void home_all_axes() { gcode_G28(true); }
4260 4260
 
4261 4261
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
4262 4262
 
4263
-  #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4263
+  #if ENABLED(LCD_BED_LEVELING)
4264 4264
     extern bool lcd_wait_for_move;
4265
+  #else
4266
+    constexpr bool lcd_wait_for_move = false;
4265 4267
   #endif
4266 4268
 
4267 4269
   inline void _manual_goto_xy(const float &rx, const float &ry) {
@@ -4277,7 +4279,7 @@ void home_all_axes() { gcode_G28(true); }
4277 4279
     current_position[X_AXIS] = rx;
4278 4280
     current_position[Y_AXIS] = ry;
4279 4281
 
4280
-    #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4282
+    #if ENABLED(LCD_BED_LEVELING)
4281 4283
       lcd_wait_for_move = false;
4282 4284
     #endif
4283 4285
   }
@@ -4298,18 +4300,6 @@ void home_all_axes() { gcode_G28(true); }
4298 4300
     );
4299 4301
   }
4300 4302
 
4301
-  void mesh_probing_done() {
4302
-    mbl.has_mesh = true;
4303
-    home_all_axes();
4304
-    set_bed_leveling_enabled(true);
4305
-    #if ENABLED(MESH_G28_REST_ORIGIN)
4306
-      current_position[Z_AXIS] = Z_MIN_POS;
4307
-      set_destination_from_current();
4308
-      buffer_line_to_destination(homing_feedrate(Z_AXIS));
4309
-      stepper.synchronize();
4310
-    #endif
4311
-  }
4312
-
4313 4303
   /**
4314 4304
    * G29: Mesh-based Z probe, probes a grid and produces a
4315 4305
    *      mesh to compensate for variable bed height
@@ -4359,7 +4349,7 @@ void home_all_axes() { gcode_G28(true); }
4359 4349
       case MeshStart:
4360 4350
         mbl.reset();
4361 4351
         mbl_probe_index = 0;
4362
-        enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
4352
+        enqueue_and_echo_commands_P(lcd_wait_for_move ? PSTR("G29 S2") : PSTR("G28\nG29 S2"));
4363 4353
         break;
4364 4354
 
4365 4355
       case MeshNext:
@@ -4405,7 +4395,21 @@ void home_all_axes() { gcode_G28(true); }
4405 4395
           SERIAL_PROTOCOLLNPGM("Mesh probing done.");
4406 4396
           BUZZ(100, 659);
4407 4397
           BUZZ(100, 698);
4408
-          mesh_probing_done();
4398
+          mbl.has_mesh = true;
4399
+
4400
+          home_all_axes();
4401
+          set_bed_leveling_enabled(true);
4402
+
4403
+          #if ENABLED(MESH_G28_REST_ORIGIN)
4404
+            current_position[Z_AXIS] = Z_MIN_POS;
4405
+            set_destination_from_current();
4406
+            buffer_line_to_destination(homing_feedrate(Z_AXIS));
4407
+            stepper.synchronize();
4408
+          #endif
4409
+
4410
+          #if ENABLED(LCD_BED_LEVELING)
4411
+            lcd_wait_for_move = false;
4412
+          #endif
4409 4413
         }
4410 4414
         break;
4411 4415
 
@@ -4434,9 +4438,8 @@ void home_all_axes() { gcode_G28(true); }
4434 4438
           return;
4435 4439
         }
4436 4440
 
4437
-        if (parser.seenval('Z')) {
4441
+        if (parser.seenval('Z'))
4438 4442
           mbl.z_values[px][py] = parser.value_linear_units();
4439
-        }
4440 4443
         else {
4441 4444
           SERIAL_CHAR('Z'); echo_not_entered();
4442 4445
           return;
@@ -4444,9 +4447,8 @@ void home_all_axes() { gcode_G28(true); }
4444 4447
         break;
4445 4448
 
4446 4449
       case MeshSetZOffset:
4447
-        if (parser.seenval('Z')) {
4450
+        if (parser.seenval('Z'))
4448 4451
           mbl.z_offset = parser.value_linear_units();
4449
-        }
4450 4452
         else {
4451 4453
           SERIAL_CHAR('Z'); echo_not_entered();
4452 4454
           return;
@@ -4459,6 +4461,11 @@ void home_all_axes() { gcode_G28(true); }
4459 4461
 
4460 4462
     } // switch(state)
4461 4463
 
4464
+    if (state == MeshStart || state == MeshNext) {
4465
+      SERIAL_PROTOCOLPAIR("MBL G29 point ", min(mbl_probe_index, GRID_MAX_POINTS));
4466
+      SERIAL_PROTOCOLLNPAIR(" of ", int(GRID_MAX_POINTS));
4467
+    }
4468
+
4462 4469
     report_current_position();
4463 4470
   }
4464 4471
 

+ 44
- 108
Marlin/ultralcd.cpp 파일 보기

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

Loading…
취소
저장