Browse Source

Make MBL work more like PROBE_MANUALLY

Scott Lahteine 7 years ago
parent
commit
915c4b9ce2
2 changed files with 71 additions and 128 deletions
  1. 27
    20
      Marlin/Marlin_main.cpp
  2. 44
    108
      Marlin/ultralcd.cpp

+ 27
- 20
Marlin/Marlin_main.cpp View File

4260
 
4260
 
4261
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
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
     extern bool lcd_wait_for_move;
4264
     extern bool lcd_wait_for_move;
4265
+  #else
4266
+    constexpr bool lcd_wait_for_move = false;
4265
   #endif
4267
   #endif
4266
 
4268
 
4267
   inline void _manual_goto_xy(const float &rx, const float &ry) {
4269
   inline void _manual_goto_xy(const float &rx, const float &ry) {
4277
     current_position[X_AXIS] = rx;
4279
     current_position[X_AXIS] = rx;
4278
     current_position[Y_AXIS] = ry;
4280
     current_position[Y_AXIS] = ry;
4279
 
4281
 
4280
-    #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4282
+    #if ENABLED(LCD_BED_LEVELING)
4281
       lcd_wait_for_move = false;
4283
       lcd_wait_for_move = false;
4282
     #endif
4284
     #endif
4283
   }
4285
   }
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
    * G29: Mesh-based Z probe, probes a grid and produces a
4304
    * G29: Mesh-based Z probe, probes a grid and produces a
4315
    *      mesh to compensate for variable bed height
4305
    *      mesh to compensate for variable bed height
4359
       case MeshStart:
4349
       case MeshStart:
4360
         mbl.reset();
4350
         mbl.reset();
4361
         mbl_probe_index = 0;
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
         break;
4353
         break;
4364
 
4354
 
4365
       case MeshNext:
4355
       case MeshNext:
4405
           SERIAL_PROTOCOLLNPGM("Mesh probing done.");
4395
           SERIAL_PROTOCOLLNPGM("Mesh probing done.");
4406
           BUZZ(100, 659);
4396
           BUZZ(100, 659);
4407
           BUZZ(100, 698);
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
         break;
4414
         break;
4411
 
4415
 
4434
           return;
4438
           return;
4435
         }
4439
         }
4436
 
4440
 
4437
-        if (parser.seenval('Z')) {
4441
+        if (parser.seenval('Z'))
4438
           mbl.z_values[px][py] = parser.value_linear_units();
4442
           mbl.z_values[px][py] = parser.value_linear_units();
4439
-        }
4440
         else {
4443
         else {
4441
           SERIAL_CHAR('Z'); echo_not_entered();
4444
           SERIAL_CHAR('Z'); echo_not_entered();
4442
           return;
4445
           return;
4444
         break;
4447
         break;
4445
 
4448
 
4446
       case MeshSetZOffset:
4449
       case MeshSetZOffset:
4447
-        if (parser.seenval('Z')) {
4450
+        if (parser.seenval('Z'))
4448
           mbl.z_offset = parser.value_linear_units();
4451
           mbl.z_offset = parser.value_linear_units();
4449
-        }
4450
         else {
4452
         else {
4451
           SERIAL_CHAR('Z'); echo_not_entered();
4453
           SERIAL_CHAR('Z'); echo_not_entered();
4452
           return;
4454
           return;
4459
 
4461
 
4460
     } // switch(state)
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
     report_current_position();
4469
     report_current_position();
4463
   }
4470
   }
4464
 
4471
 

+ 44
- 108
Marlin/ultralcd.cpp View File

54
   #include "planner.h"
54
   #include "planner.h"
55
 #elif ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
55
 #elif ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
56
   #include "mesh_bed_leveling.h"
56
   #include "mesh_bed_leveling.h"
57
-  extern void mesh_probing_done();
58
 #endif
57
 #endif
59
 
58
 
60
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
59
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
557
     static bool no_reentry = false;
556
     static bool no_reentry = false;
558
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
557
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
559
     if (no_reentry) return;
558
     if (no_reentry) return;
560
-
561
     // Make this the current handler till all moves are done
559
     // Make this the current handler till all moves are done
562
     no_reentry = true;
560
     no_reentry = true;
563
     screenFunc_t old_screen = currentScreen;
561
     screenFunc_t old_screen = currentScreen;
1745
       #endif
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
     // ** This blocks the command queue! **
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
           line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1763
           line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1764
+          lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1774
         #endif
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
     void _lcd_level_goto_next_point();
1774
     void _lcd_level_goto_next_point();
1802
 
1775
 
1809
       if (lcd_clicked) {
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
         // If done...
1788
         // If done...
1826
         if (++manual_probe_index >= total_probe_points) {
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
           #if ENABLED(PROBE_MANUALLY)
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
             enqueue_and_echo_commands_P(PSTR("G29 V1"));
1796
             enqueue_and_echo_commands_P(PSTR("G29 V1"));
1835
-            lcd_goto_screen(_lcd_level_bed_done);
1836
-
1837
           #elif ENABLED(MESH_BED_LEVELING)
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
           #endif
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
           _lcd_level_goto_next_point();
1802
           _lcd_level_goto_next_point();
1851
-        }
1852
 
1803
 
1853
         return;
1804
         return;
1854
       }
1805
       }
1884
         lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
1835
         lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
1885
       }
1836
       }
1886
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
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
      * Step 5: Initiate a move to the next point
1842
      * Step 5: Initiate a move to the next point
1894
      */
1843
      */
1895
     void _lcd_level_goto_next_point() {
1844
     void _lcd_level_goto_next_point() {
1896
-
1897
       // Set the menu to display ahead of blocking call
1845
       // Set the menu to display ahead of blocking call
1898
       lcd_goto_screen(_lcd_level_bed_moving);
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
         enqueue_and_echo_commands_P(PSTR("G29 V1"));
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
       #endif
1854
       #endif
1921
     }
1855
     }
1922
 
1856
 
1982
       START_MENU();
1916
       START_MENU();
1983
       MENU_BACK(MSG_PREPARE);
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
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1929
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1991
         MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
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
 
1960
 
2022
     void _lcd_goto_bed_leveling() {
1961
     void _lcd_goto_bed_leveling() {
2023
       lcd_goto_screen(lcd_bed_leveling);
1962
       lcd_goto_screen(lcd_bed_leveling);
2024
-      #if ENABLED(LCD_BED_LEVELING)
2025
-        new_level_state = planner.leveling_active;
2026
-      #endif
2027
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1963
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2028
         new_z_fade_height = planner.z_fade_height;
1964
         new_z_fade_height = planner.z_fade_height;
2029
       #endif
1965
       #endif

Loading…
Cancel
Save