@@ -289,6 +289,35 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
289
289
char buf[32 ];
290
290
elapsed.toString (buf);
291
291
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
292
321
}
293
322
294
323
void DGUSScreenHandler::DGUSLCD_SendAboutFirmwareWebsite (DGUS_VP_Variable &var) {
0 commit comments