From 9cdb8ca244dcbea0c6d33b2ae40f9d7f059bf4c7 Mon Sep 17 00:00:00 2001 From: deram Date: Thu, 17 Sep 2020 13:41:13 +0300 Subject: [PATCH] SHOW_REMAINING_TIME for HD44780 character LCD (#19416) --- Marlin/Configuration_adv.h | 31 +++++++++++---------- Marlin/src/inc/SanityCheck.h | 6 ++-- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 29 ++++++++++++++++--- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d46ba55a9..214bf4afd 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1105,23 +1105,26 @@ #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) #endif -#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits - //#define SHOW_REMAINING_TIME // Display estimated time to completion +#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && (HAS_GRAPHICAL_LCD || HAS_CHARACTER_LCD) + //#define SHOW_REMAINING_TIME // Display estimated time to completion #if ENABLED(SHOW_REMAINING_TIME) - //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation - //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time + //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation + //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time #endif -#endif -#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing - #if ENABLED(LCD_PROGRESS_BAR) - #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar - #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message - #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) - //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it - //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar + #if HAS_GRAPHICAL_LCD + //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits + #endif + + #if HAS_CHARACTER_LCD + //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing + #if ENABLED(LCD_PROGRESS_BAR) + #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar + #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message + #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) + //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it + //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar + #endif #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1ee082720..9f15d7e5e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -692,8 +692,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif -#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, EXTENSIBLE_UI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Graphical LCD, TFT, or EXTENSIBLE_UI." +#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, HAS_CHARACTER_LCD, EXTENSIBLE_UI) + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI." #endif #if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) @@ -3055,8 +3055,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #if !HAS_GRAPHICAL_LCD #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." - #elif ENABLED(SHOW_REMAINING_TIME) - #error "SHOW_REMAINING_TIME currently requires a Graphical LCD." #endif #endif diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index 0a1177d63..3dc0925b4 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -845,10 +845,31 @@ void MarlinUI::draw_status_screen() { lcd_put_wchar('%'); char buffer[14]; - duration_t elapsed = print_job_timer.duration(); - const uint8_t len = elapsed.toDigital(buffer), - timepos = LCD_WIDTH - len - 1; - lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + uint8_t timepos = 0; + #if ENABLED(SHOW_REMAINING_TIME) + const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && (printingIsActive() || marlin_state == MF_SD_COMPLETE); + if (show_remain) { + #if ENABLED(USE_M73_REMAINING_TIME) + duration_t remaining = get_remaining_time(); + #else + uint8_t progress = get_progress_percent(); + uint32_t elapsed = print_job_timer.duration(); + duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; + #endif + const uint8_t len = remaining.toDigital(buffer); + timepos = LCD_WIDTH - 1 - len; + lcd_put_wchar(timepos, 2, 'R'); + } + #else + constexpr bool show_remain = false; + #endif + + if (!show_remain) { + duration_t elapsed = print_job_timer.duration(); + const uint8_t len = elapsed.toDigital(buffer); + timepos = LCD_WIDTH - 1 - len; + lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + } lcd_put_u8str(buffer); #if LCD_WIDTH >= 20