@@ -286,37 +286,38 @@ void DGUSScreenHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var
286
286
// It is using a hex display for that: It expects BSD coded data in the format xxyyzz
287
287
void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay (DGUS_VP_Variable &var) {
288
288
duration_t elapsed = print_job_timer.duration ();
289
+
289
290
char buf[32 ];
290
291
elapsed.toString (buf);
291
292
dgusdisplay.WriteVariable (VP_PrintTime, buf, var.size , true );
293
+ }
292
294
295
+ // Send the current print time to the display.
296
+ // It is using a hex display for that: It expects BSD coded data in the format xxyyzz
297
+ void DGUSScreenHandler::DGUSLCD_SendPrintTimeRemainingToDisplay (DGUS_VP_Variable &var) {
293
298
#if ENABLED(SHOW_REMAINING_TIME)
294
299
static uint32_t lastRemainingTime = -1 ;
295
300
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.
301
+ if (lastRemainingTime == remaining_time) {
302
+ return ;
303
+ }
299
304
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.
305
+ // Send a progress update to the display if anything is different.
306
+ // This allows custom M117 commands to override the displayed string if desired.
303
307
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 */ ;
308
+ // Remaining time is seconds. When Marlin accepts a M73 R[minutes] command, it multiplies
309
+ // the R value by 60 to make a number of seconds. But... Marlin can also predict time
310
+ // if the M73 R command has not been used. So we should be good either way.
311
+ duration_t remaining (remaining_time );
312
+ constexpr size_t buffer_size = 21 ;
309
313
310
- // Add the "remaining" string
311
- char buffer[buffer_size] = {0 };
312
- strcpy_P (buffer, remainingStr );
314
+ // Write the duration
315
+ char buffer[buffer_size] = {0 };
316
+ remaining. toString (buffer);
313
317
314
- // Write the duration
315
- char * duration_buffer_str = buffer + 11 ;
316
- remaining.toString (duration_buffer_str);
318
+ dgusdisplay.WriteVariable (VP_PrintTimeRemaining, buffer, var.size , true );
317
319
318
- setstatusmessage (buffer);
319
- }
320
+ lastRemainingTime = remaining_time;
320
321
#endif
321
322
}
322
323
0 commit comments