|
@@ -887,14 +887,35 @@ 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
|
|
- * MBL Wait for controller movement and clicks:
|
893
|
|
- * - Movement adjusts the Z axis
|
894
|
|
- * - Click saves the Z and goes to the next mesh point
|
|
914
|
+ * 5. MBL Wait for controller movement and clicks:
|
|
915
|
+ * - Movement adjusts the Z axis
|
|
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);
|
|
@@ -946,24 +963,16 @@ void lcd_cooldown() {
|
946
|
963
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
947
|
964
|
line_to_current(Z_AXIS);
|
948
|
965
|
st_synchronize();
|
949
|
|
- mbl.active = 1;
|
|
966
|
+ mbl.active = true;
|
950
|
967
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
951
|
968
|
}
|
952
|
969
|
else {
|
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
|
}
|
|
@@ -973,22 +982,25 @@ void lcd_cooldown() {
|
973
|
982
|
}
|
974
|
983
|
}
|
975
|
984
|
|
|
985
|
+ /**
|
|
986
|
+ * 4. MBL Display "Click to Begin", wait for click
|
|
987
|
+ * Move to the first probe position
|
|
988
|
+ */
|
976
|
989
|
static void _lcd_level_bed_homing_done() {
|
977
|
990
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING), NULL);
|
978
|
991
|
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
|
992
|
+ if (mbl_wait_for_move) return;
|
979
|
993
|
if (LCD_CLICKED) {
|
980
|
994
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
981
|
995
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
982
|
|
- current_position[X_AXIS] = MESH_MIN_X;
|
983
|
|
- current_position[Y_AXIS] = MESH_MIN_Y;
|
984
|
|
- 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);
|
985
|
997
|
_lcd_level_bed_position = 0;
|
986
|
998
|
lcd_goto_menu(_lcd_level_bed_procedure, true);
|
987
|
999
|
}
|
988
|
1000
|
}
|
989
|
1001
|
|
990
|
1002
|
/**
|
991
|
|
- * MBL Move to mesh starting point
|
|
1003
|
+ * 3. MBL Display "Hoing XYZ" - Wait for homing to finish
|
992
|
1004
|
*/
|
993
|
1005
|
static void _lcd_level_bed_homing() {
|
994
|
1006
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
|
|
@@ -998,7 +1010,7 @@ void lcd_cooldown() {
|
998
|
1010
|
}
|
999
|
1011
|
|
1000
|
1012
|
/**
|
1001
|
|
- * MBL Continue Bed Leveling...
|
|
1013
|
+ * 2. MBL Continue Bed Leveling...
|
1002
|
1014
|
*/
|
1003
|
1015
|
static void _lcd_level_bed_continue() {
|
1004
|
1016
|
defer_return_to_status = true;
|
|
@@ -1009,7 +1021,7 @@ void lcd_cooldown() {
|
1009
|
1021
|
}
|
1010
|
1022
|
|
1011
|
1023
|
/**
|
1012
|
|
- * MBL entry-point
|
|
1024
|
+ * 1. MBL entry-point: "Cancel" or "Level Bed"
|
1013
|
1025
|
*/
|
1014
|
1026
|
static void lcd_level_bed() {
|
1015
|
1027
|
START_MENU();
|