Skip to content

Commit

Permalink
Implement initial M73 remaining support #208
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebazzz committed Mar 2, 2021
1 parent abd0855 commit ad407de
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
29 changes: 29 additions & 0 deletions Marlin/src/lcd/extui/lib/dgus_creality/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,35 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
char buf[32];
elapsed.toString(buf);
dgusdisplay.WriteVariable(VP_PrintTime, buf, var.size, true);

#if ENABLED(SHOW_REMAINING_TIME)
static uint32_t lastRemainingTime = -1;
uint32_t remaining_time = ui.get_remaining_time();
if (lastRemainingTime != remaining_time && remaining_time) {
// Send a progress update to the display if anything is different.
// This allows custom M117 commands to override the displayed string if desired.

// Remaining time is seconds. When Marlin accepts a M73 R[minutes] command, it multiplies
// the R value by 60 to make a number of seconds. But... Marlin can also predict time
// if the M73 R command has not been used.

duration_t remaining(remaining_time);

// So duration_t wants 21 bytes and we want to prepend remaining before it
static PGM_P remainingStr = PSTR("Remaining: ");
constexpr size_t buffer_size = 11 /* remaining */ + 21 /*for duration_t*/ + 2 /*zero bytes*/;

// Add the "remaining" string
char buffer[buffer_size] = {0};
strcpy_P(buffer, remainingStr);

// Write the duration
char* duration_buffer_str = buffer + 11;
remaining.toString(duration_buffer_str);

setstatusmessage(buffer);
}
#endif
}

void DGUSScreenHandler::DGUSLCD_SendAboutFirmwareWebsite(DGUS_VP_Variable &var) {
Expand Down
7 changes: 7 additions & 0 deletions config/btt-skr-cr6-with-btt-tft-biqu-h2/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
7 changes: 7 additions & 0 deletions config/btt-skr-cr6-with-btt-tft/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
7 changes: 7 additions & 0 deletions config/cr6-max/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
7 changes: 7 additions & 0 deletions config/cr6-se-v4.5.2-mb-no-watchdog/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
7 changes: 7 additions & 0 deletions config/cr6-se-v4.5.2-mb/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
7 changes: 7 additions & 0 deletions config/cr6-se-v4.5.3-mb/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,13 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ENABLED(EXTENSIBLE_UI)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
#endif
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down

0 comments on commit ad407de

Please # to comment.