Skip to content

Commit 8684cef

Browse files
committed
SHOW_REMAINING_TIME for HD44780 character LCD (MarlinFirmware#19416)
1 parent a52afd2 commit 8684cef

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

Marlin/Configuration_adv.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,23 +1105,26 @@
11051105
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11061106
#endif
11071107

1108-
#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
1109-
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
1110-
//#define SHOW_REMAINING_TIME // Display estimated time to completion
1108+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && (HAS_GRAPHICAL_LCD || HAS_CHARACTER_LCD)
1109+
//#define SHOW_REMAINING_TIME // Display estimated time to completion
11111110
#if ENABLED(SHOW_REMAINING_TIME)
1112-
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1113-
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
1111+
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1112+
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
1113+
#endif
1114+
1115+
#if HAS_GRAPHICAL_LCD
1116+
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
11141117
#endif
1115-
#endif
11161118

1117-
#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
1118-
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
1119-
#if ENABLED(LCD_PROGRESS_BAR)
1120-
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
1121-
#define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
1122-
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
1123-
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
1124-
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
1119+
#if HAS_CHARACTER_LCD
1120+
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
1121+
#if ENABLED(LCD_PROGRESS_BAR)
1122+
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
1123+
#define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
1124+
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
1125+
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
1126+
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
1127+
#endif
11251128
#endif
11261129
#endif
11271130

Marlin/src/inc/SanityCheck.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
692692
#elif PROGRESS_MSG_EXPIRE < 0
693693
#error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0."
694694
#endif
695-
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, EXTENSIBLE_UI)
696-
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Graphical LCD, TFT, or EXTENSIBLE_UI."
695+
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, HAS_CHARACTER_LCD, EXTENSIBLE_UI)
696+
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI."
697697
#endif
698698

699699
#if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
@@ -3042,8 +3042,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
30423042
#if !HAS_GRAPHICAL_LCD
30433043
#if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS)
30443044
#error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD."
3045-
#elif ENABLED(SHOW_REMAINING_TIME)
3046-
#error "SHOW_REMAINING_TIME currently requires a Graphical LCD."
30473045
#endif
30483046
#endif
30493047

Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,31 @@ void MarlinUI::draw_status_screen() {
865865
lcd_put_wchar('%');
866866

867867
char buffer[14];
868-
duration_t elapsed = print_job_timer.duration();
869-
const uint8_t len = elapsed.toDigital(buffer),
870-
timepos = LCD_WIDTH - len - 1;
871-
lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]);
868+
uint8_t timepos = 0;
869+
#if ENABLED(SHOW_REMAINING_TIME)
870+
const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && (printingIsActive() || marlin_state == MF_SD_COMPLETE);
871+
if (show_remain) {
872+
#if ENABLED(USE_M73_REMAINING_TIME)
873+
duration_t remaining = get_remaining_time();
874+
#else
875+
uint8_t progress = get_progress_percent();
876+
uint32_t elapsed = print_job_timer.duration();
877+
duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0;
878+
#endif
879+
const uint8_t len = remaining.toDigital(buffer);
880+
timepos = LCD_WIDTH - 1 - len;
881+
lcd_put_wchar(timepos, 2, 'R');
882+
}
883+
#else
884+
constexpr bool show_remain = false;
885+
#endif
886+
887+
if (!show_remain) {
888+
duration_t elapsed = print_job_timer.duration();
889+
const uint8_t len = elapsed.toDigital(buffer);
890+
timepos = LCD_WIDTH - 1 - len;
891+
lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]);
892+
}
872893
lcd_put_u8str(buffer);
873894

874895
#if LCD_WIDTH >= 20

0 commit comments

Comments
 (0)