From e8f6c9fac91f0ad808ef8a8ee62f5b5466f5aeab Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 24 Feb 2021 17:01:45 +0100 Subject: [PATCH] Exit the _lcd_move* menus when homing/leveling Instead of resetting the encoder status when homing or leveling, simply exit the move/liveZ menu. When transitioning from idle->printing, axis move shouldn't be allowed as it would insert moves during a print. This is always wrong. The menu must be always dismissed. Instead of checking all places where the menu could be active, automatically dimiss the menu from within _lcd_move when homing/MBL is happening. The long-push function and the settings menu checks if "axis move" is possible, and thus prevent the user to re-enter the menu already. When doing the first layer calibration, the _lcd_babystep_z is automatically brought back after MBL has completed. Technically we should do the same when entering/exiting the paused state in _lcd_move. However, it's better to dismiss _any_ menu in stop_and_save_print_to_ram/restore_print_from_ram_and_continue instead. To be done later... --- Firmware/ultralcd.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 833eddc39..0117cca8a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2850,6 +2850,13 @@ void lcd_menu_statistics() static void _lcd_move(const char *name, int axis, int min, int max) { + if (homing_flag || mesh_bed_leveling_flag) + { + // printer entered a new state where axis move is forbidden + menu_back(); + return; + } + typedef struct { // 2bytes total bool initialized; // 1byte @@ -3071,6 +3078,13 @@ static void lcd_move_z() { */ static void lcd_babystep_z() { + if (homing_flag || mesh_bed_leveling_flag) + { + // printer changed to a new state where live Z is forbidden + menu_back(); + return; + } + typedef struct { int8_t status; @@ -3106,9 +3120,8 @@ static void lcd_babystep_z() lcd_timeoutToStatus.start(); } - if (lcd_encoder != 0) + if (lcd_encoder != 0) { - if (homing_flag || mesh_bed_leveling_flag) lcd_encoder = 0; _md->babystepMemZ += (int)lcd_encoder; if (_md->babystepMemZ < Z_BABYSTEP_MIN) _md->babystepMemZ = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm