From 2ba24fe0d459297bf03bfe81ddffaa31d880edd9 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 3 Feb 2021 10:42:25 +0100 Subject: [PATCH] Add pause/resume to USB/host prints via LCD menu Depending if SD or USB/host print the firmware sends - SD print: `// action:paused` or `// action:resumed` are send to inform USB/Host - USB/host print: `// action:pause` or `// action:resume` are send to trigger the USB/host to handle it - USB/host must handle `// action:pause` and `// action:resume` correctly to work - Tested with Octoprint - It handles every thing correctly - Any combination of Octoprint and/or LCD `pause` and `resume` working correctly - Tested with Pronterface - It pauses BUT doesn't send the printer in pause position, and so it is not possible to `resume` from LCD menu - I guess some Macros can fix that. - Repetier Host/Server documentation shows that it should work. Not tested. Could save 56 bytes in first step and additional 38 bytes adding `MSG_PAUSE_PRINT` to messages.c/.h Updated `lang_en*.txt` @todo Polish translation is 19 characters long (it still fits) BUT should be corrected to 18 chars. --- Firmware/messages.c | 3 ++ Firmware/messages.h | 3 ++ Firmware/ultralcd.cpp | 92 ++++++++++++++++++++++++++----------------- lang/lang_en.txt | 2 +- lang/lang_en_cz.txt | 2 +- lang/lang_en_de.txt | 2 +- lang/lang_en_es.txt | 2 +- lang/lang_en_fr.txt | 2 +- lang/lang_en_it.txt | 2 +- lang/lang_en_pl.txt | 2 +- 10 files changed, 68 insertions(+), 44 deletions(-) diff --git a/Firmware/messages.c b/Firmware/messages.c index 0b1d58e0..950efcd3 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -70,6 +70,7 @@ const char MSG_MMU_LOAD_FAILS[] PROGMEM_I1 = ISTR("MMU load fails"); ////c=14 const char MSG_NO[] PROGMEM_I1 = ISTR("No"); //// const char MSG_NOZZLE[] PROGMEM_I1 = ISTR("Nozzle"); //// const char MSG_PAPER[] PROGMEM_I1 = ISTR("Place a sheet of paper under the nozzle during the calibration of first 4 points. If the nozzle catches the paper, power off the printer immediately."); ////c=20 r=10 +const char MSG_PAUSE_PRINT[] PROGMEM_I1 = ISTR("Pause print");////c=18 const char MSG_PLACE_STEEL_SHEET[] PROGMEM_I1 = ISTR("Please place steel sheet on heatbed."); ////c=20 r=4 const char MSG_PLEASE_WAIT[] PROGMEM_I1 = ISTR("Please wait"); ////c=20 const char MSG_POWER_FAILURES[] PROGMEM_I1 = ISTR("Power failures"); ////c=14 @@ -188,7 +189,9 @@ const char MSG_ENDSTOP_OPEN[] PROGMEM_N1 = "open"; //// const char MSG_POWERUP[] PROGMEM_N1 = "PowerUp"; //// const char MSG_ERR_STOPPED[] PROGMEM_N1 = "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"; //// const char MSG_ENDSTOP_HIT[] PROGMEM_N1 = "TRIGGERED"; //// +const char MSG_OCTOPRINT_PAUSE[] PROGMEM_N1 = "// action:pause"; //// const char MSG_OCTOPRINT_PAUSED[] PROGMEM_N1 = "// action:paused"; //// +const char MSG_OCTOPRINT_RESUME[] PROGMEM_N1 = "// action:resume"; //// const char MSG_OCTOPRINT_RESUMED[] PROGMEM_N1 = "// action:resumed"; //// const char MSG_OCTOPRINT_CANCEL[] PROGMEM_N1 = "// action:cancel"; //// const char MSG_FANCHECK_EXTRUDER[] PROGMEM_N1 = "Err: EXTR. FAN ERROR"; ////c=20 diff --git a/Firmware/messages.h b/Firmware/messages.h index 0a05c58f..c99a77d9 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -69,6 +69,7 @@ extern const char MSG_MMU_LOAD_FAILS[]; extern const char MSG_NO[]; extern const char MSG_NOZZLE[]; extern const char MSG_PAPER[]; +extern const char MSG_PAUSE_PRINT[]; extern const char MSG_PLACE_STEEL_SHEET[]; extern const char MSG_PLEASE_WAIT[]; extern const char MSG_POWER_FAILURES[]; @@ -188,7 +189,9 @@ extern const char MSG_ERR_STOPPED[]; extern const char MSG_ENDSTOP_HIT[]; extern const char MSG_EJECT_FILAMENT[]; extern const char MSG_CUT_FILAMENT[]; +extern const char MSG_OCTOPRINT_PAUSE[]; extern const char MSG_OCTOPRINT_PAUSED[]; +extern const char MSG_OCTOPRINT_RESUME[]; extern const char MSG_OCTOPRINT_RESUMED[]; extern const char MSG_OCTOPRINT_CANCEL[]; extern const char MSG_FANCHECK_EXTRUDER[]; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0f6bc1fa..94fa0da4 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1539,6 +1539,12 @@ void lcd_pause_print() } } +//! @brief Pause USB/host print, disable nozzle heater, move to park position +void lcd_pause_usb_print() +{ + SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSE); //pause for octoprint +} + float move_menu_scale; static void lcd_move_menu_axis(); @@ -6497,6 +6503,12 @@ void lcd_resume_print() SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUMED); //resume octoprint } +//! @brief Resume paused USB/host print +void lcd_resume_usb_print() +{ + SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUME); //resume octoprint +} + static void change_sheet() { eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet); @@ -6631,44 +6643,50 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT } - - if(isPrintPaused && saved_printing_type == PRINTING_TYPE_USB) + if (mesh_bed_leveling_flag == false && homing_flag == false && !isPrintPaused) { -#ifdef FANCHECK - if((fan_check_error == EFCE_FIXED) || (fan_check_error == EFCE_OK)) - MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 -#else - MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 -#endif + if (IS_SD_PRINTING) + { + MENU_ITEM_FUNCTION_P(_T(MSG_PAUSE_PRINT), lcd_pause_print);////MSG_PAUSE_PRINT c=18 + } + else if (is_usb_printing) + { + MENU_ITEM_FUNCTION_P(_T(MSG_PAUSE_PRINT), lcd_pause_usb_print);////MSG_PAUSE_PRINT c=18 + } } - -#ifdef SDSUPPORT + if(isPrintPaused) + { + #ifdef FANCHECK + if((fan_check_error == EFCE_FIXED) || (fan_check_error == EFCE_OK)) + { + if (is_usb_printing) + { + MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_usb_print);////MSG_RESUME_PRINT c=18 + } + else + { + MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 + } + } + #else + if (is_usb_printing) + { + MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_usb_print);////MSG_RESUME_PRINT c=18 + } + else + { + MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 + } + #endif //FANCHECK + } + if(IS_SD_PRINTING || is_usb_printing || isPrintPaused) + { + MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); + } +#ifdef SDSUPPORT //!@todo SDSUPPORT undefined creates several issues in source code if (card.cardOK || lcd_commands_type == LcdCommands::Layer1Cal) { - if (card.isFileOpen()) - { - if (mesh_bed_leveling_flag == false && homing_flag == false) { - if (card.sdprinting) - { - MENU_ITEM_FUNCTION_P(_i("Pause print"), lcd_pause_print);////MSG_PAUSE_PRINT - } - else if(isPrintPaused) - { - #ifdef FANCHECK - if((fan_check_error == EFCE_FIXED) || (fan_check_error == EFCE_OK)) - MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 - #else - MENU_ITEM_SUBMENU_P(_T(MSG_RESUME_PRINT), lcd_resume_print);////MSG_RESUME_PRINT c=18 - #endif - - } - MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); - } - } - else if (lcd_commands_type == LcdCommands::Layer1Cal && mesh_bed_leveling_flag == false && homing_flag == false) { - //MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); - } - else + if (!card.isFileOpen()) { if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { @@ -6680,7 +6698,7 @@ static void lcd_main_menu() } #if SDCARDDETECT < 1 MENU_ITEM_GCODE_P(_i("Change SD card"), PSTR("M21")); // SD-card changed by user////MSG_CNG_SDCARD -#endif +#endif //SDCARDDETECT } } else @@ -6689,9 +6707,9 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_i("No SD card"), lcd_sdcard_menu);////MSG_NO_CARD #if SDCARDDETECT < 1 MENU_ITEM_GCODE_P(_i("Init. SD card"), PSTR("M21")); // Manually initialize the SD-card via user interface////MSG_INIT_SDCARD -#endif +#endif //SDCARDDETECT } -#endif +#endif //SDSUPPORT if(!isPrintPaused && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { diff --git a/lang/lang_en.txt b/lang/lang_en.txt index bcb0a444..d9f606ca 100644 --- a/lang/lang_en.txt +++ b/lang/lang_en.txt @@ -544,7 +544,7 @@ # "Nozzle FAN" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" #MSG_PID_RUNNING c=20 r=1 diff --git a/lang/lang_en_cz.txt b/lang/lang_en_cz.txt index 0b3d7b14..f8cf4bd8 100644 --- a/lang/lang_en_cz.txt +++ b/lang/lang_en_cz.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "Vent. trysky" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Pozastavit tisk" diff --git a/lang/lang_en_de.txt b/lang/lang_en_de.txt index 0a436a9e..df13e1d1 100644 --- a/lang/lang_en_de.txt +++ b/lang/lang_en_de.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "Duesevent." -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Druck pausieren" diff --git a/lang/lang_en_es.txt b/lang/lang_en_es.txt index 2e29fa20..30548327 100644 --- a/lang/lang_en_es.txt +++ b/lang/lang_en_es.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "Vent. capa" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Pausar impresion" diff --git a/lang/lang_en_fr.txt b/lang/lang_en_fr.txt index cc0cbb95..8cbf3a67 100644 --- a/lang/lang_en_fr.txt +++ b/lang/lang_en_fr.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "Vent. buse" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Pause de l'impr." diff --git a/lang/lang_en_it.txt b/lang/lang_en_it.txt index 8cd93908..919c2e56 100644 --- a/lang/lang_en_it.txt +++ b/lang/lang_en_it.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "Ventola estrusore" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Metti in pausa" diff --git a/lang/lang_en_pl.txt b/lang/lang_en_pl.txt index 38d1421f..31cb5a41 100644 --- a/lang/lang_en_pl.txt +++ b/lang/lang_en_pl.txt @@ -726,7 +726,7 @@ "Nozzle FAN" "WentHotend" -#MSG_PAUSE_PRINT +#MSG_PAUSE_PRINT c=18 "Pause print" "Wstrzymanie wydruku"