Przeglądaj źródła

Move Bed Leveling Menu to its own file

Scott Lahteine 6 lat temu
rodzic
commit
587a64d80c
2 zmienionych plików z 339 dodań i 311 usunięć
  1. 0
    311
      Marlin/src/lcd/menu/menu.cpp
  2. 339
    0
      Marlin/src/lcd/menu/menu_bed_leveling.cpp

+ 0
- 311
Marlin/src/lcd/menu/menu.cpp Wyświetl plik

263
   #endif
263
   #endif
264
 #endif
264
 #endif
265
 
265
 
266
-#if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
267
-  #include "../../feature/bedlevel/mbl/mesh_bed_leveling.h"
268
-#endif
269
-
270
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
266
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
271
   float lcd_z_fade_height;
267
   float lcd_z_fade_height;
272
   void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
268
   void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
685
   lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
681
   lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
686
 }
682
 }
687
 
683
 
688
-#if ENABLED(LEVEL_BED_CORNERS)
689
-
690
-  /**
691
-   * Level corners, starting in the front-left corner.
692
-   */
693
-  static int8_t bed_corner;
694
-  void _lcd_goto_next_corner() {
695
-    line_to_z(4.0);
696
-    switch (bed_corner) {
697
-      case 0:
698
-        current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
699
-        current_position[Y_AXIS] = Y_MIN_BED + LEVEL_CORNERS_INSET;
700
-        break;
701
-      case 1:
702
-        current_position[X_AXIS] = X_MAX_BED - LEVEL_CORNERS_INSET;
703
-        break;
704
-      case 2:
705
-        current_position[Y_AXIS] = Y_MAX_BED - LEVEL_CORNERS_INSET;
706
-        break;
707
-      case 3:
708
-        current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
709
-        break;
710
-      #if ENABLED(LEVEL_CENTER_TOO)
711
-        case 4:
712
-          current_position[X_AXIS] = X_CENTER;
713
-          current_position[Y_AXIS] = Y_CENTER;
714
-          break;
715
-      #endif
716
-    }
717
-    planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
718
-    line_to_z(0.0);
719
-    if (++bed_corner > 3
720
-      #if ENABLED(LEVEL_CENTER_TOO)
721
-        + 1
722
-      #endif
723
-    ) bed_corner = 0;
724
-  }
725
-
726
-  void _lcd_corner_submenu() {
727
-    START_MENU();
728
-    MENU_ITEM(function,
729
-      #if ENABLED(LEVEL_CENTER_TOO)
730
-        MSG_LEVEL_BED_NEXT_POINT
731
-      #else
732
-        MSG_NEXT_CORNER
733
-      #endif
734
-      , _lcd_goto_next_corner);
735
-    MENU_ITEM(function, MSG_BACK, lcd_goto_previous_menu_no_defer);
736
-    END_MENU();
737
-  }
738
-
739
-  void _lcd_level_bed_corners_homing() {
740
-    _lcd_draw_homing();
741
-    if (all_axes_homed()) {
742
-      bed_corner = 0;
743
-      lcd_goto_screen(_lcd_corner_submenu);
744
-      _lcd_goto_next_corner();
745
-    }
746
-  }
747
-
748
-  void _lcd_level_bed_corners() {
749
-    defer_return_to_status = true;
750
-    if (!all_axes_known()) {
751
-      axis_homed = 0;
752
-      enqueue_and_echo_commands_P(PSTR("G28"));
753
-    }
754
-    lcd_goto_screen(_lcd_level_bed_corners_homing);
755
-  }
756
-
757
-#endif // LEVEL_BED_CORNERS
758
-
759
-#if ENABLED(LCD_BED_LEVELING) && (ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING))
760
-
761
-  /**
762
-   *
763
-   * "Motion" > "Level Bed" handlers
764
-   *
765
-   */
766
-
767
-  static uint8_t manual_probe_index;
768
-
769
-  // LCD probed points are from defaults
770
-  constexpr uint8_t total_probe_points = (
771
-    #if ENABLED(AUTO_BED_LEVELING_3POINT)
772
-      3
773
-    #elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
774
-      GRID_MAX_POINTS
775
-    #endif
776
-  );
777
-
778
-  bool lcd_wait_for_move;
779
-
780
-  //
781
-  // Bed leveling is done. Wait for G29 to complete.
782
-  // A flag is used so that this can release control
783
-  // and allow the command queue to be processed.
784
-  //
785
-  // When G29 finishes the last move:
786
-  // - Raise Z to the "manual probe height"
787
-  // - Don't return until done.
788
-  //
789
-  // ** This blocks the command queue! **
790
-  //
791
-  void _lcd_level_bed_done() {
792
-    if (!lcd_wait_for_move) {
793
-      #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
794
-        // Display "Done" screen and wait for moves to complete
795
-        line_to_z(MANUAL_PROBE_HEIGHT);
796
-        lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
797
-      #endif
798
-      lcd_goto_previous_menu_no_defer();
799
-      lcd_completion_feedback();
800
-    }
801
-    if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
802
-    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
803
-  }
804
-
805
-  void _lcd_level_goto_next_point();
806
-
807
-  /**
808
-   * Step 7: Get the Z coordinate, click goes to the next point or exits
809
-   */
810
-  void _lcd_level_bed_get_z() {
811
-    ENCODER_DIRECTION_NORMAL();
812
-
813
-    if (use_click()) {
814
-
815
-      //
816
-      // Save the current Z position and move
817
-      //
818
-
819
-      // If done...
820
-      if (++manual_probe_index >= total_probe_points) {
821
-        //
822
-        // The last G29 records the point and enables bed leveling
823
-        //
824
-        lcd_wait_for_move = true;
825
-        lcd_goto_screen(_lcd_level_bed_done);
826
-        #if ENABLED(MESH_BED_LEVELING)
827
-          enqueue_and_echo_commands_P(PSTR("G29 S2"));
828
-        #elif ENABLED(PROBE_MANUALLY)
829
-          enqueue_and_echo_commands_P(PSTR("G29 V1"));
830
-        #endif
831
-      }
832
-      else
833
-        _lcd_level_goto_next_point();
834
-
835
-      return;
836
-    }
837
-
838
-    //
839
-    // Encoder knob or keypad buttons adjust the Z position
840
-    //
841
-    if (encoderPosition) {
842
-      const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP);
843
-      line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
844
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
845
-      encoderPosition = 0;
846
-    }
847
-
848
-    //
849
-    // Draw on first display, then only on Z change
850
-    //
851
-    if (lcdDrawUpdate) {
852
-      const float v = current_position[Z_AXIS];
853
-      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
854
-    }
855
-  }
856
-
857
-  /**
858
-   * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
859
-   */
860
-  void _lcd_level_bed_moving() {
861
-    if (lcdDrawUpdate) {
862
-      char msg[10];
863
-      sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
864
-      lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
865
-    }
866
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
867
-    if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
868
-  }
869
-
870
-  /**
871
-   * Step 5: Initiate a move to the next point
872
-   */
873
-  void _lcd_level_goto_next_point() {
874
-    lcd_goto_screen(_lcd_level_bed_moving);
875
-
876
-    // G29 Records Z, moves, and signals when it pauses
877
-    lcd_wait_for_move = true;
878
-    #if ENABLED(MESH_BED_LEVELING)
879
-      enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
880
-    #elif ENABLED(PROBE_MANUALLY)
881
-      enqueue_and_echo_commands_P(PSTR("G29 V1"));
882
-    #endif
883
-  }
884
-
885
-  /**
886
-   * Step 4: Display "Click to Begin", wait for click
887
-   *         Move to the first probe position
888
-   */
889
-  void _lcd_level_bed_homing_done() {
890
-    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
891
-    if (use_click()) {
892
-      manual_probe_index = 0;
893
-      _lcd_level_goto_next_point();
894
-    }
895
-  }
896
-
897
-  /**
898
-   * Step 3: Display "Homing XYZ" - Wait for homing to finish
899
-   */
900
-  void _lcd_level_bed_homing() {
901
-    _lcd_draw_homing();
902
-    if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done);
903
-  }
904
-
905
-  #if ENABLED(PROBE_MANUALLY)
906
-    extern bool g29_in_progress;
907
-  #endif
908
-
909
-  /**
910
-   * Step 2: Continue Bed Leveling...
911
-   */
912
-  void _lcd_level_bed_continue() {
913
-    defer_return_to_status = true;
914
-    axis_homed = 0;
915
-    lcd_goto_screen(_lcd_level_bed_homing);
916
-    enqueue_and_echo_commands_P(PSTR("G28"));
917
-  }
918
-
919
-#endif // LCD_BED_LEVELING && (PROBE_MANUALLY || MESH_BED_LEVELING)
920
-
921
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
684
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
922
   void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
685
   void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
923
 #endif
686
 #endif
924
 
687
 
925
-#if ENABLED(LCD_BED_LEVELING)
926
-
927
-  /**
928
-   * Step 1: Bed Level entry-point
929
-   *
930
-   * << Motion
931
-   *    Auto Home           (if homing needed)
932
-   *    Leveling On/Off     (if data exists, and homed)
933
-   *    Fade Height: ---    (Req: ENABLE_LEVELING_FADE_HEIGHT)
934
-   *    Mesh Z Offset: ---  (Req: MESH_BED_LEVELING)
935
-   *    Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
936
-   *    Level Bed >
937
-   *    Level Corners >     (if homed)
938
-   *    Load Settings       (Req: EEPROM_SETTINGS)
939
-   *    Save Settings       (Req: EEPROM_SETTINGS)
940
-   */
941
-  void menu_bed_leveling() {
942
-    START_MENU();
943
-    MENU_BACK(MSG_MOTION);
944
-
945
-    const bool is_homed = all_axes_known();
946
-
947
-    // Auto Home if not using manual probing
948
-    #if DISABLED(PROBE_MANUALLY) && DISABLED(MESH_BED_LEVELING)
949
-      if (!is_homed) MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
950
-    #endif
951
-
952
-    // Level Bed
953
-    #if ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING)
954
-      // Manual leveling uses a guided procedure
955
-      MENU_ITEM(submenu, MSG_LEVEL_BED, _lcd_level_bed_continue);
956
-    #else
957
-      // Automatic leveling can just run the G-code
958
-      MENU_ITEM(gcode, MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
959
-    #endif
960
-
961
-    // Homed and leveling is valid? Then leveling can be toggled.
962
-    if (is_homed && leveling_is_valid()) {
963
-      bool new_level_state = planner.leveling_active;
964
-      MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
965
-    }
966
-
967
-    // Z Fade Height
968
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
969
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
970
-    #endif
971
-
972
-    //
973
-    // MBL Z Offset
974
-    //
975
-    #if ENABLED(MESH_BED_LEVELING)
976
-      MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
977
-    #endif
978
-
979
-    #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
980
-      MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
981
-    #elif HAS_BED_PROBE
982
-      MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
983
-    #endif
984
-
985
-    #if ENABLED(LEVEL_BED_CORNERS)
986
-      // Move to the next corner for leveling
987
-      MENU_ITEM(submenu, MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
988
-    #endif
989
-
990
-    #if ENABLED(EEPROM_SETTINGS)
991
-      MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
992
-      MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
993
-    #endif
994
-    END_MENU();
995
-  }
996
-
997
-#endif // LCD_BED_LEVELING
998
-
999
 #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
688
 #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
1000
 
689
 
1001
   void _man_probe_pt(const float &rx, const float &ry) {
690
   void _man_probe_pt(const float &rx, const float &ry) {

+ 339
- 0
Marlin/src/lcd/menu/menu_bed_leveling.cpp Wyświetl plik

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// Bed Leveling Menus
25
+//
26
+
27
+#include "../../inc/MarlinConfigPre.h"
28
+
29
+#if HAS_LCD_MENU && ENABLED(LCD_BED_LEVELING)
30
+
31
+#include "menu.h"
32
+#include "../../module/planner.h"
33
+#include "../../feature/bedlevel/bedlevel.h"
34
+
35
+#if ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING)
36
+
37
+  #include "../../module/motion.h"
38
+  #include "../../gcode/queue.h"
39
+
40
+  //
41
+  // Motion > Level Bed handlers
42
+  //
43
+
44
+  static uint8_t manual_probe_index;
45
+
46
+  // LCD probed points are from defaults
47
+  constexpr uint8_t total_probe_points = (
48
+    #if ENABLED(AUTO_BED_LEVELING_3POINT)
49
+      3
50
+    #elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
51
+      GRID_MAX_POINTS
52
+    #endif
53
+  );
54
+
55
+  bool lcd_wait_for_move;
56
+
57
+  //
58
+  // Bed leveling is done. Wait for G29 to complete.
59
+  // A flag is used so that this can release control
60
+  // and allow the command queue to be processed.
61
+  //
62
+  // When G29 finishes the last move:
63
+  // - Raise Z to the "manual probe height"
64
+  // - Don't return until done.
65
+  //
66
+  // ** This blocks the command queue! **
67
+  //
68
+  void _lcd_level_bed_done() {
69
+    if (!lcd_wait_for_move) {
70
+      #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
71
+        // Display "Done" screen and wait for moves to complete
72
+        line_to_z(MANUAL_PROBE_HEIGHT);
73
+        lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
74
+      #endif
75
+      lcd_goto_previous_menu_no_defer();
76
+      lcd_completion_feedback();
77
+    }
78
+    if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
79
+    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
80
+  }
81
+
82
+  void _lcd_level_goto_next_point();
83
+
84
+  //
85
+  // Step 7: Get the Z coordinate, click goes to the next point or exits
86
+  //
87
+  void _lcd_level_bed_get_z() {
88
+    ENCODER_DIRECTION_NORMAL();
89
+
90
+    if (use_click()) {
91
+
92
+      //
93
+      // Save the current Z position and move
94
+      //
95
+
96
+      // If done...
97
+      if (++manual_probe_index >= total_probe_points) {
98
+        //
99
+        // The last G29 records the point and enables bed leveling
100
+        //
101
+        lcd_wait_for_move = true;
102
+        lcd_goto_screen(_lcd_level_bed_done);
103
+        #if ENABLED(MESH_BED_LEVELING)
104
+          enqueue_and_echo_commands_P(PSTR("G29 S2"));
105
+        #elif ENABLED(PROBE_MANUALLY)
106
+          enqueue_and_echo_commands_P(PSTR("G29 V1"));
107
+        #endif
108
+      }
109
+      else
110
+        _lcd_level_goto_next_point();
111
+
112
+      return;
113
+    }
114
+
115
+    //
116
+    // Encoder knob or keypad buttons adjust the Z position
117
+    //
118
+    if (encoderPosition) {
119
+      const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP);
120
+      line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
121
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
122
+      encoderPosition = 0;
123
+    }
124
+
125
+    //
126
+    // Draw on first display, then only on Z change
127
+    //
128
+    if (lcdDrawUpdate) {
129
+      const float v = current_position[Z_AXIS];
130
+      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
131
+    }
132
+  }
133
+
134
+  //
135
+  // Step 6: Display "Next point: 1 / 9" while waiting for move to finish
136
+  //
137
+  void _lcd_level_bed_moving() {
138
+    if (lcdDrawUpdate) {
139
+      char msg[10];
140
+      sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
141
+      lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
142
+    }
143
+    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
144
+    if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
145
+  }
146
+
147
+  //
148
+  // Step 5: Initiate a move to the next point
149
+  //
150
+  void _lcd_level_goto_next_point() {
151
+    lcd_goto_screen(_lcd_level_bed_moving);
152
+
153
+    // G29 Records Z, moves, and signals when it pauses
154
+    lcd_wait_for_move = true;
155
+    #if ENABLED(MESH_BED_LEVELING)
156
+      enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
157
+    #elif ENABLED(PROBE_MANUALLY)
158
+      enqueue_and_echo_commands_P(PSTR("G29 V1"));
159
+    #endif
160
+  }
161
+
162
+  //
163
+  // Step 4: Display "Click to Begin", wait for click
164
+  //         Move to the first probe position
165
+  //
166
+  void _lcd_level_bed_homing_done() {
167
+    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
168
+    if (use_click()) {
169
+      manual_probe_index = 0;
170
+      _lcd_level_goto_next_point();
171
+    }
172
+  }
173
+
174
+  //
175
+  // Step 3: Display "Homing XYZ" - Wait for homing to finish
176
+  //
177
+  void _lcd_level_bed_homing() {
178
+    _lcd_draw_homing();
179
+    if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done);
180
+  }
181
+
182
+  #if ENABLED(PROBE_MANUALLY)
183
+    extern bool g29_in_progress;
184
+  #endif
185
+
186
+  //
187
+  // Step 2: Continue Bed Leveling...
188
+  //
189
+  void _lcd_level_bed_continue() {
190
+    defer_return_to_status = true;
191
+    axis_homed = 0;
192
+    lcd_goto_screen(_lcd_level_bed_homing);
193
+    enqueue_and_echo_commands_P(PSTR("G28"));
194
+  }
195
+
196
+#endif // PROBE_MANUALLY || MESH_BED_LEVELING
197
+
198
+#if ENABLED(LEVEL_BED_CORNERS)
199
+
200
+  /**
201
+   * Level corners, starting in the front-left corner.
202
+   */
203
+  static int8_t bed_corner;
204
+  void _lcd_goto_next_corner() {
205
+    line_to_z(4.0);
206
+    switch (bed_corner) {
207
+      case 0:
208
+        current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
209
+        current_position[Y_AXIS] = Y_MIN_BED + LEVEL_CORNERS_INSET;
210
+        break;
211
+      case 1:
212
+        current_position[X_AXIS] = X_MAX_BED - LEVEL_CORNERS_INSET;
213
+        break;
214
+      case 2:
215
+        current_position[Y_AXIS] = Y_MAX_BED - LEVEL_CORNERS_INSET;
216
+        break;
217
+      case 3:
218
+        current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
219
+        break;
220
+      #if ENABLED(LEVEL_CENTER_TOO)
221
+        case 4:
222
+          current_position[X_AXIS] = X_CENTER;
223
+          current_position[Y_AXIS] = Y_CENTER;
224
+          break;
225
+      #endif
226
+    }
227
+    planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
228
+    line_to_z(0.0);
229
+    if (++bed_corner > 3
230
+      #if ENABLED(LEVEL_CENTER_TOO)
231
+        + 1
232
+      #endif
233
+    ) bed_corner = 0;
234
+  }
235
+
236
+  void _lcd_corner_submenu() {
237
+    START_MENU();
238
+    MENU_ITEM(function,
239
+      #if ENABLED(LEVEL_CENTER_TOO)
240
+        MSG_LEVEL_BED_NEXT_POINT
241
+      #else
242
+        MSG_NEXT_CORNER
243
+      #endif
244
+      , _lcd_goto_next_corner);
245
+    MENU_ITEM(function, MSG_BACK, lcd_goto_previous_menu_no_defer);
246
+    END_MENU();
247
+  }
248
+
249
+  void _lcd_level_bed_corners_homing() {
250
+    _lcd_draw_homing();
251
+    if (all_axes_homed()) {
252
+      bed_corner = 0;
253
+      lcd_goto_screen(_lcd_corner_submenu);
254
+      _lcd_goto_next_corner();
255
+    }
256
+  }
257
+
258
+  void _lcd_level_bed_corners() {
259
+    defer_return_to_status = true;
260
+    if (!all_axes_known()) {
261
+      axis_homed = 0;
262
+      enqueue_and_echo_commands_P(PSTR("G28"));
263
+    }
264
+    lcd_goto_screen(_lcd_level_bed_corners_homing);
265
+  }
266
+
267
+#endif // LEVEL_BED_CORNERS
268
+
269
+/**
270
+ * Step 1: Bed Level entry-point
271
+ *
272
+ * << Motion
273
+ *    Auto Home           (if homing needed)
274
+ *    Leveling On/Off     (if data exists, and homed)
275
+ *    Fade Height: ---    (Req: ENABLE_LEVELING_FADE_HEIGHT)
276
+ *    Mesh Z Offset: ---  (Req: MESH_BED_LEVELING)
277
+ *    Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
278
+ *    Level Bed >
279
+ *    Level Corners >     (if homed)
280
+ *    Load Settings       (Req: EEPROM_SETTINGS)
281
+ *    Save Settings       (Req: EEPROM_SETTINGS)
282
+ */
283
+void menu_bed_leveling() {
284
+  START_MENU();
285
+  MENU_BACK(MSG_MOTION);
286
+
287
+  const bool is_homed = all_axes_known();
288
+
289
+  // Auto Home if not using manual probing
290
+  #if DISABLED(PROBE_MANUALLY) && DISABLED(MESH_BED_LEVELING)
291
+    if (!is_homed) MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
292
+  #endif
293
+
294
+  // Level Bed
295
+  #if ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING)
296
+    // Manual leveling uses a guided procedure
297
+    MENU_ITEM(submenu, MSG_LEVEL_BED, _lcd_level_bed_continue);
298
+  #else
299
+    // Automatic leveling can just run the G-code
300
+    MENU_ITEM(gcode, MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
301
+  #endif
302
+
303
+  // Homed and leveling is valid? Then leveling can be toggled.
304
+  if (is_homed && leveling_is_valid()) {
305
+    bool new_level_state = planner.leveling_active;
306
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
307
+  }
308
+
309
+  // Z Fade Height
310
+  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
311
+    MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
312
+  #endif
313
+
314
+  //
315
+  // MBL Z Offset
316
+  //
317
+  #if ENABLED(MESH_BED_LEVELING)
318
+    MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
319
+  #endif
320
+
321
+  #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
322
+    MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
323
+  #elif HAS_BED_PROBE
324
+    MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
325
+  #endif
326
+
327
+  #if ENABLED(LEVEL_BED_CORNERS)
328
+    // Move to the next corner for leveling
329
+    MENU_ITEM(submenu, MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
330
+  #endif
331
+
332
+  #if ENABLED(EEPROM_SETTINGS)
333
+    MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
334
+    MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
335
+  #endif
336
+  END_MENU();
337
+}
338
+
339
+#endif // HAS_LCD_MENU && LCD_BED_LEVELING

Ładowanie…
Anuluj
Zapisz