@@ -285,6 +285,19 @@ void DGUSScreenHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var
285
285
// Send the current print time to the display.
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
+ // Clear if changed and we shouldn't display
289
+ static bool last_shouldDisplay = true ;
290
+ bool shouldDisplay = ui.remaining_time == 0 ;
291
+ if (last_shouldDisplay != shouldDisplay) {
292
+ if (!shouldDisplay) {
293
+ dgusdisplay.WriteVariable (VP_PrintTime, nullptr , var.size , true );
294
+ }
295
+ }
296
+
297
+ last_shouldDisplay = shouldDisplay;
298
+ if (!shouldDisplay) return ;
299
+
300
+ // Write if changed
288
301
duration_t elapsed = print_job_timer.duration ();
289
302
290
303
static uint32_t last_elapsed;
@@ -299,16 +312,60 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
299
312
last_elapsed = elapsed.second ();
300
313
}
301
314
315
+ void DGUSScreenHandler::DGUSLCD_SendPrintTimeWithRemainingToDisplay (DGUS_VP_Variable &var) {
316
+ // Clear if changed and we shouldn't display
317
+ static bool last_shouldDisplay = true ;
318
+ bool shouldDisplay = ui.remaining_time != 0 ;
319
+ if (last_shouldDisplay != shouldDisplay) {
320
+ if (!shouldDisplay) {
321
+ dgusdisplay.WriteVariable (VP_PrintTimeWithRemainingVisible, nullptr , var.size , true );
322
+ }
323
+ }
324
+
325
+ last_shouldDisplay = shouldDisplay;
326
+ if (!shouldDisplay) return ;
327
+
328
+ // Write if changed
329
+ duration_t elapsed = print_job_timer.duration ();
330
+
331
+ static uint32_t last_elapsed;
332
+ if (elapsed == last_elapsed) {
333
+ return ;
334
+ }
335
+
336
+ char buf[32 ];
337
+ elapsed.toString (buf);
338
+ dgusdisplay.WriteVariable (VP_PrintTimeWithRemainingVisible, buf, var.size , true );
339
+
340
+ last_elapsed = elapsed.second ();
341
+ }
342
+
302
343
// Send the current print time to the display.
303
344
// It is using a hex display for that: It expects BSD coded data in the format xxyyzz
304
345
void DGUSScreenHandler::DGUSLCD_SendPrintTimeRemainingToDisplay (DGUS_VP_Variable &var) {
305
346
#if ENABLED(SHOW_REMAINING_TIME)
306
347
static uint32_t lastRemainingTime = -1 ;
307
- uint32_t remaining_time = ui.get_remaining_time () ;
348
+ uint32_t remaining_time = ui.remaining_time ;
308
349
if (lastRemainingTime == remaining_time) {
309
350
return ;
310
351
}
311
352
353
+ bool has_remaining_time = remaining_time != 0 ;
354
+
355
+ // Update display of SPs (toggle between large and small print timer)
356
+ if (has_remaining_time) {
357
+ dgusdisplay.WriteVariable (VP_HideRemainingTime_Ico, ICON_REMAINING_VISIBLE);
358
+ } else {
359
+ dgusdisplay.WriteVariable (VP_HideRemainingTime_Ico, ICON_REMAINING_HIDDEN);
360
+ }
361
+
362
+ if (!has_remaining_time) {
363
+ // Clear remaining time
364
+ dgusdisplay.WriteVariable (VP_PrintTimeRemaining, nullptr , var.size , true );
365
+ lastRemainingTime = remaining_time;
366
+ return ;
367
+ }
368
+
312
369
// Send a progress update to the display if anything is different.
313
370
// This allows custom M117 commands to override the displayed string if desired.
314
371
0 commit comments