|
@@ -891,15 +891,13 @@ void lcd_cooldown() {
|
891
|
891
|
*
|
892
|
892
|
*/
|
893
|
893
|
|
894
|
|
- static int _lcd_level_bed_position;
|
895
|
|
- static bool mbl_wait_for_move = false;
|
|
894
|
+ static uint8_t _lcd_level_bed_position;
|
896
|
895
|
|
897
|
896
|
// Utility to go to the next mesh point
|
898
|
897
|
// A raise is added between points if MIN_Z_HEIGHT_FOR_HOMING is in use
|
899
|
898
|
// Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
|
900
|
899
|
// Z position will be restored with the final action, a G28
|
901
|
900
|
inline void _mbl_goto_xy(float x, float y) {
|
902
|
|
- mbl_wait_for_move = true;
|
903
|
901
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
904
|
902
|
#if MIN_Z_HEIGHT_FOR_HOMING > 0
|
905
|
903
|
+ MIN_Z_HEIGHT_FOR_HOMING
|
|
@@ -914,59 +912,52 @@ void lcd_cooldown() {
|
914
|
912
|
line_to_current(Z_AXIS);
|
915
|
913
|
#endif
|
916
|
914
|
st_synchronize();
|
917
|
|
- mbl_wait_for_move = false;
|
|
915
|
+ }
|
|
916
|
+
|
|
917
|
+ static void _lcd_level_goto_next_point();
|
|
918
|
+
|
|
919
|
+ static void _lcd_level_bed_done() {
|
|
920
|
+ if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
|
|
921
|
+ lcdDrawUpdate =
|
|
922
|
+ #if ENABLED(DOGLCD)
|
|
923
|
+ LCDVIEW_CALL_REDRAW_NEXT
|
|
924
|
+ #else
|
|
925
|
+ LCDVIEW_CALL_NO_REDRAW
|
|
926
|
+ #endif
|
|
927
|
+ ;
|
918
|
928
|
}
|
919
|
929
|
|
920
|
930
|
/**
|
921
|
|
- * 5. MBL Wait for controller movement and clicks:
|
922
|
|
- * - Movement adjusts the Z axis
|
923
|
|
- * - Click saves the Z, goes to the next mesh point
|
|
931
|
+ * Step 7: Get the Z coordinate, then goto next point or exit
|
924
|
932
|
*/
|
925
|
|
- static void _lcd_level_bed_procedure() {
|
926
|
|
- // Menu handlers may be called in a re-entrant fashion
|
927
|
|
- // if they call st_synchronize or plan_buffer_line. So
|
928
|
|
- // while waiting for a move we just ignore new input.
|
929
|
|
- if (mbl_wait_for_move) {
|
930
|
|
- lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
931
|
|
- return;
|
932
|
|
- }
|
933
|
|
-
|
|
933
|
+ static void _lcd_level_bed_get_z() {
|
934
|
934
|
ENCODER_DIRECTION_NORMAL();
|
935
|
935
|
|
936
|
936
|
// Encoder wheel adjusts the Z position
|
937
|
937
|
if (encoderPosition && movesplanned() <= 3) {
|
938
|
938
|
refresh_cmd_timeout();
|
939
|
939
|
current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
|
940
|
|
- if (min_software_endstops) NOLESS(current_position[Z_AXIS], Z_MIN_POS);
|
941
|
|
- if (max_software_endstops) NOMORE(current_position[Z_AXIS], Z_MAX_POS);
|
942
|
|
- encoderPosition = 0;
|
|
940
|
+ NOLESS(current_position[Z_AXIS], 0);
|
|
941
|
+ NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
|
943
|
942
|
line_to_current(Z_AXIS);
|
944
|
|
- lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
945
|
|
- }
|
946
|
|
-
|
947
|
|
- // Update on first display, then only on updates to Z position
|
948
|
|
- if (lcdDrawUpdate) {
|
949
|
|
- float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
|
950
|
|
- lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
|
|
943
|
+ lcdDrawUpdate =
|
|
944
|
+ #if ENABLED(DOGLCD)
|
|
945
|
+ LCDVIEW_CALL_REDRAW_NEXT
|
|
946
|
+ #else
|
|
947
|
+ LCDVIEW_REDRAW_NOW
|
|
948
|
+ #endif
|
|
949
|
+ ;
|
951
|
950
|
}
|
|
951
|
+ encoderPosition = 0;
|
952
|
952
|
|
953
|
|
- // We want subsequent calls, but don't force redraw
|
954
|
|
- // Set here so it can be overridden by lcd_return_to_status below
|
955
|
|
- lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
956
|
|
-
|
957
|
|
- // Click sets the current Z and moves to the next position
|
958
|
953
|
static bool debounce_click = false;
|
959
|
954
|
if (LCD_CLICKED) {
|
960
|
955
|
if (!debounce_click) {
|
961
|
956
|
debounce_click = true; // ignore multiple "clicks" in a row
|
962
|
957
|
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
|
963
|
958
|
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
964
|
|
- lcd_return_to_status();
|
965
|
|
- LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
|
966
|
|
- #if HAS_BUZZER
|
967
|
|
- buzz(200, 659);
|
968
|
|
- buzz(200, 698);
|
969
|
|
- #endif
|
|
959
|
+ lcd_goto_menu(_lcd_level_bed_done, true);
|
|
960
|
+
|
970
|
961
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
971
|
962
|
#if MIN_Z_HEIGHT_FOR_HOMING > 0
|
972
|
963
|
+ MIN_Z_HEIGHT_FOR_HOMING
|
|
@@ -974,44 +965,85 @@ void lcd_cooldown() {
|
974
|
965
|
;
|
975
|
966
|
line_to_current(Z_AXIS);
|
976
|
967
|
st_synchronize();
|
|
968
|
+
|
977
|
969
|
mbl.active = true;
|
978
|
970
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
|
971
|
+ lcd_return_to_status();
|
|
972
|
+ //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
|
|
973
|
+ #if HAS_BUZZER
|
|
974
|
+ buzz(200, 659);
|
|
975
|
+ buzz(200, 698);
|
|
976
|
+ #endif
|
979
|
977
|
}
|
980
|
978
|
else {
|
981
|
|
- #if ENABLED(NEWPANEL)
|
982
|
|
- lcd_quick_feedback();
|
983
|
|
- #endif
|
984
|
|
- int ix, iy;
|
985
|
|
- mbl.zigzag(_lcd_level_bed_position, ix, iy);
|
986
|
|
- _mbl_goto_xy(mbl.get_x(ix), mbl.get_y(iy));
|
987
|
|
- encoderPosition = 0;
|
|
979
|
+ lcd_goto_menu(_lcd_level_goto_next_point, true);
|
988
|
980
|
}
|
989
|
981
|
}
|
990
|
982
|
}
|
991
|
983
|
else {
|
992
|
984
|
debounce_click = false;
|
993
|
985
|
}
|
|
986
|
+
|
|
987
|
+ // Update on first display, then only on updates to Z position
|
|
988
|
+ // Show message above on clicks instead
|
|
989
|
+ if (lcdDrawUpdate) {
|
|
990
|
+ float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
|
|
991
|
+ lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
|
|
992
|
+ }
|
|
993
|
+
|
994
|
994
|
}
|
995
|
995
|
|
996
|
996
|
/**
|
997
|
|
- * 4. MBL Display "Click to Begin", wait for click
|
998
|
|
- * Move to the first probe position
|
|
997
|
+ * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
|
|
998
|
+ */
|
|
999
|
+ static void _lcd_level_bed_moving() {
|
|
1000
|
+ if (lcdDrawUpdate) {
|
|
1001
|
+ char msg[10];
|
|
1002
|
+ sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
|
|
1003
|
+ lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
|
|
1004
|
+ }
|
|
1005
|
+
|
|
1006
|
+ lcdDrawUpdate =
|
|
1007
|
+ #if ENABLED(DOGLCD)
|
|
1008
|
+ LCDVIEW_CALL_REDRAW_NEXT
|
|
1009
|
+ #else
|
|
1010
|
+ LCDVIEW_CALL_NO_REDRAW
|
|
1011
|
+ #endif
|
|
1012
|
+ ;
|
|
1013
|
+ }
|
|
1014
|
+
|
|
1015
|
+ /**
|
|
1016
|
+ * Step 5: Initiate a move to the next point
|
|
1017
|
+ */
|
|
1018
|
+ static void _lcd_level_goto_next_point() {
|
|
1019
|
+ // Set the menu to display ahead of blocking call
|
|
1020
|
+ lcd_goto_menu(_lcd_level_bed_moving);
|
|
1021
|
+
|
|
1022
|
+ // _mbl_goto_xy runs the menu loop until the move is done
|
|
1023
|
+ int ix, iy;
|
|
1024
|
+ mbl.zigzag(_lcd_level_bed_position, ix, iy);
|
|
1025
|
+ _mbl_goto_xy(mbl.get_x(ix), mbl.get_y(iy));
|
|
1026
|
+
|
|
1027
|
+ // After the blocking function returns, change menus
|
|
1028
|
+ lcd_goto_menu(_lcd_level_bed_get_z);
|
|
1029
|
+ }
|
|
1030
|
+
|
|
1031
|
+ /**
|
|
1032
|
+ * Step 4: Display "Click to Begin", wait for click
|
|
1033
|
+ * Move to the first probe position
|
999
|
1034
|
*/
|
1000
|
1035
|
static void _lcd_level_bed_homing_done() {
|
1001
|
|
- if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING), NULL);
|
1002
|
|
- lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
1003
|
|
- if (mbl_wait_for_move) return;
|
|
1036
|
+ if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
|
1004
|
1037
|
if (LCD_CLICKED) {
|
|
1038
|
+ _lcd_level_bed_position = 0;
|
1005
|
1039
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
1006
|
1040
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1007
|
|
- _mbl_goto_xy(MESH_MIN_X, MESH_MIN_Y);
|
1008
|
|
- _lcd_level_bed_position = 0;
|
1009
|
|
- lcd_goto_menu(_lcd_level_bed_procedure, true);
|
|
1041
|
+ lcd_goto_menu(_lcd_level_goto_next_point, true);
|
1010
|
1042
|
}
|
1011
|
1043
|
}
|
1012
|
1044
|
|
1013
|
1045
|
/**
|
1014
|
|
- * 3. MBL Display "Hoing XYZ" - Wait for homing to finish
|
|
1046
|
+ * Step 3: Display "Homing XYZ" - Wait for homing to finish
|
1015
|
1047
|
*/
|
1016
|
1048
|
static void _lcd_level_bed_homing() {
|
1017
|
1049
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
|
|
@@ -1027,7 +1059,7 @@ void lcd_cooldown() {
|
1027
|
1059
|
}
|
1028
|
1060
|
|
1029
|
1061
|
/**
|
1030
|
|
- * 2. MBL Continue Bed Leveling...
|
|
1062
|
+ * Step 2: Continue Bed Leveling...
|
1031
|
1063
|
*/
|
1032
|
1064
|
static void _lcd_level_bed_continue() {
|
1033
|
1065
|
defer_return_to_status = true;
|
|
@@ -1038,7 +1070,7 @@ void lcd_cooldown() {
|
1038
|
1070
|
}
|
1039
|
1071
|
|
1040
|
1072
|
/**
|
1041
|
|
- * 1. MBL entry-point: "Cancel" or "Level Bed"
|
|
1073
|
+ * Step 1: MBL entry-point: "Cancel" or "Level Bed"
|
1042
|
1074
|
*/
|
1043
|
1075
|
static void lcd_level_bed() {
|
1044
|
1076
|
START_MENU();
|
|
@@ -1348,7 +1380,7 @@ static void lcd_control_menu() {
|
1348
|
1380
|
|
1349
|
1381
|
static void _lcd_autotune(int e) {
|
1350
|
1382
|
char cmd[30];
|
1351
|
|
- sprintf_P(cmd, PSTR("M303 U1 E%d S%d"), e,
|
|
1383
|
+ sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
|
1352
|
1384
|
#if HAS_PID_FOR_BOTH
|
1353
|
1385
|
e < 0 ? autotune_temp_bed : autotune_temp[e]
|
1354
|
1386
|
#elif ENABLED(PIDTEMPBED)
|