Skip to content

Commit ad407de

Browse files
committed
Implement initial M73 remaining support #208
1 parent abd0855 commit ad407de

File tree

11 files changed

+99
-0
lines changed

11 files changed

+99
-0
lines changed

Marlin/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

Marlin/src/lcd/extui/lib/dgus_creality/DGUSScreenHandler.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,35 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
289289
char buf[32];
290290
elapsed.toString(buf);
291291
dgusdisplay.WriteVariable(VP_PrintTime, buf, var.size, true);
292+
293+
#if ENABLED(SHOW_REMAINING_TIME)
294+
static uint32_t lastRemainingTime = -1;
295+
uint32_t remaining_time = ui.get_remaining_time();
296+
if (lastRemainingTime != remaining_time && remaining_time) {
297+
// Send a progress update to the display if anything is different.
298+
// This allows custom M117 commands to override the displayed string if desired.
299+
300+
// Remaining time is seconds. When Marlin accepts a M73 R[minutes] command, it multiplies
301+
// the R value by 60 to make a number of seconds. But... Marlin can also predict time
302+
// if the M73 R command has not been used.
303+
304+
duration_t remaining(remaining_time);
305+
306+
// So duration_t wants 21 bytes and we want to prepend remaining before it
307+
static PGM_P remainingStr = PSTR("Remaining: ");
308+
constexpr size_t buffer_size = 11 /* remaining */ + 21 /*for duration_t*/ + 2 /*zero bytes*/;
309+
310+
// Add the "remaining" string
311+
char buffer[buffer_size] = {0};
312+
strcpy_P(buffer, remainingStr);
313+
314+
// Write the duration
315+
char* duration_buffer_str = buffer + 11;
316+
remaining.toString(duration_buffer_str);
317+
318+
setstatusmessage(buffer);
319+
}
320+
#endif
292321
}
293322

294323
void DGUSScreenHandler::DGUSLCD_SendAboutFirmwareWebsite(DGUS_VP_Variable &var) {

config/btt-skr-cr6-with-btt-tft-biqu-h2/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/btt-skr-cr6-with-btt-tft-e3d-hemera/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/btt-skr-cr6-with-btt-tft/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/btt-skr-cr6-with-stock-creality-tft-biqu-h2/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/btt-skr-cr6-with-stock-creality-tft/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/cr6-max/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/cr6-se-v4.5.2-mb-no-watchdog/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/cr6-se-v4.5.2-mb/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

config/cr6-se-v4.5.3-mb/Configuration_adv.h

+7
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@
11531153
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
11541154
#endif
11551155

1156+
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
1157+
#define SHOW_REMAINING_TIME // Display estimated time to completion
1158+
#if ENABLED(SHOW_REMAINING_TIME)
1159+
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1160+
#endif
1161+
#endif
1162+
11561163
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
11571164
#define SHOW_REMAINING_TIME // Display estimated time to completion
11581165
#if ENABLED(SHOW_REMAINING_TIME)

0 commit comments

Comments
 (0)