Fix Progress Display

This commit is contained in:
Robby Candra 2019-10-16 16:18:20 +07:00
parent e0e406dbcc
commit bf850827f7

View File

@ -347,9 +347,16 @@ void MarlinUI::draw_status_screen() {
static uint8_t lastElapsed = 0, elapsed_x_pos = 0; static uint8_t lastElapsed = 0, elapsed_x_pos = 0;
static char elapsed_string[16]; static char elapsed_string[16];
#if ENABLED(SHOW_REMAINING_TIME) #if ENABLED(SHOW_REMAINING_TIME)
#define SHOW_REMAINING_TIME_PREFIX 'E' #define SHOW_REMAINING_TIME_PREFIX 'R'
static uint8_t estimation_x_pos = 0; static uint8_t estimation_x_pos = 0;
static char estimation_string[10]; static char estimation_string[10];
#if ENABLED(DOGM_SD_PERCENT)
#define PROGRESS_TIME_PREFIX 'P'
#define ELAPSED_TIME_PREFIX 'E'
static uint8_t progress_x_pos = 0;
static uint8_t progress_state = 0;
static bool prev_blink = 0;
#endif
#endif #endif
#endif #endif
@ -401,6 +408,9 @@ void MarlinUI::draw_status_screen() {
ui8tostr3(progress / (PROGRESS_SCALE)) ui8tostr3(progress / (PROGRESS_SCALE))
#endif #endif
)); ));
#if ENABLED(SHOW_REMAINING_TIME) // Tristate progress display mode
progress_x_pos = _SD_DURATION_X(strlen(progress_string)+1);
#endif
#endif #endif
} }
@ -415,7 +425,11 @@ void MarlinUI::draw_status_screen() {
duration_t estimation = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress; duration_t estimation = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress;
const bool has_days = (estimation.value >= 60*60*24L); const bool has_days = (estimation.value >= 60*60*24L);
const uint8_t len = estimation.toDigital(estimation_string, has_days); const uint8_t len = estimation.toDigital(estimation_string, has_days);
estimation_x_pos = _SD_DURATION_X(len + 1); #if ENABLED(DOGM_SD_PERCENT)
estimation_x_pos = _SD_DURATION_X(len);
#else
estimation_x_pos = _SD_DURATION_X(len + 2);
#endif
} }
#endif #endif
} }
@ -563,35 +577,60 @@ void MarlinUI::draw_status_screen() {
if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50) if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50)
u8g.drawBox(PROGRESS_BAR_X + 1, 50, progress_bar_solid_width, 2); u8g.drawBox(PROGRESS_BAR_X + 1, 50, progress_bar_solid_width, 2);
//
// SD Percent Complete
//
#if ENABLED(DOGM_SD_PERCENT)
if (progress_string[0] != '\0')
if (PAGE_CONTAINS(41, 48)) {
// Percent complete
lcd_put_u8str(55, 48, progress_string);
lcd_put_wchar('%');
}
#endif
//
// Elapsed Time
//
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) { if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
#if ENABLED(SHOW_REMAINING_TIME) #if ENABLED(DOGM_SD_PERCENT) && ENABLED(SHOW_REMAINING_TIME)
if (blink && (estimation_string[0] != '\0')) { if (prev_blink != blink) {
lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, SHOW_REMAINING_TIME_PREFIX); prev_blink = blink;
lcd_put_u8str(estimation_string); progress_state++;
if (progress_state >=3) progress_state = 0;
} }
else
#endif
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
}
if (progress_state == 0) {
if (progress_string[0] != '\0') {
lcd_put_wchar(PROGRESS_BAR_X, EXTRAS_BASELINE, PROGRESS_TIME_PREFIX);
lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string);
lcd_put_wchar('%');
}
}
else if (progress_state == 2 && estimation_string[0] != '\0') {
lcd_put_wchar(PROGRESS_BAR_X, EXTRAS_BASELINE, SHOW_REMAINING_TIME_PREFIX);
lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string);
}
else {
lcd_put_wchar(PROGRESS_BAR_X, EXTRAS_BASELINE, ELAPSED_TIME_PREFIX);
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
}
#else
//
// SD Percent Complete
//
#if ENABLED(DOGM_SD_PERCENT)
if (progress_string[0] != '\0') {
// Percent complete
lcd_put_u8str(55, 48, progress_string);
lcd_put_wchar('%');
}
#endif
//
// Elapsed Time
//
#if ENABLED(SHOW_REMAINING_TIME)
if (blink && (estimation_string[0] != '\0')) {
lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, SHOW_REMAINING_TIME_PREFIX);
lcd_put_wchar(" ");
lcd_put_u8str(estimation_string);
}
else
#endif
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
#endif
}
#endif // HAS_PRINT_PROGRESS #endif // HAS_PRINT_PROGRESS
// //