From 462535ef7fa2611579509b46b560db31bd7f409f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 6 May 2023 12:08:06 +0000 Subject: [PATCH] Restore 3.12 live Z-adjust menu behavior Code size increases a bit but keep in mind the PR that broke the behavior "saved" 182 bytes: https://github.com/prusa3d/Prusa-Firmware/pull/4063 So I think this code size increase is OK Change in memory: Flash: +84 bytes SRAM: 0 bytes --- Firmware/Marlin.h | 16 +++++++++++----- Firmware/Marlin_main.cpp | 10 +++++++++- Firmware/ultralcd.cpp | 11 +++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index c05a27261..1c5e55209 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -336,14 +336,20 @@ bool printer_active(); bool check_fsensor(); //! Condition where Babystepping is allowed: -//! 1) Z-axis position is less than 2.0mm (only allowed during the first couple of layers) -//! 2) Not allowed during Homing (printer busy) -//! 3) Not allowed during Mesh Bed Leveling (printer busy) +//! 1) Not allowed during Homing (printer busy) +//! 2) Not allowed during Mesh Bed Leveling (printer busy) +//! 3) Not allowed when a print job is paused //! 4) Allowed if: -//! - First Layer Calibration is running -//! - OR there are queued blocks, printJob is running and it's not paused, and Z-axis position is less than 2.0mm (only allowed during the first couple of layers) +//! - First Layer Calibration is running (the event when heaters are turned off is used to dismiss the menu) +//! - A print job is running +//! - If the printer is idle with not planned moves bool babystep_allowed(); +//! Same as babystep_allowed() but additionally adds a requirement +//! where the Z-axis position must be less than 2.0mm (only allowed +//! during the first couple of layers) +bool babystep_allowed_strict(); + extern void calculate_extruder_multipliers(); // Similar to the default Arduino delay function, diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 48acea582..dc8af8f9f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -542,10 +542,18 @@ bool check_fsensor() { bool __attribute__((noinline)) babystep_allowed() { return ( !homing_flag && !mesh_bed_leveling_flag - && ( lcd_commands_type == LcdCommands::Layer1Cal || ( blocks_queued() && !isPrintPaused && printJobOngoing() && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU))) + && !isPrintPaused + && ((lcd_commands_type == LcdCommands::Layer1Cal && CHECK_ALL_HEATERS) + || printJobOngoing() + || lcd_commands_type == LcdCommands::Idle + ) ); } +bool __attribute__((noinline)) babystep_allowed_strict() { + return ( babystep_allowed() && current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU); +} + bool fans_check_enabled = true; #ifdef TMC2130 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0f0c89f66..daaa44b44 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4470,7 +4470,7 @@ static void lcd_settings_menu() MENU_ITEM_TOGGLE_P(_T(MSG_RPI_PORT), (selectedSerialPort == 0) ? _T(MSG_OFF) : _T(MSG_ON), lcd_second_serial_set); #endif //HAS_SECOND_SERIAL - MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z); + if (!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z); #if (LANG_MODE != 0) MENU_ITEM_SUBMENU_P(_T(MSG_SELECT_LANGUAGE), lcd_language_menu); @@ -5148,7 +5148,8 @@ static void lcd_main_menu() MENU_ITEM_FUNCTION_P(PSTR("power panic"), uvlo_); #endif //TMC2130_DEBUG - if ( babystep_allowed() ) + // Menu is never shown when idle + if (babystep_allowed_strict() && (printJobOngoing() || lcd_commands_type == LcdCommands::Layer1Cal)) MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 if (farm_mode) @@ -7166,11 +7167,13 @@ void menu_lcd_longpress_func(void) // explicitely listed menus which are allowed to rise the move-z or live-adj-z functions // The lists are not the same for both functions, so first decide which function is to be performed - if (babystep_allowed()){ // long press as live-adj-z - if ( menu_menu == lcd_status_screen // and in listed menus... + if (blocks_queued() || printJobOngoing()){ // long press as live-adj-z + if ( babystep_allowed_strict() + && (menu_menu == lcd_status_screen // and in listed menus... || menu_menu == lcd_main_menu || menu_menu == lcd_tune_menu || menu_menu == lcd_support_menu + ) ){ lcd_clear(); menu_submenu(lcd_babystep_z);