From 887ed73c9bc33cd27895d709e1106cc966ca5d9c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Dec 2016 00:43:36 -0800 Subject: [PATCH 1/5] Expose delta_clip_start_height for use by others --- Marlin/Marlin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 0c3511ad7c..7496551326 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -322,7 +322,8 @@ float code_value_temp_diff(); delta_segments_per_second, delta_diagonal_rod_trim_tower_1, delta_diagonal_rod_trim_tower_2, - delta_diagonal_rod_trim_tower_3; + delta_diagonal_rod_trim_tower_3, + delta_clip_start_height; void recalc_delta_settings(float radius, float diagonal_rod); #elif IS_SCARA void forward_kinematics_SCARA(const float &a, const float &b); From 2b5d4243940426f86ad3fdf547cfa0b0e79d2a6e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Dec 2016 21:51:46 -0800 Subject: [PATCH 2/5] Use handle_reprapworld_keypad for keypad handling --- Marlin/ultralcd.cpp | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 23eae4639f..bae069b798 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2502,6 +2502,39 @@ void kill_screen(const char* lcd_msg) { void reprapworld_keypad_move_y_down() { _reprapworld_keypad_move(Y_AXIS, 1); } void reprapworld_keypad_move_home() { enqueue_and_echo_commands_P(PSTR("G28")); } // move all axes home and wait void reprapworld_keypad_move_menu() { lcd_goto_screen(lcd_move_menu); } + + inline void handle_reprapworld_keypad() { + + static uint8_t keypad_debounce = 0; + + if (!REPRAPWORLD_KEYPAD_PRESSED) { + if (keypad_debounce > 0) keypad_debounce--; + } + else if (!keypad_debounce) { + keypad_debounce = 2; + + if (REPRAPWORLD_KEYPAD_MOVE_MENU) reprapworld_keypad_move_menu(); + + #if DISABLED(DELTA) && Z_HOME_DIR == -1 + if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up(); + #endif + + if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) { + #if ENABLED(DELTA) || Z_HOME_DIR != -1 + if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up(); + #endif + if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down(); + if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left(); + if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right(); + if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down(); + if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up(); + } + else { + if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home(); + } + } + } + #endif // REPRAPWORLD_KEYPAD /** @@ -2773,36 +2806,8 @@ void lcd_update() { #endif #if ENABLED(REPRAPWORLD_KEYPAD) - - static uint8_t keypad_debounce = 0; - - if (!REPRAPWORLD_KEYPAD_PRESSED) { - if (keypad_debounce > 0) keypad_debounce--; - } - else if (!keypad_debounce) { - keypad_debounce = 2; - - if (REPRAPWORLD_KEYPAD_MOVE_MENU) reprapworld_keypad_move_menu(); - - #if DISABLED(DELTA) && Z_HOME_DIR == -1 - if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up(); - #endif - - if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) { - #if ENABLED(DELTA) || Z_HOME_DIR != -1 - if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up(); - #endif - if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down(); - if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left(); - if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right(); - if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down(); - if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up(); - } - else { - if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home(); - } - } - #endif // REPRAPWORLD_KEYPAD + handle_reprapworld_keypad(); + #endif bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP); if (encoderPastThreshold || lcd_clicked) { From b4dbf4d18a03029f44217e73b7dbe8c7b5123a91 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Dec 2016 21:56:05 -0800 Subject: [PATCH 3/5] Non-reentrant "Moving..." screen to safely wait in LCD --- Marlin/language_en.h | 3 +++ Marlin/ultralcd.cpp | 36 +++++++++++++++++++++++++---- Marlin/ultralcd_impl_DOGM.h | 42 +++++++++++++++------------------- Marlin/ultralcd_impl_HD44780.h | 40 +++++++++++++++----------------- 4 files changed, 71 insertions(+), 50 deletions(-) diff --git a/Marlin/language_en.h b/Marlin/language_en.h index f19de3b331..4f8dd20605 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -138,6 +138,9 @@ #ifndef MSG_LEVEL_BED #define MSG_LEVEL_BED "Level bed" #endif +#ifndef MSG_MOVING + #define MSG_MOVING "Moving..." +#endif #ifndef MSG_MOVE_X #define MSG_MOVE_X "Move X" #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index bae069b798..479da86b18 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -390,7 +390,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to bool screen_changed; // LCD and menu clicks - bool lcd_clicked, wait_for_unclick, defer_return_to_status; + bool lcd_clicked, wait_for_unclick, defer_return_to_status, no_reentrance; // Variables used when editing values. const char* editLabel; @@ -422,6 +422,27 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to } } + /** + * Synchronize safely while holding the current screen + * This blocks all further screen or stripe updates once called + */ + inline void lcd_synchronize() { + lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_MOVING)); + if (no_reentrance) return; + no_reentrance = true; + screenFunc_t old_screen = currentScreen; + lcd_goto_screen(lcd_synchronize); + stepper.synchronize(); + no_reentrance = false; + lcd_goto_screen(old_screen); + } + + inline void lcd_wait_for_homing() { + no_reentrance = true; + while (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) idle(); + no_reentrance = true; + } + void lcd_return_to_status() { lcd_goto_screen(lcd_status_screen); } void lcd_save_previous_screen() { @@ -1063,6 +1084,7 @@ void kill_screen(const char* lcd_msg) { // Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z // Z position will be restored with the final action, a G28 inline void _mbl_goto_xy(float x, float y) { + if (no_reentrance) return; current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT); line_to_current(Z_AXIS); current_position[X_AXIS] = LOGICAL_X_POSITION(x); @@ -1072,7 +1094,7 @@ void kill_screen(const char* lcd_msg) { current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z); line_to_current(Z_AXIS); #endif - stepper.synchronize(); + lcd_synchronize(); } void _lcd_level_goto_next_point(); @@ -1094,6 +1116,8 @@ void kill_screen(const char* lcd_msg) { void _lcd_level_bed_get_z() { ENCODER_DIRECTION_NORMAL(); + if (no_reentrance) goto KeepDrawing; + // Encoder wheel adjusts the Z position if (encoderPosition) { refresh_cmd_timeout(); @@ -1121,7 +1145,7 @@ void kill_screen(const char* lcd_msg) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT; line_to_current(Z_AXIS); - stepper.synchronize(); + lcd_synchronize(); mbl.set_has_mesh(true); enqueue_and_echo_commands_P(PSTR("G28")); @@ -1141,6 +1165,7 @@ void kill_screen(const char* lcd_msg) { debounce_click = false; } +KeepDrawing: // Update on first display, then only on updates to Z position // Show message above on clicks instead if (lcdDrawUpdate) { @@ -1215,8 +1240,9 @@ void kill_screen(const char* lcd_msg) { LCDVIEW_CALL_NO_REDRAW #endif ; - if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) - lcd_goto_screen(_lcd_level_bed_homing_done); + if (no_reentrance) return; + lcd_wait_for_homing(); + lcd_goto_screen(_lcd_level_bed_homing_done); } /** diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index f8ffe74981..4adba37d27 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -656,34 +656,30 @@ static void lcd_implementation_status_screen() { u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2); } - #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE) + // Draw a static line of text in the same idiom as a menu item + static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) { - // Draw a static line of text in the same idiom as a menu item - static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) { + lcd_implementation_mark_as_selected(row, invert); - lcd_implementation_mark_as_selected(row, invert); - - if (!PAGE_CONTAINS(row_y1, row_y2)) return; + if (!PAGE_CONTAINS(row_y1, row_y2)) return; - char c; - int8_t n = LCD_WIDTH - (START_COL); + char c; + int8_t n = LCD_WIDTH - (START_COL); - if (center && !valstr) { - int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; - while (--pad >= 0) { u8g.print(' '); n--; } - } - while (n > 0 && (c = pgm_read_byte(pstr))) { - n -= lcd_print_and_count(c); - pstr++; - } - if (valstr) while (n > 0 && (c = *valstr)) { - n -= lcd_print_and_count(c); - valstr++; - } - while (n-- > 0) u8g.print(' '); + if (center && !valstr) { + int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; + while (--pad >= 0) { u8g.print(' '); n--; } } - - #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE + while (n > 0 && (c = pgm_read_byte(pstr))) { + n -= lcd_print_and_count(c); + pstr++; + } + if (valstr) while (n > 0 && (c = *valstr)) { + n -= lcd_print_and_count(c); + valstr++; + } + while (n-- > 0) u8g.print(' '); + } // Draw a generic menu item static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index a5efb0e09e..bc2504c14b 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -792,29 +792,25 @@ static void lcd_implementation_status_screen() { #if ENABLED(ULTIPANEL) - #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE) - - static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) { - UNUSED(invert); - char c; - int8_t n = LCD_WIDTH; - lcd.setCursor(0, row); - if (center && !valstr) { - int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; - while (--pad >= 0) { lcd.print(' '); n--; } - } - while (n > 0 && (c = pgm_read_byte(pstr))) { - n -= charset_mapper(c); - pstr++; - } - if (valstr) while (n > 0 && (c = *valstr)) { - n -= charset_mapper(c); - valstr++; - } - while (n-- > 0) lcd.print(' '); + static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) { + UNUSED(invert); + char c; + int8_t n = LCD_WIDTH; + lcd.setCursor(0, row); + if (center && !valstr) { + int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; + while (--pad >= 0) { lcd.print(' '); n--; } } - - #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE + while (n > 0 && (c = pgm_read_byte(pstr))) { + n -= charset_mapper(c); + pstr++; + } + if (valstr) while (n > 0 && (c = *valstr)) { + n -= charset_mapper(c); + valstr++; + } + while (n-- > 0) lcd.print(' '); + } static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { char c; From 641e0936d4d4703368d390bae45fb131b8c8a788 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Dec 2016 22:03:54 -0800 Subject: [PATCH 4/5] Patch up Delta Calibration Menu --- .../delta/biv2.5/Configuration.h | 3 - .../delta/generic/Configuration.h | 3 - .../delta/kossel_mini/Configuration.h | 3 - .../delta/kossel_pro/Configuration.h | 3 - .../delta/kossel_xl/Configuration.h | 3 - Marlin/ultralcd.cpp | 60 +++++++++++++++---- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 70274c0194..8c817681cc 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -453,10 +453,7 @@ #define DELTA_PRINTABLE_RADIUS 160.0 // Delta calibration menu - // uncomment to add three points calibration menu option. // See http://minow.blogspot.com/index.html#4918805519571907051 - // If needed, adjust the X, Y, Z calibration coordinates - // in ultralcd.cpp@lcd_delta_calibrate_menu() //#define DELTA_CALIBRATION_MENU // After homing move down to a height where XY movement is unconstrained diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index a8888e2b75..a3482357fe 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -453,10 +453,7 @@ #define DELTA_PRINTABLE_RADIUS 140.0 // Delta calibration menu - // uncomment to add three points calibration menu option. // See http://minow.blogspot.com/index.html#4918805519571907051 - // If needed, adjust the X, Y, Z calibration coordinates - // in ultralcd.cpp@lcd_delta_calibrate_menu() //#define DELTA_CALIBRATION_MENU // After homing move down to a height where XY movement is unconstrained diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index c02886db4d..d6e5106030 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -453,10 +453,7 @@ #define DELTA_PRINTABLE_RADIUS 90.0 // Delta calibration menu - // uncomment to add three points calibration menu option. // See http://minow.blogspot.com/index.html#4918805519571907051 - // If needed, adjust the X, Y, Z calibration coordinates - // in ultralcd.cpp@lcd_delta_calibrate_menu() //#define DELTA_CALIBRATION_MENU // After homing move down to a height where XY movement is unconstrained diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 7e26333a0f..c6510b2bb0 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -440,10 +440,7 @@ #define DELTA_PRINTABLE_RADIUS 127.0 // Delta calibration menu - // uncomment to add three points calibration menu option. // See http://minow.blogspot.com/index.html#4918805519571907051 - // If needed, adjust the X, Y, Z calibration coordinates - // in ultralcd.cpp@lcd_delta_calibrate_menu() //#define DELTA_CALIBRATION_MENU // After homing move down to a height where XY movement is unconstrained diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index 70c9f088fa..a539152c6d 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -451,10 +451,7 @@ #define DELTA_PRINTABLE_RADIUS 140.0 // Delta calibration menu - // uncomment to add three points calibration menu option. // See http://minow.blogspot.com/index.html#4918805519571907051 - // If needed, adjust the X, Y, Z calibration coordinates - // in ultralcd.cpp@lcd_delta_calibrate_menu() //#define DELTA_CALIBRATION_MENU // After homing move down to a height where XY movement is unconstrained diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 479da86b18..d30b405ec4 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1367,14 +1367,50 @@ KeepDrawing: END_MENU(); } + float move_menu_scale; + #if ENABLED(DELTA_CALIBRATION_MENU) + void lcd_move_z(); + void lcd_delta_calibrate_menu(); + + void _lcd_calibrate_homing() { + if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_HOMING)); + lcdDrawUpdate = + #if ENABLED(DOGLCD) + LCDVIEW_CALL_REDRAW_NEXT + #else + LCDVIEW_CALL_NO_REDRAW + #endif + ; + if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) + lcd_goto_previous_menu(); + } + + void _lcd_delta_calibrate_home() { + enqueue_and_echo_commands_P(PSTR("G28")); + lcd_goto_screen(_lcd_calibrate_homing); + } + + // Move directly to the tower position with uninterpolated moves + // If we used interpolated moves it would cause this to become re-entrant void _goto_tower_pos(const float &a) { - do_blocking_move_to( - a < 0 ? X_HOME_POS : sin(a) * -(DELTA_PRINTABLE_RADIUS), - a < 0 ? Y_HOME_POS : cos(a) * (DELTA_PRINTABLE_RADIUS), - 4 - ); + if (no_reentrance) return; + + current_position[Z_AXIS] = max(Z_HOMING_HEIGHT, Z_CLEARANCE_BETWEEN_PROBES) + (DELTA_PRINTABLE_RADIUS) / 5; + line_to_current(Z_AXIS); + + current_position[X_AXIS] = a < 0 ? X_HOME_POS : sin(a) * -(DELTA_PRINTABLE_RADIUS); + current_position[Y_AXIS] = a < 0 ? Y_HOME_POS : cos(a) * (DELTA_PRINTABLE_RADIUS); + line_to_current(Z_AXIS); + + current_position[Z_AXIS] = 4.0; + line_to_current(Z_AXIS); + + lcd_synchronize(); + + move_menu_scale = 0.1; + lcd_goto_screen(lcd_move_z); } void _goto_tower_x() { _goto_tower_pos(RADIANS(120)); } @@ -1385,18 +1421,18 @@ KeepDrawing: void lcd_delta_calibrate_menu() { START_MENU(); MENU_BACK(MSG_MAIN); - MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); - MENU_ITEM(function, MSG_DELTA_CALIBRATE_X, _goto_tower_x); - MENU_ITEM(function, MSG_DELTA_CALIBRATE_Y, _goto_tower_y); - MENU_ITEM(function, MSG_DELTA_CALIBRATE_Z, _goto_tower_z); - MENU_ITEM(function, MSG_DELTA_CALIBRATE_CENTER, _goto_center); + MENU_ITEM(submenu, MSG_AUTO_HOME, _lcd_delta_calibrate_home); + if (axis_homed[Z_AXIS]) { + MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_X, _goto_tower_x); + MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Y, _goto_tower_y); + MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Z, _goto_tower_z); + MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_CENTER, _goto_center); + } END_MENU(); } #endif // DELTA_CALIBRATION_MENU - float move_menu_scale; - /** * If the most recent manual move hasn't been fed to the planner yet, * and the planner can accept one, send immediately From 93b283334781f80e42c5bac66db479c73a71cb4a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Dec 2016 21:58:16 -0800 Subject: [PATCH 5/5] Move Menu: Select axis first, resolution after --- Marlin/language_en.h | 3 + Marlin/ultralcd.cpp | 154 +++++++++++++++++++++++++++---------------- 2 files changed, 100 insertions(+), 57 deletions(-) diff --git a/Marlin/language_en.h b/Marlin/language_en.h index 4f8dd20605..15ab487f34 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -141,6 +141,9 @@ #ifndef MSG_MOVING #define MSG_MOVING "Moving..." #endif +#ifndef MSG_FREE_XY + #define MSG_FREE_XY "Free XY" +#endif #ifndef MSG_MOVE_X #define MSG_MOVE_X "Move X" #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index d30b405ec4..088af11c90 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1282,6 +1282,14 @@ KeepDrawing: // MENU_BACK(MSG_MAIN); + // + // Move Axis + // + #if ENABLED(DELTA) + if (axis_homed[Z_AXIS]) + #endif + MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); + // // Auto Home // @@ -1309,11 +1317,6 @@ KeepDrawing: MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed); #endif - // - // Move Axis - // - MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); - // // Disable Steppers // @@ -1557,58 +1560,48 @@ KeepDrawing: * */ - #if IS_KINEMATIC - #define _MOVE_XYZ_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) - #else - #define _MOVE_XYZ_ALLOWED true - #endif + screenFunc_t _manual_move_func_ptr; - void _lcd_move_menu_axis() { - START_MENU(); - MENU_BACK(MSG_MOVE_AXIS); + void lcd_move_menu_10mm() { move_menu_scale = 10.0; lcd_goto_screen(_manual_move_func_ptr); } + void lcd_move_menu_1mm() { move_menu_scale = 1.0; lcd_goto_screen(_manual_move_func_ptr); } + void lcd_move_menu_01mm() { move_menu_scale = 0.1; lcd_goto_screen(_manual_move_func_ptr); } - if (_MOVE_XYZ_ALLOWED) { - MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); - MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); - } - - if (move_menu_scale < 10.0) { - if (_MOVE_XYZ_ALLOWED) MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); - - #if ENABLED(SWITCHING_EXTRUDER) - if (active_extruder) - MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0")); - else - MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1")); - #endif - - MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); - #if E_MANUAL > 1 - MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E1, lcd_move_e0); - MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E2, lcd_move_e1); - #if E_MANUAL > 2 - MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_e2); - #if E_MANUAL > 3 - MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E4, lcd_move_e3); - #endif - #endif - #endif + void _lcd_move_distance_menu(AxisEnum axis, screenFunc_t func) { + _manual_move_func_ptr = func; + START_MENU(); + if (LCD_HEIGHT >= 4) { + switch(axis) { + case X_AXIS: + STATIC_ITEM(MSG_MOVE_X, true, true); break; + case Y_AXIS: + STATIC_ITEM(MSG_MOVE_Y, true, true); break; + case Z_AXIS: + STATIC_ITEM(MSG_MOVE_Z, true, true); break; + default: + STATIC_ITEM(MSG_MOVE_E, true, true); break; + } } + MENU_BACK(MSG_MOVE_AXIS); + if (axis == X_AXIS || axis == Y_AXIS) + MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm); + MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm); + MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm); END_MENU(); } - - void lcd_move_menu_10mm() { - move_menu_scale = 10.0; - _lcd_move_menu_axis(); - } - void lcd_move_menu_1mm() { - move_menu_scale = 1.0; - _lcd_move_menu_axis(); - } - void lcd_move_menu_01mm() { - move_menu_scale = 0.1; - _lcd_move_menu_axis(); - } + void lcd_move_get_x_amount() { _lcd_move_distance_menu(X_AXIS, lcd_move_x); } + void lcd_move_get_y_amount() { _lcd_move_distance_menu(Y_AXIS, lcd_move_y); } + void lcd_move_get_z_amount() { _lcd_move_distance_menu(Z_AXIS, lcd_move_z); } + void lcd_move_get_e_amount() { _lcd_move_distance_menu(E_AXIS, lcd_move_e); } + #if E_MANUAL > 1 + void lcd_move_get_e0_amount() { _lcd_move_distance_menu(E_AXIS, lcd_move_e0); } + void lcd_move_get_e1_amount() { _lcd_move_distance_menu(E_AXIS, lcd_move_e1); } + #if E_MANUAL > 2 + void lcd_move_get_e2_amount() { _lcd_move_distance_menu(E_AXIS, lcd_move_e2); } + #if E_MANUAL > 3 + void lcd_move_get_e3_amount() { _lcd_move_distance_menu(E_AXIS, lcd_move_e3); } + #endif + #endif + #endif /** * @@ -1616,16 +1609,63 @@ KeepDrawing: * */ + #if IS_KINEMATIC + #define _MOVE_XYZ_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) + #if ENABLED(DELTA) + #define _MOVE_XY_ALLOWED (current_position[Z_AXIS] <= delta_clip_start_height) + void lcd_lower_z_to_clip_height() { + if (!no_reentrance) { + current_position[Z_AXIS] = delta_clip_start_height; + line_to_current(Z_AXIS); + lcd_synchronize(); + } + } + #else + #define _MOVE_XY_ALLOWED true + #endif + #else + #define _MOVE_XYZ_ALLOWED true + #define _MOVE_XY_ALLOWED true + #endif + void lcd_move_menu() { START_MENU(); MENU_BACK(MSG_PREPARE); - if (_MOVE_XYZ_ALLOWED) - MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm); + if (_MOVE_XYZ_ALLOWED) { + if (_MOVE_XY_ALLOWED) { + MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_get_x_amount); + MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_get_y_amount); + } + #if ENABLED(DELTA) + else + MENU_ITEM(function, MSG_FREE_XY, lcd_lower_z_to_clip_height); + #endif + + MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_get_z_amount); + } + else + MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); + + #if ENABLED(SWITCHING_EXTRUDER) + if (active_extruder) + MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0")); + else + MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1")); + #endif + + MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_get_e_amount); + #if E_MANUAL > 1 + MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E1, lcd_move_get_e0_amount); + MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E2, lcd_move_get_e1_amount); + #if E_MANUAL > 2 + MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_get_e2_amount); + #if E_MANUAL > 3 + MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E4, lcd_move_get_e3_amount); + #endif + #endif + #endif - MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm); - MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm); - //TODO:X,Y,Z,E END_MENU(); }