From 5f708d47ce779d1001f16283a9e1b903af67bf21 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 15 Oct 2017 01:40:34 -0500 Subject: [PATCH] Add LCD_SET_PROGRESS_MANUALLY --- Marlin/Configuration_adv.h | 3 + Marlin/Marlin_main.cpp | 25 +++++++- .../AlephObjects/TAZ4/Configuration_adv.h | 3 + .../Anet/A6/Configuration_adv.h | 3 + .../Anet/A8/Configuration_adv.h | 3 + .../BQ/Hephestos/Configuration_adv.h | 3 + .../BQ/WITBOX/Configuration_adv.h | 3 + .../Cartesio/Configuration_adv.h | 3 + .../Creality/CR-10/Configuration_adv.h | 3 + .../Felix/Configuration_adv.h | 3 + .../Folger Tech/i3-2020/Configuration_adv.h | 3 + .../Infitary/i3-M508/Configuration_adv.h | 3 + .../RigidBot/Configuration_adv.h | 3 + .../SCARA/Configuration_adv.h | 3 + .../Sanguinololu/Configuration_adv.h | 3 + .../TinyBoy2/Configuration_adv.h | 3 + .../Velleman/K8400/Configuration_adv.h | 3 + .../FLSUN/auto_calibrate/Configuration_adv.h | 3 + .../FLSUN/kossel_mini/Configuration_adv.h | 3 + .../delta/generic/Configuration_adv.h | 3 + .../delta/kossel_mini/Configuration_adv.h | 3 + .../delta/kossel_pro/Configuration_adv.h | 3 + .../delta/kossel_xl/Configuration_adv.h | 3 + .../gCreate/gMax1.5+/Configuration_adv.h | 3 + .../makibox/Configuration_adv.h | 3 + .../tvrrug/Round2/Configuration_adv.h | 3 + .../wt150/Configuration_adv.h | 3 + Marlin/ultralcd.cpp | 60 ++++++++++++------- Marlin/ultralcd.h | 4 ++ Marlin/ultralcd_impl_DOGM.h | 12 ++-- Marlin/ultralcd_impl_HD44780.h | 13 ++-- 31 files changed, 161 insertions(+), 31 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 3ed2a44b3..e837e658f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b196169d0..00292adfb 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6022,7 +6022,7 @@ inline void gcode_G92() { #if ENABLED(ULTIPANEL) if (lcd_detected()) { while (wait_for_user) idle(); - IS_SD_PRINTING ? LCD_MESSAGEPGM(MSG_RESUMING) : LCD_MESSAGEPGM(WELCOME_MSG); + print_job_timer.isPaused() ? LCD_MESSAGEPGM(WELCOME_MSG) : LCD_MESSAGEPGM(MSG_RESUMING); } #else while (wait_for_user) idle(); @@ -7241,6 +7241,24 @@ inline void gcode_M42() { #endif // AUTO_BED_LEVELING_UBL && UBL_G26_MESH_VALIDATION +#if ENABLED(ULTRA_LCD) && ENABLED(LCD_SET_PROGRESS_MANUALLY) + /** + * M73: Set percentage complete (for display on LCD) + * + * Example: + * M73 P25 ; Set progress to 25% + * + * Notes: + * This has no effect during an SD print job + */ + inline void gcode_M73() { + if (!IS_SD_PRINTING && parser.seen('P')) { + progress_bar_percent = parser.value_byte(); + NOMORE(progress_bar_percent, 100); + } + } +#endif // ULTRA_LCD && LCD_SET_PROGRESS_MANUALLY + /** * M75: Start print timer */ @@ -11090,6 +11108,11 @@ void process_next_command() { break; #endif // AUTO_BED_LEVELING_UBL && UBL_G26_MESH_VALIDATION + #if ENABLED(ULTRA_LCD) && ENABLED(LCD_SET_PROGRESS_MANUALLY) + case 73: // M73: Set print progress percentage + gcode_M73(); break; + #endif + case 75: // M75: Start print timer gcode_M75(); break; case 76: // M76: Pause print timer diff --git a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h index eec1b6c11..dbcdf7b24 100644 --- a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Anet/A6/Configuration_adv.h b/Marlin/example_configurations/Anet/A6/Configuration_adv.h index b4e0f6a73..e3cebb068 100644 --- a/Marlin/example_configurations/Anet/A6/Configuration_adv.h +++ b/Marlin/example_configurations/Anet/A6/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Anet/A8/Configuration_adv.h b/Marlin/example_configurations/Anet/A8/Configuration_adv.h index 039e0b59b..f41e4ffda 100644 --- a/Marlin/example_configurations/Anet/A8/Configuration_adv.h +++ b/Marlin/example_configurations/Anet/A8/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h b/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h index af68c5700..f04869c23 100644 --- a/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h b/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h index af68c5700..f04869c23 100644 --- a/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 61aa19e13..3de5111b5 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h b/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h index adfd6aa50..14150e1e2 100755 --- a/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h +++ b/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 03ae2b21d..38fcf602c 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h b/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h index ae7d57084..891571ea3 100644 --- a/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h +++ b/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h b/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h index 811e6d625..a381cb00e 100644 --- a/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h +++ b/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index e488c5141..d0ae01fb2 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 0a92aeeb0..cf4a82afe 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Sanguinololu/Configuration_adv.h b/Marlin/example_configurations/Sanguinololu/Configuration_adv.h index 00401a88e..2e8e793d7 100644 --- a/Marlin/example_configurations/Sanguinololu/Configuration_adv.h +++ b/Marlin/example_configurations/Sanguinololu/Configuration_adv.h @@ -524,6 +524,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h index 197f909d2..a6c9d07d3 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h b/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h index b3cfc51b1..dd889587e 100644 --- a/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h index 328600676..41023ea40 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -537,6 +537,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h index b7c896df1..2e39eded2 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -537,6 +537,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index b7c896df1..2e39eded2 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -537,6 +537,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index b7c896df1..2e39eded2 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -537,6 +537,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 9a519ec17..dd1922f12 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -542,6 +542,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index 0c04e6d92..1763794ce 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -537,6 +537,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h index 7bbc33476..31fcefc84 100644 --- a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h +++ b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index e8188d661..fad81700c 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 6dc73d621..29c1f4296 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/example_configurations/wt150/Configuration_adv.h b/Marlin/example_configurations/wt150/Configuration_adv.h index aed0fee48..9b5695b94 100644 --- a/Marlin/example_configurations/wt150/Configuration_adv.h +++ b/Marlin/example_configurations/wt150/Configuration_adv.h @@ -535,6 +535,9 @@ //#define LCD_PROGRESS_BAR_TEST #endif + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY + // This allows hosts to request long names for files and folders with M33 //#define LONG_FILENAME_HOST_SUPPORT diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index e86617bfb..c803b71b4 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -60,6 +60,10 @@ // Initialized by settings.load() int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2]; +#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD)) + uint8_t progress_bar_percent; +#endif + #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) millis_t previous_lcd_status_ms = 0; #endif @@ -603,36 +607,52 @@ void lcd_status_screen() { #endif #if ENABLED(LCD_PROGRESS_BAR) + + // + // HD44780 implements the following message blinking and + // message expiration because Status Line and Progress Bar + // share the same line on the display. + // + + // Set current percentage from SD when actively printing + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + if (IS_SD_PRINTING) + progress_bar_percent = card.percentDone(); + #endif + millis_t ms = millis(); + + // If the message will blink rather than expire... #if DISABLED(PROGRESS_MSG_ONCE) - if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) { + if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) progress_bar_ms = ms; - } #endif + #if PROGRESS_MSG_EXPIRE > 0 + // Handle message expire if (expire_status_ms > 0) { - #if ENABLED(SDSUPPORT) - if (card.isFileOpen()) { - // Expire the message when printing is active - if (IS_SD_PRINTING) { - if (ELAPSED(ms, expire_status_ms)) { - lcd_status_message[0] = '\0'; - expire_status_ms = 0; - } - } - else { - expire_status_ms += LCD_UPDATE_INTERVAL; - } - } - else { + + #if DISABLED(LCD_SET_PROGRESS_MANUALLY) + const uint8_t progress_bar_percent = card.percentDone(); + #endif + + // Expire the message if a job is active and the bar has ticks + if (progress_bar_percent > 2 && !print_job_timer.isPaused()) { + if (ELAPSED(ms, expire_status_ms)) { + lcd_status_message[0] = '\0'; expire_status_ms = 0; } - #else - expire_status_ms = 0; - #endif // SDSUPPORT + } + else { + // Defer message expiration before bar appears + // and during any pause (not just SD) + expire_status_ms += LCD_UPDATE_INTERVAL; + } } - #endif + + #endif // PROGRESS_MSG_EXPIRE + #endif // LCD_PROGRESS_BAR #if ENABLED(ULTIPANEL) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 0a50f173a..3b156ee98 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -168,6 +168,10 @@ #define LCD_CLICKED false #endif + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD)) + extern uint8_t progress_bar_percent; + #endif + #else // no LCD inline void lcd_update() {} diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 6f75143a0..886156ee1 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -535,7 +535,7 @@ static void lcd_implementation_status_screen() { // SD Card Symbol // - if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) { + if (card.isFileOpen() && PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) { // Upper box u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47) // Right edge @@ -559,7 +559,11 @@ static void lcd_implementation_status_screen() { PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION) ); - if (IS_SD_PRINTING) { + #if DISABLED(LCD_SET_PROGRESS_MANUALLY) + const uint8_t progress_bar_percent = card.percentDone(); + #endif + + if (progress_bar_percent > 1) { // // Progress bar solid part @@ -568,7 +572,7 @@ static void lcd_implementation_status_screen() { if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION))) // 50-51 (or just 50) u8g.drawBox( PROGRESS_BAR_X + 1, 50, - (uint16_t)((PROGRESS_BAR_WIDTH - 2) * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION) + (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2 - (TALL_FONT_CORRECTION) ); // @@ -579,7 +583,7 @@ static void lcd_implementation_status_screen() { if (PAGE_CONTAINS(41, 48)) { // Percent complete u8g.setPrintPos(55, 48); - u8g.print(itostr3(card.percentDone())); + u8g.print(itostr3(progress_bar_percent)); u8g.print('%'); } #endif diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index e25d4f61b..f1009697d 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -200,9 +200,9 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt #include "utf_mapper.h" #if ENABLED(LCD_PROGRESS_BAR) - static millis_t progress_bar_ms = 0; + static millis_t progress_bar_ms = 0; // Start millis of the current progress bar cycle #if PROGRESS_MSG_EXPIRE > 0 - static millis_t expire_status_ms = 0; + static millis_t expire_status_ms = 0; // millis at which to expire the status message #endif #define LCD_STR_PROGRESS "\x03\x04\x05" #endif @@ -841,10 +841,11 @@ static void lcd_implementation_status_screen() { // Draw the progress bar if the message has shown long enough // or if there is no message set. - if (card.isFileOpen() && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0])) { - const uint8_t percent = card.percentDone(); - if (percent) return lcd_draw_progress_bar(percent); - } + #if DISABLED(LCD_SET_PROGRESS_MANUALLY) + const uint8_t progress_bar_percent = card.percentDone(); + #endif + if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0])) + return lcd_draw_progress_bar(progress_bar_percent); #elif ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)