Skip to content

Commit 0efeedf

Browse files
EvilGremlinthinkyhead
authored andcommitted
🚸 Progress display followup (MarlinFirmware#24879)
1 parent c86f200 commit 0efeedf

File tree

7 files changed

+123
-148
lines changed

7 files changed

+123
-148
lines changed

Marlin/Configuration_adv.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,24 +1476,26 @@
14761476

14771477
#endif // HAS_DISPLAY || DWIN_LCD_PROUI
14781478

1479-
// Add the G-code 'M73' to set / report the current job progress
1479+
// Add 'M73' to set print job progress, overrides Marlin's built-in estimate
14801480
//#define SET_PROGRESS_MANUALLY
14811481
#if ENABLED(SET_PROGRESS_MANUALLY)
1482-
//#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate
1483-
//#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate
1482+
#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done
1483+
#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time
14841484
//#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction
1485-
#if ENABLED(SET_INTERACTION_TIME)
1486-
#define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change)
1485+
//#define M73_REPORT // Report M73 values to host
1486+
#if BOTH(M73_REPORT, SDSUPPORT)
1487+
#define M73_REPORT_SD_ONLY // Report only when printing from SD
14871488
#endif
1488-
//#define M73_REPORT // Report progress to host with 'M73'
14891489
#endif
14901490

1491-
// LCD Print Progress options, multiple can be rotated depending on screen layout
1491+
// LCD Print Progress options. Multiple times may be displayed in turn.
14921492
#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
14931493
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
14941494
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
14951495
//#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')
1496-
1496+
#if ENABLED(SET_INTERACTION_TIME)
1497+
#define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change)
1498+
#endif
14971499
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this
14981500

14991501
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)

Marlin/src/gcode/lcd/M73.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#include "../../lcd/e3v2/proui/dwin.h"
3434
#endif
3535

36-
#if ENABLED(M73_REPORT)
37-
#define M73_REPORT_PRUSA
38-
#endif
39-
4036
/**
4137
* M73: Set percentage complete (for display on LCD)
4238
*
@@ -46,10 +42,9 @@
4642
* M73 C12 ; Set next interaction countdown to 12 minutes
4743
* M73 ; Report current values
4844
*
49-
* Use a shorter-than-Průša report format:
50-
* M73 Percent done: ---%; Time left: -----m; Change: -----m;
45+
* M73 Progress: ---%; Time left: -----m; Change: -----m;
5146
*
52-
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format
47+
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100% / 23.4% / 3.45% format
5348
*
5449
*/
5550
void GcodeSuite::M73() {
@@ -79,19 +74,20 @@ void GcodeSuite::M73() {
7974
#endif
8075

8176
#if ENABLED(M73_REPORT)
82-
{
83-
SERIAL_ECHO_MSG(
84-
TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ")
85-
, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
77+
if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) {
78+
SERIAL_ECHO_START();
79+
SERIAL_ECHOPGM(" M73");
80+
#if ENABLED(SET_PROGRESS_PERCENT)
81+
SERIAL_ECHOPGM(" Progress: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()), "%;");
82+
#endif
8683
#if ENABLED(SET_REMAINING_TIME)
87-
, TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60
84+
SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;");
8885
#endif
8986
#if ENABLED(SET_INTERACTION_TIME)
90-
, TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60
87+
SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;");
9188
#endif
92-
, TERN(M73_REPORT_PRUSA, ";", "m")
93-
);
94-
}
89+
SERIAL_EOL();
90+
}
9591
#endif
9692
}
9793

Marlin/src/lcd/HD44780/marlinui_HD44780.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ void MarlinUI::draw_status_message(const bool blink) {
760760
#if HAS_PRINT_PROGRESS
761761
#define TPOFFSET (LCD_WIDTH - 1)
762762
static uint8_t timepos = TPOFFSET - 6;
763-
static char buffer[14];
763+
static char buffer[8];
764764
static lcd_uint_t pc, pr;
765765

766766
#if ENABLED(SHOW_PROGRESS_PERCENT)
@@ -776,9 +776,10 @@ void MarlinUI::draw_status_message(const bool blink) {
776776
#endif
777777
#if ENABLED(SHOW_REMAINING_TIME)
778778
void MarlinUI::drawRemain() {
779-
const duration_t remaint = ui.get_remaining_time();
780779
if (printJobOngoing()) {
780+
const duration_t remaint = ui.get_remaining_time();
781781
timepos = TPOFFSET - remaint.toDigital(buffer);
782+
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
782783
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'R');
783784
lcd_put_u8str(buffer);
784785
}
@@ -789,18 +790,19 @@ void MarlinUI::draw_status_message(const bool blink) {
789790
const duration_t interactt = ui.interaction_time;
790791
if (printingIsActive() && interactt.value) {
791792
timepos = TPOFFSET - interactt.toDigital(buffer);
793+
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
792794
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'C');
793795
lcd_put_u8str(buffer);
794796
}
795797
}
796798
#endif
797799
#if ENABLED(SHOW_ELAPSED_TIME)
798800
void MarlinUI::drawElapsed() {
799-
const duration_t elapsedt = print_job_timer.duration();
800801
if (printJobOngoing()) {
802+
const duration_t elapsedt = print_job_timer.duration();
801803
timepos = TPOFFSET - elapsedt.toDigital(buffer);
804+
TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);)
802805
lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'E');
803-
//lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]);
804806
lcd_put_u8str(buffer);
805807
}
806808
}
@@ -919,7 +921,7 @@ void MarlinUI::draw_status_screen() {
919921
#if LCD_WIDTH < 20
920922

921923
#if HAS_PRINT_PROGRESS
922-
pc = 0, pr = 2;
924+
pc = 0; pr = 2;
923925
rotate_progress();
924926
#endif
925927

@@ -1006,14 +1008,14 @@ void MarlinUI::draw_status_screen() {
10061008
#if LCD_WIDTH >= 20
10071009

10081010
#if HAS_PRINT_PROGRESS
1009-
pc = timepos - 7, pr = 2;
1011+
pc = 6; pr = 2;
10101012
rotate_progress();
10111013
#else
10121014
char c;
10131015
uint16_t per;
10141016
#if HAS_FAN0
10151017
if (true
1016-
#if EXTRUDERS && ENABLED(ADAPTIVE_FAN_SLOWING)
1018+
#if BOTH(HAS_EXTRUDERS, ADAPTIVE_FAN_SLOWING)
10171019
&& (blink || thermalManager.fan_speed_scaler[0] < 128)
10181020
#endif
10191021
) {
@@ -1087,15 +1089,15 @@ void MarlinUI::draw_status_screen() {
10871089
_draw_bed_status(blink);
10881090
#elif HAS_PRINT_PROGRESS
10891091
#define DREW_PRINT_PROGRESS 1
1090-
pc = 0, pr = 2;
1092+
pc = 0; pr = 2;
10911093
rotate_progress();
10921094
#endif
10931095

10941096
//
10951097
// All progress strings
10961098
//
10971099
#if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS
1098-
pc = LCD_WIDTH - 9, pr = 2;
1100+
pc = LCD_WIDTH - 9; pr = 2;
10991101
rotate_progress();
11001102
#endif
11011103
#endif // LCD_INFO_SCREEN_STYLE 1

Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -596,23 +596,58 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
596596

597597
#endif // HAS_CUTTER
598598

599-
#if HAS_PRINT_PROGRESS
600-
601-
FORCE_INLINE void _draw_print_progress() {
602-
if (!PanelDetected) return;
603-
const uint8_t progress = ui._get_progress();
604-
#if ENABLED(SDSUPPORT)
605-
lcd_put_u8str(F("SD"));
606-
#elif ENABLED(SET_PROGRESS_PERCENT)
607-
lcd_put_u8str(F("P:"));
608-
#endif
609-
if (progress)
610-
lcd.print(ui8tostr3rj(progress));
611-
else
612-
lcd_put_u8str(F("---"));
613-
lcd.write('%');
614-
}
615599

600+
#if HAS_PRINT_PROGRESS // UNTESTED!!!
601+
#define TPOFFSET (LCD_WIDTH - 1)
602+
static uint8_t timepos = TPOFFSET - 6;
603+
604+
#if ENABLED(SHOW_PROGRESS_PERCENT)
605+
void MarlinUI::drawPercent() {
606+
const uint8_t progress = ui.get_progress_percent();
607+
if (progress) {
608+
lcd_moveto(0, 2);
609+
lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:")));
610+
lcd.print(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)));
611+
lcd.write('%');
612+
}
613+
}
614+
#endif
615+
#if ENABLED(SHOW_REMAINING_TIME)
616+
void MarlinUI::drawRemain() {
617+
if (printJobOngoing()) {
618+
const duration_t remaint = ui.get_remaining_time();
619+
char buffer[10];
620+
timepos = TPOFFSET - remaint.toDigital(buffer);
621+
lcd_moveto(timepos, 1);
622+
lcd.write('R');
623+
lcd.print(buffer);
624+
}
625+
}
626+
#endif
627+
#if ENABLED(SHOW_INTERACTION_TIME)
628+
void MarlinUI::drawInter() {
629+
const duration_t interactt = ui.interaction_time;
630+
if (printingIsActive() && interactt.value) {
631+
char buffer[10];
632+
timepos = TPOFFSET - interactt.toDigital(buffer);
633+
lcd_moveto(timepos, 1);
634+
lcd.write('C');
635+
lcd.print(buffer);
636+
}
637+
}
638+
#endif
639+
#if ENABLED(SHOW_ELAPSED_TIME)
640+
void MarlinUI::drawElapsed() {
641+
if (printJobOngoing()) {
642+
const duration_t elapsedt = print_job_timer.duration();
643+
char buffer[10];
644+
timepos = TPOFFSET - elapsedt.toDigital(buffer);
645+
lcd_moveto(timepos, 1);
646+
lcd.write('E');
647+
lcd.print(buffer);
648+
}
649+
}
650+
#endif
616651
#endif // HAS_PRINT_PROGRESS
617652

618653
#if ENABLED(LCD_PROGRESS_BAR)
@@ -796,23 +831,12 @@ void MarlinUI::draw_status_screen() {
796831
#endif
797832

798833
//
799-
// Line 2 - feedrate, , time
834+
// Line 2 - feedrate, progress %, progress time
800835
//
801836

802837
lcd_moveto(0, 1);
803838
lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%');
804-
805-
#if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS)
806-
lcd_moveto(LCD_WIDTH / 2 - 3, 1);
807-
_draw_print_progress();
808-
#endif
809-
810-
char buffer[10];
811-
duration_t elapsed = print_job_timer.duration();
812-
uint8_t len = elapsed.toDigital(buffer);
813-
814-
lcd_moveto((LCD_WIDTH - 1) - len, 1);
815-
lcd.write(LCD_STR_CLOCK[0]); lcd.print(buffer);
839+
ui.rotate_progress(); // UNTESTED!!!
816840

817841
//
818842
// Line 3 - progressbar

0 commit comments

Comments
 (0)