Skip to content

Commit

Permalink
🚸 Progress display followup (MarlinFirmware#24879)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilGremlin authored and thinkyhead committed Dec 16, 2022
1 parent c86f200 commit 0efeedf
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 148 deletions.
18 changes: 10 additions & 8 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1476,24 +1476,26 @@

#endif // HAS_DISPLAY || DWIN_LCD_PROUI

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

// LCD Print Progress options, multiple can be rotated depending on screen layout
// LCD Print Progress options. Multiple times may be displayed in turn.
#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
//#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')

#if ENABLED(SET_INTERACTION_TIME)
#define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change)
#endif
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this

#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
Expand Down
28 changes: 12 additions & 16 deletions Marlin/src/gcode/lcd/M73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#include "../../lcd/e3v2/proui/dwin.h"
#endif

#if ENABLED(M73_REPORT)
#define M73_REPORT_PRUSA
#endif

/**
* M73: Set percentage complete (for display on LCD)
*
Expand All @@ -46,10 +42,9 @@
* M73 C12 ; Set next interaction countdown to 12 minutes
* M73 ; Report current values
*
* Use a shorter-than-Průša report format:
* M73 Percent done: ---%; Time left: -----m; Change: -----m;
* M73 Progress: ---%; Time left: -----m; Change: -----m;
*
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100% / 23.4% / 3.45% format
*
*/
void GcodeSuite::M73() {
Expand Down Expand Up @@ -79,19 +74,20 @@ void GcodeSuite::M73() {
#endif

#if ENABLED(M73_REPORT)
{
SERIAL_ECHO_MSG(
TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ")
, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) {
SERIAL_ECHO_START();
SERIAL_ECHOPGM(" M73");
#if ENABLED(SET_PROGRESS_PERCENT)
SERIAL_ECHOPGM(" Progress: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()), "%;");
#endif
#if ENABLED(SET_REMAINING_TIME)
, TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60
SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;");
#endif
#if ENABLED(SET_INTERACTION_TIME)
, TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60
SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;");
#endif
, TERN(M73_REPORT_PRUSA, ";", "m")
);
}
SERIAL_EOL();
}
#endif
}

Expand Down
20 changes: 11 additions & 9 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand All @@ -789,18 +790,19 @@ 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);
}
}
#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);
}
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
) {
Expand Down Expand Up @@ -1087,15 +1089,15 @@ 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

//
// 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
Expand Down
82 changes: 53 additions & 29 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 0efeedf

Please sign in to comment.