From 06d34b4398f445222acda09ca8eda8e2e8a6ea63 Mon Sep 17 00:00:00 2001 From: gudnimg Date: Sat, 23 Sep 2023 14:18:52 +0000 Subject: [PATCH 1/2] Fix an issue where print can't be stopped under specific circumstances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a bug where if the printer is recovering a print, it run a blocking loop to restore the extruder and bed temperatures. But if a Fan error is triggered in this loop, then the user can't abort the print via LCD. If the fan error resolves on its own the 'Resume print' menu will appear in a few seconds. But if not, then the user can't resume the print (which is normal). But with the bug above the user can't abort the print either! The problem is essentially isPrintPaused variable is cleared too early. We should wait until the print is completely restored first. Steps to reproduce: 1. Start a print 2. Pause the print 3. Wait for extruder temperature to fall at lest 180°C 4. Click 'Resume' print 5. While heating, stop the hotend fan and wait for a few seconds until an error is raised 6. Observe issue => 'Stop print' menu item is gone! PFW-1542 --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index be066530f9..1a75a8250a 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5009,7 +5009,6 @@ void lcd_resume_print() lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); st_synchronize(); custom_message_type = CustomMsg::Resuming; - isPrintPaused = false; // resume processing USB commands again and restore hotend fan state (in case the print was // stopped due to a thermal error) @@ -5017,6 +5016,7 @@ void lcd_resume_print() Stopped = false; restore_print_from_ram_and_continue(default_retraction); + isPrintPaused = false; pause_time += (_millis() - start_pause_print); //accumulate time when print is paused for correct statistics calculation refresh_cmd_timeout(); SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUMED); //resume octoprint From 016db6a6e8f11820506cc0259b01294d85faa4bf Mon Sep 17 00:00:00 2001 From: gudnimg Date: Sat, 23 Sep 2023 15:42:03 +0000 Subject: [PATCH 2/2] Hide menus more consistently when the printer is busy lcd_calibration_menu: Remove redundant if (!isPrintPaused). The menu is never called unless this condition is true. eeprom_switch_to_next_sheet: Don't show this menu if the printer is busy doing work! Do not allow these menus to run while a print is paused or when we're recovering a print: - Preload to MMU - Load to Nozzle - Unload filament - Eject from MMU - Cut filament - Autoload filament - Settings - Calibration --- Firmware/ultralcd.cpp | 45 +++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1a75a8250a..15a5bc5fd1 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -99,7 +99,6 @@ static void lcd_language_menu(); static void lcd_main_menu(); static void lcd_tune_menu(); static void lcd_settings_menu(); -static void lcd_calibration_menu(); static void lcd_control_temperature_menu(); #ifdef TMC2130 static void lcd_settings_linearity_correction_menu_save(); @@ -4553,20 +4552,18 @@ static void lcd_settings_linearity_correction_menu_save() static void lcd_calibration_menu() { - MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_MAIN)); - if (!isPrintPaused) - { - MENU_ITEM_FUNCTION_P(_i("Wizard"), lcd_wizard);////MSG_WIZARD c=17 + MENU_BEGIN(); + MENU_ITEM_BACK_P(_T(MSG_MAIN)); + MENU_ITEM_FUNCTION_P(_i("Wizard"), lcd_wizard);////MSG_WIZARD c=17 if (lcd_commands_type == LcdCommands::Idle) { - MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_first_layer_calibration_reset); + MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_first_layer_calibration_reset); } - MENU_ITEM_GCODE_P(_T(MSG_AUTO_HOME), G28W); + MENU_ITEM_GCODE_P(_T(MSG_AUTO_HOME), G28W); #ifdef TMC2130 - MENU_ITEM_FUNCTION_P(_i("Belt test"), lcd_belttest_v);////MSG_BELTTEST c=18 + MENU_ITEM_FUNCTION_P(_i("Belt test"), lcd_belttest_v);////MSG_BELTTEST c=18 #endif //TMC2130 - MENU_ITEM_FUNCTION_P(_i("Selftest"), lcd_selftest_v);////MSG_SELFTEST c=18 + MENU_ITEM_FUNCTION_P(_i("Selftest"), lcd_selftest_v);////MSG_SELFTEST c=18 // MK2 MENU_ITEM_FUNCTION_P(_i("Calibrate XYZ"), lcd_mesh_calibration);////MSG_CALIBRATE_BED c=18 // "Calibrate Z" with storing the reference values to EEPROM. @@ -4575,21 +4572,21 @@ static void lcd_calibration_menu() MENU_ITEM_SUBMENU_P(_T(MSG_MESH_BED_LEVELING), lcd_mesh_bedleveling); ////MSG_MESH_BED_LEVELING c=18 MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=18 - MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 + MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 #ifndef TMC2130 MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=18 #endif MENU_ITEM_GCODE_P(_i("Reset XYZ calibr."), PSTR("M44"));////MSG_CALIBRATE_BED_RESET c=18 #ifdef PINDA_THERMISTOR if(has_temperature_compensation()) - MENU_ITEM_FUNCTION_P(_T(MSG_PINDA_CALIBRATION), lcd_calibrate_pinda); + MENU_ITEM_FUNCTION_P(_T(MSG_PINDA_CALIBRATION), lcd_calibrate_pinda); #endif - } + #ifdef THERMAL_MODEL MENU_ITEM_SUBMENU_P(_n("Thermal Model cal."), lcd_thermal_model_cal); #endif //THERMAL_MODEL - - MENU_END(); + + MENU_END(); } //! @brief Select one of numbered items @@ -5253,17 +5250,15 @@ static void lcd_main_menu() } #endif //SDSUPPORT - if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type == LcdCommands::Idle)) { - if (!farm_mode) { - const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)); - const int8_t nextSheet = eeprom_next_initialized_sheet(sheet); - if ((nextSheet >= 0) && (sheet != nextSheet)) { // show menu only if we have 2 or more sheets initialized - MENU_ITEM_FUNCTION_E(EEPROM_Sheets_base->s[sheet], eeprom_switch_to_next_sheet); - } + if(!printer_active() && !farm_mode) { + const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)); + const int8_t nextSheet = eeprom_next_initialized_sheet(sheet); + if ((nextSheet >= 0) && (sheet != nextSheet)) { // show menu only if we have 2 or more sheets initialized + MENU_ITEM_FUNCTION_E(EEPROM_Sheets_base->s[sheet], eeprom_switch_to_next_sheet); } } - if ( ! ( printJobOngoing() || (lcd_commands_type != LcdCommands::Idle) || (eFilamentAction != FilamentAction::None) || Stopped ) ) { + if ( ! ( printer_active() || (eFilamentAction != FilamentAction::None) || Stopped ) ) { if (MMU2::mmu2.Enabled()) { if(!MMU2::mmu2.FindaDetectsFilament() && !fsensor.getFilamentPresent()) { // The MMU 'Load filament' state machine will reject the command if any @@ -5290,8 +5285,8 @@ static void lcd_main_menu() } MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament); } - MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu); - if(!isPrintPaused && (custom_message_type != CustomMsg::Resuming)) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu); + MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu); + if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu); } if (!usb_timer.running()) {