🚸 Progress display followup (#24879)
This commit is contained in:
committed by
Scott Lahteine
parent
c86f20010d
commit
0efeedf262
@ -760,7 +760,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
#if HAS_PRINT_PROGRESS
|
||||
#define TPOFFSET (LCD_WIDTH - 1)
|
||||
static uint8_t timepos = TPOFFSET - 6;
|
||||
static char buffer[14];
|
||||
static char buffer[8];
|
||||
static lcd_uint_t pc, pr;
|
||||
|
||||
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
||||
@ -776,9 +776,10 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
#endif
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
void MarlinUI::drawRemain() {
|
||||
const duration_t remaint = ui.get_remaining_time();
|
||||
if (printJobOngoing()) {
|
||||
const duration_t remaint = ui.get_remaining_time();
|
||||
timepos = TPOFFSET - remaint.toDigital(buffer);
|
||||
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
|
||||
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'R');
|
||||
lcd_put_u8str(buffer);
|
||||
}
|
||||
@ -789,6 +790,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
const duration_t interactt = ui.interaction_time;
|
||||
if (printingIsActive() && interactt.value) {
|
||||
timepos = TPOFFSET - interactt.toDigital(buffer);
|
||||
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
|
||||
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'C');
|
||||
lcd_put_u8str(buffer);
|
||||
}
|
||||
@ -796,11 +798,11 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
#endif
|
||||
#if ENABLED(SHOW_ELAPSED_TIME)
|
||||
void MarlinUI::drawElapsed() {
|
||||
const duration_t elapsedt = print_job_timer.duration();
|
||||
if (printJobOngoing()) {
|
||||
const duration_t elapsedt = print_job_timer.duration();
|
||||
timepos = TPOFFSET - elapsedt.toDigital(buffer);
|
||||
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
|
||||
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'E');
|
||||
//lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]);
|
||||
lcd_put_u8str(buffer);
|
||||
}
|
||||
}
|
||||
@ -919,7 +921,7 @@ void MarlinUI::draw_status_screen() {
|
||||
#if LCD_WIDTH < 20
|
||||
|
||||
#if HAS_PRINT_PROGRESS
|
||||
pc = 0, pr = 2;
|
||||
pc = 0; pr = 2;
|
||||
rotate_progress();
|
||||
#endif
|
||||
|
||||
@ -1006,14 +1008,14 @@ void MarlinUI::draw_status_screen() {
|
||||
#if LCD_WIDTH >= 20
|
||||
|
||||
#if HAS_PRINT_PROGRESS
|
||||
pc = timepos - 7, pr = 2;
|
||||
pc = 6; pr = 2;
|
||||
rotate_progress();
|
||||
#else
|
||||
char c;
|
||||
uint16_t per;
|
||||
#if HAS_FAN0
|
||||
if (true
|
||||
#if EXTRUDERS && ENABLED(ADAPTIVE_FAN_SLOWING)
|
||||
#if BOTH(HAS_EXTRUDERS, ADAPTIVE_FAN_SLOWING)
|
||||
&& (blink || thermalManager.fan_speed_scaler[0] < 128)
|
||||
#endif
|
||||
) {
|
||||
@ -1087,7 +1089,7 @@ void MarlinUI::draw_status_screen() {
|
||||
_draw_bed_status(blink);
|
||||
#elif HAS_PRINT_PROGRESS
|
||||
#define DREW_PRINT_PROGRESS 1
|
||||
pc = 0, pr = 2;
|
||||
pc = 0; pr = 2;
|
||||
rotate_progress();
|
||||
#endif
|
||||
|
||||
@ -1095,7 +1097,7 @@ void MarlinUI::draw_status_screen() {
|
||||
// All progress strings
|
||||
//
|
||||
#if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS
|
||||
pc = LCD_WIDTH - 9, pr = 2;
|
||||
pc = LCD_WIDTH - 9; pr = 2;
|
||||
rotate_progress();
|
||||
#endif
|
||||
#endif // LCD_INFO_SCREEN_STYLE 1
|
||||
|
@ -596,23 +596,58 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
|
||||
#endif // HAS_CUTTER
|
||||
|
||||
#if HAS_PRINT_PROGRESS
|
||||
|
||||
FORCE_INLINE void _draw_print_progress() {
|
||||
if (!PanelDetected) return;
|
||||
const uint8_t progress = ui._get_progress();
|
||||
#if ENABLED(SDSUPPORT)
|
||||
lcd_put_u8str(F("SD"));
|
||||
#elif ENABLED(SET_PROGRESS_PERCENT)
|
||||
lcd_put_u8str(F("P:"));
|
||||
#endif
|
||||
if (progress)
|
||||
lcd.print(ui8tostr3rj(progress));
|
||||
else
|
||||
lcd_put_u8str(F("---"));
|
||||
lcd.write('%');
|
||||
}
|
||||
#if HAS_PRINT_PROGRESS // UNTESTED!!!
|
||||
#define TPOFFSET (LCD_WIDTH - 1)
|
||||
static uint8_t timepos = TPOFFSET - 6;
|
||||
|
||||
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
||||
void MarlinUI::drawPercent() {
|
||||
const uint8_t progress = ui.get_progress_percent();
|
||||
if (progress) {
|
||||
lcd_moveto(0, 2);
|
||||
lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:")));
|
||||
lcd.print(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)));
|
||||
lcd.write('%');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
void MarlinUI::drawRemain() {
|
||||
if (printJobOngoing()) {
|
||||
const duration_t remaint = ui.get_remaining_time();
|
||||
char buffer[10];
|
||||
timepos = TPOFFSET - remaint.toDigital(buffer);
|
||||
lcd_moveto(timepos, 1);
|
||||
lcd.write('R');
|
||||
lcd.print(buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(SHOW_INTERACTION_TIME)
|
||||
void MarlinUI::drawInter() {
|
||||
const duration_t interactt = ui.interaction_time;
|
||||
if (printingIsActive() && interactt.value) {
|
||||
char buffer[10];
|
||||
timepos = TPOFFSET - interactt.toDigital(buffer);
|
||||
lcd_moveto(timepos, 1);
|
||||
lcd.write('C');
|
||||
lcd.print(buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(SHOW_ELAPSED_TIME)
|
||||
void MarlinUI::drawElapsed() {
|
||||
if (printJobOngoing()) {
|
||||
const duration_t elapsedt = print_job_timer.duration();
|
||||
char buffer[10];
|
||||
timepos = TPOFFSET - elapsedt.toDigital(buffer);
|
||||
lcd_moveto(timepos, 1);
|
||||
lcd.write('E');
|
||||
lcd.print(buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // HAS_PRINT_PROGRESS
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
@ -796,23 +831,12 @@ void MarlinUI::draw_status_screen() {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Line 2 - feedrate, , time
|
||||
// Line 2 - feedrate, progress %, progress time
|
||||
//
|
||||
|
||||
lcd_moveto(0, 1);
|
||||
lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%');
|
||||
|
||||
#if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS)
|
||||
lcd_moveto(LCD_WIDTH / 2 - 3, 1);
|
||||
_draw_print_progress();
|
||||
#endif
|
||||
|
||||
char buffer[10];
|
||||
duration_t elapsed = print_job_timer.duration();
|
||||
uint8_t len = elapsed.toDigital(buffer);
|
||||
|
||||
lcd_moveto((LCD_WIDTH - 1) - len, 1);
|
||||
lcd.write(LCD_STR_CLOCK[0]); lcd.print(buffer);
|
||||
ui.rotate_progress(); // UNTESTED!!!
|
||||
|
||||
//
|
||||
// Line 3 - progressbar
|
||||
|
@ -445,50 +445,44 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
|
||||
// Prepare strings for progress display
|
||||
#if HAS_PRINT_PROGRESS
|
||||
#define _PRGR_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
|
||||
#define PCENTERED 1 // center percent value over progress bar, else align to the right
|
||||
static uint8_t lastProgress = 0xFF;
|
||||
static u8g_uint_t progress_bar_solid_width = 0;
|
||||
static MarlinUI::progress_t progress = 0;
|
||||
static char bufferc[13];
|
||||
|
||||
static void prepare_time_string(const duration_t &time, char prefix) {
|
||||
char str[9];
|
||||
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
|
||||
bufferc[0] = prefix;
|
||||
bufferc[1] = ':';
|
||||
int str_length = time.toDigital(str, time.value >= 60*60*24L);
|
||||
strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str);
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
||||
static char progress_string[5];
|
||||
static u8g_uint_t progress_x_pos;
|
||||
void MarlinUI::drawPercent() {
|
||||
if (progress_string[0]) {
|
||||
lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string);
|
||||
lcd_put_u8str(F("%"));
|
||||
if (progress != 0) {
|
||||
#define PCENTERED 1 // center percent value over progress bar, else align to the right
|
||||
#define PPOS TERN(PCENTERED, 4, 0)
|
||||
#define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)
|
||||
memset(&bufferc, 0x20, 12);
|
||||
memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN);
|
||||
bufferc[PPOS+PLEN] = '%';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
static char remaining_string[10];
|
||||
static u8g_uint_t remaining_x_pos = 0;
|
||||
void MarlinUI::drawRemain() {
|
||||
if (printJobOngoing()){
|
||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:"));
|
||||
lcd_put_u8str(remaining_x_pos, EXTRAS_BASELINE, remaining_string);
|
||||
}
|
||||
}
|
||||
if (printJobOngoing() && get_remaining_time() != 0)
|
||||
prepare_time_string(get_remaining_time(), 'R'); }
|
||||
#endif
|
||||
#if ENABLED(SHOW_INTERACTION_TIME)
|
||||
static char interaction_string[10];
|
||||
static u8g_uint_t interaction_x_pos = 0;
|
||||
void MarlinUI::drawInter() {
|
||||
if (printingIsActive() && interaction_string[0]) {
|
||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("C:"));
|
||||
lcd_put_u8str(interaction_x_pos, EXTRAS_BASELINE, interaction_string);
|
||||
}
|
||||
}
|
||||
if (printingIsActive() && interaction_time)
|
||||
prepare_time_string(interaction_time, 'C'); }
|
||||
#endif
|
||||
#if ENABLED(SHOW_ELAPSED_TIME)
|
||||
static char elapsed_string[10];
|
||||
static u8g_uint_t elapsed_x_pos = 0;
|
||||
static uint8_t lastElapsed;
|
||||
void MarlinUI::drawElapsed() {
|
||||
if (printJobOngoing()) {
|
||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:"));
|
||||
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
|
||||
}
|
||||
}
|
||||
if (printJobOngoing())
|
||||
prepare_time_string(print_job_timer.duration(), 'E'); }
|
||||
#endif
|
||||
#endif // HAS_PRINT_PROGRESS
|
||||
|
||||
@ -514,6 +508,8 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
|
||||
|
||||
static u8g_uint_t progress_bar_solid_width = 0;
|
||||
|
||||
// At the first page, generate new display values
|
||||
if (first_page) {
|
||||
#if ANIM_HBCC
|
||||
@ -551,59 +547,16 @@ void MarlinUI::draw_status_screen() {
|
||||
strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
|
||||
#endif
|
||||
|
||||
// Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
|
||||
// Progress update to avoid float math on each LCD draw
|
||||
#if HAS_PRINT_PROGRESS
|
||||
const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
|
||||
duration_t elapsedt = print_job_timer.duration();
|
||||
const uint8_t p = progress & 0xFF, ev = elapsedt.value & 0xFF;
|
||||
progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
|
||||
|
||||
static uint8_t lastProgress = 0xFF;
|
||||
const uint8_t p = progress & 0xFF;
|
||||
if (p != lastProgress) {
|
||||
lastProgress = p;
|
||||
|
||||
progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);
|
||||
|
||||
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
||||
if (progress == 0)
|
||||
progress_string[0] = '\0';
|
||||
else
|
||||
strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
|
||||
progress_x_pos = TERN(PCENTERED, 77, _PRGR_INFO_X(strlen(progress_string) + 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_INTERACTION_TIME)
|
||||
if (!(interaction_time)) {
|
||||
interaction_string[0] = '\0';
|
||||
interaction_x_pos = _PRGR_INFO_X(0);
|
||||
}
|
||||
else {
|
||||
const duration_t interactt = ui.interaction_time;
|
||||
interactt.toDigital(interaction_string, interactt.value >= 60*60*24L);
|
||||
interaction_x_pos = _PRGR_INFO_X(strlen(interaction_string));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(SHOW_ELAPSED_TIME)
|
||||
if (ev != lastElapsed) {
|
||||
lastElapsed = ev;
|
||||
const uint8_t len = elapsedt.toDigital(elapsed_string, elapsedt.value >= 60*60*24L);
|
||||
elapsed_x_pos = _PRGR_INFO_X(len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
if (!(ev & 0x3)) {
|
||||
uint32_t timeval = get_remaining_time();
|
||||
if (!timeval) {
|
||||
remaining_string[0] = '\0';
|
||||
remaining_x_pos = _PRGR_INFO_X(0);
|
||||
}
|
||||
else {
|
||||
const duration_t remaint = timeval;
|
||||
const uint8_t len = remaint.toDigital(remaining_string, remaint.value >= 60*60*24L);
|
||||
remaining_x_pos = _PRGR_INFO_X(len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -796,8 +749,10 @@ void MarlinUI::draw_status_screen() {
|
||||
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
|
||||
|
||||
// Progress strings
|
||||
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1))
|
||||
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)){
|
||||
ui.rotate_progress();
|
||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -366,6 +366,8 @@ void MarlinUI::draw_status_screen() {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO!
|
||||
|
||||
//
|
||||
// Elapsed time
|
||||
//
|
||||
|
Reference in New Issue
Block a user