|
@@ -887,6 +887,28 @@ void lcd_cooldown() {
|
887
|
887
|
*/
|
888
|
888
|
|
889
|
889
|
static int _lcd_level_bed_position;
|
|
890
|
+ static bool mbl_wait_for_move = false;
|
|
891
|
+
|
|
892
|
+ // Utility to go to the next mesh point
|
|
893
|
+ // A raise is added between points if MIN_Z_HEIGHT_FOR_HOMING is in use
|
|
894
|
+ // Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
|
|
895
|
+ // Z position will be restored with the final action, a G28
|
|
896
|
+ inline void _mbl_goto_xy(float x, float y) {
|
|
897
|
+ mbl_wait_for_move = true;
|
|
898
|
+ #if MIN_Z_HEIGHT_FOR_HOMING > 0
|
|
899
|
+ current_position[Z_AXIS] += MIN_Z_HEIGHT_FOR_HOMING;
|
|
900
|
+ line_to_current(Z_AXIS);
|
|
901
|
+ #endif
|
|
902
|
+ current_position[X_AXIS] = x + home_offset[X_AXIS];
|
|
903
|
+ current_position[Y_AXIS] = y + home_offset[Y_AXIS];
|
|
904
|
+ line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
|
|
905
|
+ #if MIN_Z_HEIGHT_FOR_HOMING > 0
|
|
906
|
+ current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
|
907
|
+ line_to_current(Z_AXIS);
|
|
908
|
+ #endif
|
|
909
|
+ st_synchronize();
|
|
910
|
+ mbl_wait_for_move = false;
|
|
911
|
+ }
|
890
|
912
|
|
891
|
913
|
/**
|
892
|
914
|
* 5. MBL Wait for controller movement and clicks:
|
|
@@ -894,7 +916,6 @@ void lcd_cooldown() {
|
894
|
916
|
* - Click saves the Z, goes to the next mesh point
|
895
|
917
|
*/
|
896
|
918
|
static void _lcd_level_bed_procedure() {
|
897
|
|
- static bool mbl_wait_for_move = false;
|
898
|
919
|
// Menu handlers may be called in a re-entrant fashion
|
899
|
920
|
// if they call st_synchronize or plan_buffer_line. So
|
900
|
921
|
// while waiting for a move we just ignore new input.
|
|
@@ -931,11 +952,7 @@ void lcd_cooldown() {
|
931
|
952
|
if (LCD_CLICKED) {
|
932
|
953
|
if (!debounce_click) {
|
933
|
954
|
debounce_click = true; // ignore multiple "clicks" in a row
|
934
|
|
- int ix = _lcd_level_bed_position % (MESH_NUM_X_POINTS),
|
935
|
|
- iy = _lcd_level_bed_position / (MESH_NUM_X_POINTS);
|
936
|
|
- if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
|
937
|
|
- mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
938
|
|
- _lcd_level_bed_position++;
|
|
955
|
+ mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
|
939
|
956
|
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
940
|
957
|
lcd_return_to_status();
|
941
|
958
|
LCD_ALERTMESSAGEPGM(MSG_LEVEL_BED_DONE);
|
|
@@ -953,17 +970,9 @@ void lcd_cooldown() {
|
953
|
970
|
#if ENABLED(NEWPANEL)
|
954
|
971
|
lcd_quick_feedback();
|
955
|
972
|
#endif
|
956
|
|
- mbl_wait_for_move = true;
|
957
|
|
- current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
958
|
|
- line_to_current(Z_AXIS);
|
959
|
|
- ix = _lcd_level_bed_position % (MESH_NUM_X_POINTS);
|
960
|
|
- iy = _lcd_level_bed_position / (MESH_NUM_X_POINTS);
|
961
|
|
- if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
|
962
|
|
- current_position[X_AXIS] = mbl.get_x(ix);
|
963
|
|
- current_position[Y_AXIS] = mbl.get_y(iy);
|
964
|
|
- line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
|
965
|
|
- st_synchronize();
|
966
|
|
- mbl_wait_for_move = false;
|
|
973
|
+ int ix, iy;
|
|
974
|
+ mbl.zigzag(_lcd_level_bed_position, ix, iy);
|
|
975
|
+ _mbl_goto_xy(mbl.get_x(ix), mbl.get_y(iy));
|
967
|
976
|
encoderPosition = 0;
|
968
|
977
|
}
|
969
|
978
|
}
|
|
@@ -980,12 +989,11 @@ void lcd_cooldown() {
|
980
|
989
|
static void _lcd_level_bed_homing_done() {
|
981
|
990
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING), NULL);
|
982
|
991
|
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
|
992
|
+ if (mbl_wait_for_move) return;
|
983
|
993
|
if (LCD_CLICKED) {
|
984
|
994
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
985
|
995
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
986
|
|
- current_position[X_AXIS] = MESH_MIN_X;
|
987
|
|
- current_position[Y_AXIS] = MESH_MIN_Y;
|
988
|
|
- line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
|
|
996
|
+ _mbl_goto_xy(MESH_MIN_X, MESH_MIN_Y);
|
989
|
997
|
_lcd_level_bed_position = 0;
|
990
|
998
|
lcd_goto_menu(_lcd_level_bed_procedure, true);
|
991
|
999
|
}
|