diff --git a/Marlin/src/gcode/stats/M31.cpp b/Marlin/src/gcode/stats/M31.cpp index a76ec7ee4d..ad48eae866 100644 --- a/Marlin/src/gcode/stats/M31.cpp +++ b/Marlin/src/gcode/stats/M31.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M31() { char buffer[22]; duration_t(print_job_timer.duration()).toString(buffer); - ui.set_status(buffer, ENABLED(DWIN_LCD_PROUI)); // No expire on ProUI + ui.set_status_no_expire(buffer); SERIAL_ECHO_MSG("Print time: ", buffer); } diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 44a87dbb1a..ba074e2560 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -852,7 +852,11 @@ #define HAS_MEDIA_SUBCALLS 1 #endif -#if ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) && !HAS_GRAPHICAL_TFT +#if ANY(SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) + #define HAS_TIME_DISPLAY 1 +#endif + +#if ANY(SHOW_PROGRESS_PERCENT, HAS_TIME_DISPLAY) && !HAS_GRAPHICAL_TFT #define HAS_EXTRA_PROGRESS 1 #endif diff --git a/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h b/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h index 524ff18778..c81c63f2ed 100644 --- a/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h +++ b/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h @@ -22,15 +22,15 @@ #pragma once /** - Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1 - Copyright: Public domain font. Share and enjoy. - Capital A Height: 6, '1' Height: 6 - Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9 - Font Bounding box w= 6 h= 9 x= 0 y=-2 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent = 6 descent=-2 - X Font ascent = 6 descent=-2 - Max Font ascent = 7 descent=-2 + * Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1 + * Copyright: Public domain font. Share and enjoy. + * Capital A Height: 6, '1' Height: 6 + * Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9 + * Font Bounding box w= 6 h= 9 x= 0 y=-2 + * Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 + * Pure Font ascent = 6 descent=-2 + * X Font ascent = 6 descent=-2 + * Max Font ascent = 7 descent=-2 */ #include const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_6x9") = { @@ -186,4 +186,5 @@ const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_ 0x00,0x50,0x00,0x90,0x90,0x90,0x70,0x04,0x09,0x09,0x06,0x01,0xFE,0x20,0x40,0x00, 0x90,0x90,0x90,0x70,0x90,0x60,0x04,0x08,0x08,0x06,0x01,0xFE,0x80,0x80,0xE0,0x90, 0x90,0xE0,0x80,0x80,0x04,0x08,0x08,0x06,0x01,0xFE,0x50,0x00,0x90,0x90,0x90,0x70, - 0x90,0x60}; + 0x90,0x60 +}; diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index d38d28c8cd..ad9e382661 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -91,6 +91,18 @@ #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT) #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT) +#define PCENTERED // Center percent value over progress bar, else right-align +#define PROGRESS_BAR_X TERN(PCENTERED, 54, 40) +#define PROGRESS_BAR_Y (EXTRAS_BASELINE + TERN(PCENTERED, 1, -3)) +#define PCT_X TERN(PCENTERED, PROGRESS_BAR_X, LCD_PIXEL_WIDTH - TERN(PRINT_PROGRESS_SHOW_DECIMALS, 5, 4) * INFO_FONT_WIDTH) +#define PCT_Y (EXTRAS_BASELINE + TERN(PCENTERED, 0, 3)) +#define PROGRESS_BAR_WIDTH TERN(PCENTERED, LCD_PIXEL_WIDTH - PROGRESS_BAR_X, PCT_X - PROGRESS_BAR_X - 1) +#define PROGRESS_BAR_HEIGHT TERN(PCENTERED, 4, 5) + +#if DISABLED(PCENTERED) && HAS_TIME_DISPLAY + #error "PCENTERED is required for extra progress display options." +#endif + #if ANIM_HBCC enum HeatBits : uint8_t { DRAWBIT_HOTEND, @@ -188,10 +200,6 @@ } #endif -#define PROGRESS_BAR_X 54 -#define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1) -#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) - FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) { const char *str; uint8_t len; @@ -471,46 +479,44 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const // Prepare strings for progress display #if ANY(HAS_EXTRA_PROGRESS, HAS_PRINT_PROGRESS) static MarlinUI::progress_t progress = 0; - static char bufferc[13]; + static MString<12> progressString; #endif #if HAS_EXTRA_PROGRESS - static void prepare_time_string(const duration_t &time, char prefix) { - char str[13]; - 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 HAS_TIME_DISPLAY + static void prepare_time_string(const duration_t &time, char prefix) { + char str[10]; + const uint8_t time_len = time.toDigital(str, time.value >= 60*60*24L); // 5 to 8 chars + progressString.set(prefix, ':', spaces_t(10 - time_len), str); // 2 to 5 spaces + } + #endif #if ENABLED(SHOW_PROGRESS_PERCENT) void MarlinUI::drawPercent() { - 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] = '%'; - } + if (progress == 0) return; + progressString.set( + OPTITEM(PCENTERED, spaces_t(4)) + TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), '%' + ); } #endif #if ENABLED(SHOW_REMAINING_TIME) void MarlinUI::drawRemain() { if (printJobOngoing() && get_remaining_time() != 0) - prepare_time_string(get_remaining_time(), 'R'); } + prepare_time_string(get_remaining_time(), 'R'); + } #endif #if ENABLED(SHOW_INTERACTION_TIME) void MarlinUI::drawInter() { if (printingIsActive() && interaction_time) - prepare_time_string(interaction_time, 'C'); } + prepare_time_string(interaction_time, 'C'); + } #endif #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { if (printJobOngoing()) - prepare_time_string(print_job_timer.duration(), 'E'); } + prepare_time_string(print_job_timer.duration(), 'E'); + } #endif #endif // HAS_EXTRA_PROGRESS @@ -779,17 +785,17 @@ void MarlinUI::draw_status_screen() { #if HAS_PRINT_PROGRESS // Progress bar frame - if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3)) - u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4); + if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 1)) + u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT); // Progress bar solid part - if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2)) - u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2); + if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 3)) + u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, PROGRESS_BAR_HEIGHT - 2); // Progress strings - if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) { + if (PAGE_CONTAINS(PCT_Y - INFO_FONT_ASCENT, PCT_Y - 1)) { ui.rotate_progress(); - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc); + lcd_put_u8str(PCT_X, PCT_Y, progressString); } #endif diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index a6e942b706..2039d99635 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -664,15 +664,17 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { #if HAS_PRINT_PROGRESS static char screenstr[8]; - char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) { - static char str[6]; - memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles - screenstr[0] = prefix; - TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space - int str_length = time.toDigital(str); - memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator - return screenstr; - } + #if HAS_TIME_DISPLAY + char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) { + static char str[6]; + memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles + screenstr[0] = prefix; + TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space + int str_length = time.toDigital(str); + memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator + return screenstr; + } + #endif void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) { set_ddram_address(addr); @@ -687,7 +689,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { void ST7920_Lite_Status_Screen::drawPercent() { #define LSHIFT TERN(HOTENDS == 1, 0, 1) const uint8_t progress = ui.get_progress_percent(); - memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts + memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts if (progress){ memcpy(&screenstr[2 - LSHIFT], \ TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \ diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index d838ee1a3a..e096825f8a 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -83,8 +83,10 @@ class ST7920_Lite_Status_Screen { static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false); static void draw_fan_speed(const uint8_t value); #if HAS_PRINT_PROGRESS + #if HAS_TIME_DISPLAY + static char* prepare_time_string(const duration_t &time, char prefix=' '); + #endif static void draw_progress_bar(const uint8_t value); - static char* prepare_time_string(const duration_t &time, char prefix=' '); static void draw_progress_string(uint8_t addr, const char *str); static void update_progress(const bool forceUpdate); #endif diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp index 0dd12b1612..3a9ca9c762 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp @@ -105,7 +105,7 @@ void DGUSTxHandler::sdCardInsertionStatus(DGUS_VP &vp) { } #endif // PIDTEMPBED -static duration_t _PrintRemainingDurationEstimate() { +static duration_t _printRemainingDurationEstimate() { duration_t remainingDuration = 0; if (ExtUI::isPrinting()) { @@ -120,12 +120,12 @@ static duration_t _PrintRemainingDurationEstimate() { } void DGUSTxHandler::printRemainingHours(DGUS_VP &vp) { - const int16_t data = _PrintRemainingDurationEstimate().hour(); + const int16_t data = _printRemainingDurationEstimate().hour(); dgus.write((uint16_t)vp.addr, Endianness::toBE(data)); } void DGUSTxHandler::printRemainingMinutes(DGUS_VP &vp) { - const int16_t data = _PrintRemainingDurationEstimate().minute() % 60; + const int16_t data = _printRemainingDurationEstimate().minute() % 60; dgus.write((uint16_t)vp.addr, Endianness::toBE(data)); }