Remaining Time for Prusa-style LCD layout (#20148)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
f1cdd02d4c
commit
04a3ece3e0
|
@ -707,6 +707,35 @@ void MarlinUI::draw_status_message(const bool blink) {
|
|||
* |01234567890123456789|
|
||||
*/
|
||||
|
||||
inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos) {
|
||||
char buffer[14];
|
||||
|
||||
#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
|
||||
timepos -= remaining.toDigital(buffer);
|
||||
lcd_put_wchar(timepos, 2, 'R');
|
||||
}
|
||||
#else
|
||||
constexpr bool show_remain = false;
|
||||
#endif
|
||||
|
||||
if (!show_remain) {
|
||||
duration_t elapsed = print_job_timer.duration();
|
||||
timepos -= elapsed.toDigital(buffer);
|
||||
lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]);
|
||||
}
|
||||
lcd_put_u8str(buffer);
|
||||
return timepos;
|
||||
}
|
||||
|
||||
void MarlinUI::draw_status_screen() {
|
||||
|
||||
const bool blink = get_blink();
|
||||
|
@ -845,33 +874,7 @@ void MarlinUI::draw_status_screen() {
|
|||
lcd_put_u8str(i16tostr3rj(feedrate_percentage));
|
||||
lcd_put_wchar('%');
|
||||
|
||||
char buffer[14];
|
||||
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);
|
||||
const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1);
|
||||
|
||||
#if LCD_WIDTH >= 20
|
||||
lcd_moveto(timepos - 7, 2);
|
||||
|
@ -955,7 +958,7 @@ void MarlinUI::draw_status_screen() {
|
|||
#elif HAS_MULTI_HOTEND && HAS_HEATED_BED
|
||||
_draw_bed_status(blink);
|
||||
#elif HAS_PRINT_PROGRESS
|
||||
#define DREW_PRINT_PROGRESS
|
||||
#define DREW_PRINT_PROGRESS 1
|
||||
_draw_print_progress();
|
||||
#endif
|
||||
|
||||
|
@ -963,14 +966,15 @@ void MarlinUI::draw_status_screen() {
|
|||
// Elapsed Time or SD Percent
|
||||
//
|
||||
lcd_moveto(LCD_WIDTH - 9, 2);
|
||||
#if HAS_PRINT_PROGRESS && !defined(DREW_PRINT_PROGRESS)
|
||||
|
||||
#if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS
|
||||
|
||||
_draw_print_progress();
|
||||
|
||||
#else
|
||||
duration_t elapsed = print_job_timer.duration();
|
||||
char buffer[14];
|
||||
(void)elapsed.toDigital(buffer);
|
||||
lcd_put_wchar(LCD_STR_CLOCK[0]);
|
||||
lcd_put_u8str(buffer);
|
||||
|
||||
(void)draw_elapsed_or_remaining_time(LCD_WIDTH - 4);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LCD_INFO_SCREEN_STYLE 1
|
||||
|
|
Loading…
Reference in a new issue