From 27c487bab744a22aeb580a0471591adba040bc68 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Wed, 17 Jul 2019 02:12:39 -0600 Subject: [PATCH] Print progress enhancements (#14647) --- Marlin/src/gcode/lcd/M117.cpp | 5 ++++- Marlin/src/gcode/lcd/M73.cpp | 4 ++-- Marlin/src/gcode/sdcard/M23.cpp | 5 +++++ Marlin/src/gcode/temperature/M104_M109.cpp | 2 +- Marlin/src/lcd/menu/menu.cpp | 4 ++++ Marlin/src/lcd/ultralcd.cpp | 4 +++- Marlin/src/lcd/ultralcd.h | 2 ++ Marlin/src/module/motion.cpp | 4 ++-- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/temperature.h | 2 +- Marlin/src/module/tool_change.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 8 +++----- Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 4 ++-- 13 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index 19cbbc2580..118b55fe37 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -28,6 +28,9 @@ */ void GcodeSuite::M117() { - ui.set_status(parser.string_arg); + if (parser.string_arg && parser.string_arg[0]) + ui.set_status(parser.string_arg); + else + ui.reset_status(); } diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 4ed7559835..85fb7831ea 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && EITHER(EXTENSIBLE_UI, ULTRA_LCD) +#if ENABLED(LCD_SET_PROGRESS_MANUALLY) #include "../gcode.h" #include "../../lcd/ultralcd.h" @@ -42,4 +42,4 @@ void GcodeSuite::M73() { ui.set_progress(parser.value_byte()); } -#endif // LCD_SET_PROGRESS_MANUALLY && (EXTENSIBLE_UI || ULTRA_LCD) +#endif // LCD_SET_PROGRESS_MANUALLY diff --git a/Marlin/src/gcode/sdcard/M23.cpp b/Marlin/src/gcode/sdcard/M23.cpp index 87aa213ddc..f170345c57 100644 --- a/Marlin/src/gcode/sdcard/M23.cpp +++ b/Marlin/src/gcode/sdcard/M23.cpp @@ -26,6 +26,7 @@ #include "../gcode.h" #include "../../sd/cardreader.h" +#include "../../lcd/ultralcd.h" /** * M23: Open a file @@ -36,6 +37,10 @@ void GcodeSuite::M23() { // Simplify3D includes the size, so zero out all spaces (#7227) for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0'; card.openFile(parser.string_arg, true); + + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + ui.set_progress(0); + #endif } #endif // SDSUPPORT diff --git a/Marlin/src/gcode/temperature/M104_M109.cpp b/Marlin/src/gcode/temperature/M104_M109.cpp index b17243851d..f4259abff9 100644 --- a/Marlin/src/gcode/temperature/M104_M109.cpp +++ b/Marlin/src/gcode/temperature/M104_M109.cpp @@ -125,7 +125,7 @@ void GcodeSuite::M109() { print_job_timer.start(); #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) thermalManager.set_heating_message(target_extruder); #endif diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 879c62476a..3d661c6f0f 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -204,6 +204,10 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co lcd_z_fade_height = planner.z_fade_height; #endif + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + progress_reset(); + #endif + #if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING) static millis_t doubleclick_expire_ms = 0; // Going to menu_main from status screen? Remember first click time. diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 169aa2f6f6..b932b4b4c5 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -1522,13 +1522,15 @@ void MarlinUI::update() { uint8_t MarlinUI::get_progress() { #if ENABLED(LCD_SET_PROGRESS_MANUALLY) uint8_t &progress = progress_bar_percent; + #define _PLIMIT(P) ((P) & 0x7F) #else + #define _PLIMIT(P) P uint8_t progress = 0; #endif #if ENABLED(SDSUPPORT) if (IS_SD_PRINTING()) progress = card.percentDone(); #endif - return progress; + return _PLIMIT(progress); } #endif diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 2325b5b959..f0fdbf764f 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -298,6 +298,8 @@ public: #if ENABLED(LCD_SET_PROGRESS_MANUALLY) static uint8_t progress_bar_percent; static void set_progress(const uint8_t progress) { progress_bar_percent = _MIN(progress, 100); } + static void set_progress_done() { set_progress(0x80 + 100); } + static bool progress_reset() { if (progress_bar_percent & 0x80) set_progress(0); } #endif static uint8_t get_progress(); #else diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 5ba992eea5..8f5da0b22a 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -51,7 +51,7 @@ #include "../feature/bltouch.h" #endif -#if EITHER(ULTRA_LCD, EXTENSIBLE_UI) +#if HAS_DISPLAY #include "../lcd/ultralcd.h" #endif @@ -1044,7 +1044,7 @@ bool axis_unhomed_error(const bool x/*=true*/, const bool y/*=true*/, const bool if (zz) SERIAL_CHAR('Z'); SERIAL_ECHOLNPGM(" " MSG_FIRST); - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY ui.status_printf_P(0, PSTR(MSG_HOME " %s%s%s " MSG_FIRST), xx ? MSG_X : "", yy ? MSG_Y : "", zz ? MSG_Z : ""); #endif return true; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0cdce6dc72..f32d689ef6 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2923,7 +2923,7 @@ void Temperature::isr() { #endif // AUTO_REPORT_TEMPERATURES - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY void Temperature::set_heating_message(const uint8_t e) { const bool heating = isHeatingHotend(e); #if HOTENDS > 1 diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 8c69e13169..becec0770d 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -785,7 +785,7 @@ class Temperature { #endif #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY static void set_heating_message(const uint8_t e); #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index c113678a0d..73f3716960 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -982,7 +982,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) { singlenozzle_temp[active_extruder] = thermalManager.temp_hotend[0].target; if (singlenozzle_temp[tmp_extruder] && singlenozzle_temp[tmp_extruder] != singlenozzle_temp[active_extruder]) { thermalManager.setTargetHotend(singlenozzle_temp[tmp_extruder], 0); - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY thermalManager.set_heating_message(0); #endif (void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index bc67e3de4e..0ee57c019e 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1008,18 +1008,16 @@ void CardReader::printingHasFinished() { #endif print_job_timer.stop(); - if (print_job_timer.duration() > 60) queue.inject_P(PSTR("M31")); + queue.enqueue_now_P(print_job_timer.duration() > 60 ? PSTR("M31") : PSTR("M117")); #if ENABLED(SDCARD_SORT_ALPHA) presort(); #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) && ENABLED(LCD_SET_PROGRESS_MANUALLY) - ui.progress_bar_percent = 0; + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + ui.set_progress_done(); #endif - ui.reset_status(); - #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) ui.reselect_last_file(); #endif diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 05cc1fd855..d63a2b9f0f 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -31,7 +31,7 @@ #include "Sd2Card_FlashDrive.h" -#if EITHER(ULTRA_LCD, EXTENSIBLE_UI) +#if HAS_DISPLAY #include "../../lcd/ultralcd.h" #endif @@ -63,7 +63,7 @@ void Sd2Card::idle() { SERIAL_ECHOPGM("Starting USB host..."); if (!usb.start()) { SERIAL_ECHOPGM(" Failed. Retrying in 2s."); - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY LCD_MESSAGEPGM("USB start failed"); #endif state = USB_HOST_DELAY_INIT;