Skip to content

Commit da4839a

Browse files
mikemerryguythinkyhead
authored andcommitted
🚸 Adjust Progress / Completion (MarlinFirmware#26466)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent e9a36fd commit da4839a

File tree

7 files changed

+72
-57
lines changed

7 files changed

+72
-57
lines changed

‎Marlin/src/gcode/stats/M31.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void GcodeSuite::M31() {
3333
char buffer[22];
3434
duration_t(print_job_timer.duration()).toString(buffer);
3535

36-
ui.set_status(buffer, ENABLED(DWIN_LCD_PROUI)); // No expire on ProUI
36+
ui.set_status_no_expire(buffer);
3737

3838
SERIAL_ECHO_MSG("Print time: ", buffer);
3939
}

‎Marlin/src/inc/Conditionals_adv.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@
852852
#define HAS_MEDIA_SUBCALLS 1
853853
#endif
854854

855-
#if ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) && !HAS_GRAPHICAL_TFT
855+
#if ANY(SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME)
856+
#define HAS_TIME_DISPLAY 1
857+
#endif
858+
859+
#if ANY(SHOW_PROGRESS_PERCENT, HAS_TIME_DISPLAY) && !HAS_GRAPHICAL_TFT
856860
#define HAS_EXTRA_PROGRESS 1
857861
#endif
858862

‎Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
#pragma once
2323

2424
/**
25-
Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
26-
Copyright: Public domain font. Share and enjoy.
27-
Capital A Height: 6, '1' Height: 6
28-
Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9
29-
Font Bounding box w= 6 h= 9 x= 0 y=-2
30-
Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
31-
Pure Font ascent = 6 descent=-2
32-
X Font ascent = 6 descent=-2
33-
Max Font ascent = 7 descent=-2
25+
* Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
26+
* Copyright: Public domain font. Share and enjoy.
27+
* Capital A Height: 6, '1' Height: 6
28+
* Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9
29+
* Font Bounding box w= 6 h= 9 x= 0 y=-2
30+
* Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
31+
* Pure Font ascent = 6 descent=-2
32+
* X Font ascent = 6 descent=-2
33+
* Max Font ascent = 7 descent=-2
3434
*/
3535
#include <U8glib-HAL.h>
3636
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_
186186
0x00,0x50,0x00,0x90,0x90,0x90,0x70,0x04,0x09,0x09,0x06,0x01,0xFE,0x20,0x40,0x00,
187187
0x90,0x90,0x90,0x70,0x90,0x60,0x04,0x08,0x08,0x06,0x01,0xFE,0x80,0x80,0xE0,0x90,
188188
0x90,0xE0,0x80,0x80,0x04,0x08,0x08,0x06,0x01,0xFE,0x50,0x00,0x90,0x90,0x90,0x70,
189-
0x90,0x60};
189+
0x90,0x60
190+
};

‎Marlin/src/lcd/dogm/status_screen_DOGM.cpp

+37-31
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@
9191
#define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
9292
#define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
9393

94+
#define PCENTERED // Center percent value over progress bar, else right-align
95+
#define PROGRESS_BAR_X TERN(PCENTERED, 54, 40)
96+
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + TERN(PCENTERED, 1, -3))
97+
#define PCT_X TERN(PCENTERED, PROGRESS_BAR_X, LCD_PIXEL_WIDTH - TERN(PRINT_PROGRESS_SHOW_DECIMALS, 5, 4) * INFO_FONT_WIDTH)
98+
#define PCT_Y (EXTRAS_BASELINE + TERN(PCENTERED, 0, 3))
99+
#define PROGRESS_BAR_WIDTH TERN(PCENTERED, LCD_PIXEL_WIDTH - PROGRESS_BAR_X, PCT_X - PROGRESS_BAR_X - 1)
100+
#define PROGRESS_BAR_HEIGHT TERN(PCENTERED, 4, 5)
101+
102+
#if DISABLED(PCENTERED) && HAS_TIME_DISPLAY
103+
#error "PCENTERED is required for extra progress display options."
104+
#endif
105+
94106
#if ANIM_HBCC
95107
enum HeatBits : uint8_t {
96108
DRAWBIT_HOTEND,
@@ -188,10 +200,6 @@
188200
}
189201
#endif
190202

191-
#define PROGRESS_BAR_X 54
192-
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
193-
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
194-
195203
FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
196204
const char *str;
197205
uint8_t len;
@@ -471,46 +479,44 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
471479
// Prepare strings for progress display
472480
#if ANY(HAS_EXTRA_PROGRESS, HAS_PRINT_PROGRESS)
473481
static MarlinUI::progress_t progress = 0;
474-
static char bufferc[13];
482+
static MString<12> progressString;
475483
#endif
476484

477485
#if HAS_EXTRA_PROGRESS
478486

479-
static void prepare_time_string(const duration_t &time, char prefix) {
480-
char str[13];
481-
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
482-
bufferc[0] = prefix;
483-
bufferc[1] = ':';
484-
int str_length = time.toDigital(str, time.value >= 60*60*24L);
485-
strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str);
486-
}
487-
487+
#if HAS_TIME_DISPLAY
488+
static void prepare_time_string(const duration_t &time, char prefix) {
489+
char str[10];
490+
const uint8_t time_len = time.toDigital(str, time.value >= 60*60*24L); // 5 to 8 chars
491+
progressString.set(prefix, ':', spaces_t(10 - time_len), str); // 2 to 5 spaces
492+
}
493+
#endif
488494
#if ENABLED(SHOW_PROGRESS_PERCENT)
489495
void MarlinUI::drawPercent() {
490-
if (progress != 0) {
491-
#define PCENTERED 1 // center percent value over progress bar, else align to the right
492-
#define PPOS TERN(PCENTERED, 4, 0)
493-
#define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)
494-
memset(&bufferc, 0x20, 12);
495-
memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN);
496-
bufferc[PPOS+PLEN] = '%';
497-
}
496+
if (progress == 0) return;
497+
progressString.set(
498+
OPTITEM(PCENTERED, spaces_t(4))
499+
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), '%'
500+
);
498501
}
499502
#endif
500503
#if ENABLED(SHOW_REMAINING_TIME)
501504
void MarlinUI::drawRemain() {
502505
if (printJobOngoing() && get_remaining_time() != 0)
503-
prepare_time_string(get_remaining_time(), 'R'); }
506+
prepare_time_string(get_remaining_time(), 'R');
507+
}
504508
#endif
505509
#if ENABLED(SHOW_INTERACTION_TIME)
506510
void MarlinUI::drawInter() {
507511
if (printingIsActive() && interaction_time)
508-
prepare_time_string(interaction_time, 'C'); }
512+
prepare_time_string(interaction_time, 'C');
513+
}
509514
#endif
510515
#if ENABLED(SHOW_ELAPSED_TIME)
511516
void MarlinUI::drawElapsed() {
512517
if (printJobOngoing())
513-
prepare_time_string(print_job_timer.duration(), 'E'); }
518+
prepare_time_string(print_job_timer.duration(), 'E');
519+
}
514520
#endif
515521

516522
#endif // HAS_EXTRA_PROGRESS
@@ -779,17 +785,17 @@ void MarlinUI::draw_status_screen() {
779785

780786
#if HAS_PRINT_PROGRESS
781787
// Progress bar frame
782-
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3))
783-
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4);
788+
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 1))
789+
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT);
784790

785791
// Progress bar solid part
786-
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2))
787-
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
792+
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 3))
793+
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, PROGRESS_BAR_HEIGHT - 2);
788794

789795
// Progress strings
790-
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
796+
if (PAGE_CONTAINS(PCT_Y - INFO_FONT_ASCENT, PCT_Y - 1)) {
791797
ui.rotate_progress();
792-
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc);
798+
lcd_put_u8str(PCT_X, PCT_Y, progressString);
793799
}
794800
#endif
795801

‎Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -664,15 +664,17 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
664664
#if HAS_PRINT_PROGRESS
665665
static char screenstr[8];
666666

667-
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
668-
static char str[6];
669-
memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
670-
screenstr[0] = prefix;
671-
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
672-
int str_length = time.toDigital(str);
673-
memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator
674-
return screenstr;
675-
}
667+
#if HAS_TIME_DISPLAY
668+
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
669+
static char str[6];
670+
memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
671+
screenstr[0] = prefix;
672+
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
673+
int str_length = time.toDigital(str);
674+
memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator
675+
return screenstr;
676+
}
677+
#endif
676678

677679
void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) {
678680
set_ddram_address(addr);
@@ -687,7 +689,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
687689
void ST7920_Lite_Status_Screen::drawPercent() {
688690
#define LSHIFT TERN(HOTENDS == 1, 0, 1)
689691
const uint8_t progress = ui.get_progress_percent();
690-
memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts
692+
memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts
691693
if (progress){
692694
memcpy(&screenstr[2 - LSHIFT], \
693695
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \

‎Marlin/src/lcd/dogm/status_screen_lite_ST7920.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ class ST7920_Lite_Status_Screen {
8383
static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
8484
static void draw_fan_speed(const uint8_t value);
8585
#if HAS_PRINT_PROGRESS
86+
#if HAS_TIME_DISPLAY
87+
static char* prepare_time_string(const duration_t &time, char prefix=' ');
88+
#endif
8689
static void draw_progress_bar(const uint8_t value);
87-
static char* prepare_time_string(const duration_t &time, char prefix=' ');
8890
static void draw_progress_string(uint8_t addr, const char *str);
8991
static void update_progress(const bool forceUpdate);
9092
#endif

‎Marlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void DGUSTxHandler::sdCardInsertionStatus(DGUS_VP &vp) {
105105
}
106106
#endif // PIDTEMPBED
107107

108-
static duration_t _PrintRemainingDurationEstimate() {
108+
static duration_t _printRemainingDurationEstimate() {
109109
duration_t remainingDuration = 0;
110110

111111
if (ExtUI::isPrinting()) {
@@ -120,12 +120,12 @@ static duration_t _PrintRemainingDurationEstimate() {
120120
}
121121

122122
void DGUSTxHandler::printRemainingHours(DGUS_VP &vp) {
123-
const int16_t data = _PrintRemainingDurationEstimate().hour();
123+
const int16_t data = _printRemainingDurationEstimate().hour();
124124
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
125125
}
126126

127127
void DGUSTxHandler::printRemainingMinutes(DGUS_VP &vp) {
128-
const int16_t data = _PrintRemainingDurationEstimate().minute() % 60;
128+
const int16_t data = _printRemainingDurationEstimate().minute() % 60;
129129
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
130130
}
131131

0 commit comments

Comments
 (0)