@@ -221,9 +221,9 @@ void MarlinUI::draw_status_screen() {
221
221
222
222
TERN_ (TOUCH_SCREEN, touch.clear ());
223
223
224
- // heaters and fan
225
224
uint16_t i, x, y = TFT_STATUS_TOP_Y;
226
225
226
+ // heaters and fan
227
227
for (i = 0 ; i < ITEMS_COUNT; i++) {
228
228
x = (TFT_WIDTH / ITEMS_COUNT - 80 ) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
229
229
switch (i) {
@@ -298,57 +298,114 @@ void MarlinUI::draw_status_screen() {
298
298
299
299
y += TERN (HAS_UI_480x272, 38 , 48 );
300
300
// feed rate
301
- tft.canvas (96 , y, 100 , 32 );
301
+ tft.canvas (96 , y, 144 , 32 );
302
302
tft.set_background (COLOR_BACKGROUND);
303
303
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
304
304
tft.add_image (0 , 0 , imgFeedRate, color);
305
305
tft_string.set (i16tostr3rj (feedrate_percentage));
306
306
tft_string.add (' %' );
307
- tft.add_text (36 , 1 , color , tft_string);
307
+ tft.add_text (36 , 1 , color, tft_string);
308
308
TERN_ (TOUCH_SCREEN, touch.add_control (FEEDRATE, 96 , 176 , 100 , 32 ));
309
309
310
310
// flow rate
311
- tft.canvas (284 , y, 100 , 32 );
311
+ tft.canvas (256 , y, 144 , 32 );
312
312
tft.set_background (COLOR_BACKGROUND);
313
313
color = planner.flow_percentage [0 ] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
314
314
tft.add_image (0 , 0 , imgFlowRate, color);
315
315
tft_string.set (i16tostr3rj (planner.flow_percentage [active_extruder]));
316
316
tft_string.add (' %' );
317
- tft.add_text (36 , 1 , color , tft_string);
317
+ tft.add_text (36 , 1 , color, tft_string);
318
318
TERN_ (TOUCH_SCREEN, touch.add_control (FLOWRATE, 284 , 176 , 100 , 32 , active_extruder));
319
319
320
320
#if ENABLED(TOUCH_SCREEN)
321
- add_control (404 , y, menu_main, imgSettings);
322
- TERN_ (SDSUPPORT, add_control (12 , y, menu_media, imgSD, !printingIsActive (), COLOR_CONTROL_ENABLED, card.isMounted () && printingIsActive () ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
321
+ uint16_t controls_y_offset = TERN (HAS_UI_480x272, 4 , 8 );
322
+ add_control (404 , y + controls_y_offset, menu_main, imgSettings);
323
+ #if ENABLED(SDSUPPORT)
324
+ color = card.isMounted () && printingIsActive () ? COLOR_BUSY : COLOR_CONTROL_DISABLED;
325
+ add_control (12 , y + controls_y_offset, menu_media, imgSD, !printingIsActive (), COLOR_CONTROL_ENABLED, color);
326
+ #endif
323
327
#endif
324
328
325
329
y += TERN (HAS_UI_480x272, 36 , 44 );
326
- // print duration
327
- char buffer[14 ];
328
- duration_t elapsed = print_job_timer.duration ();
329
- elapsed.toDigital (buffer);
330
330
331
- tft.canvas ((TFT_WIDTH - 128 ) / 2 , y, 128 , 29 );
332
- tft.set_background (COLOR_BACKGROUND);
333
- tft_string.set (buffer);
334
- tft.add_text (tft_string.center (128 ), 0 , COLOR_PRINT_TIME, tft_string);
331
+ #if DISABLED(SHOW_REMAINING_TIME)
332
+ // print duration so far (time elapsed) - centered
333
+ char elapsed_str[22 ];
334
+ duration_t elapsed = print_job_timer.duration ();
335
+ elapsed.toString (elapsed_str);
336
+
337
+ // Same width constraints as feedrate/flowrate controls
338
+ uint16_t time_str_width = 288 ;
339
+ uint16_t image_width = 36 ;
335
340
336
- y += TERN (HAS_UI_480x272, 28 , 36 );
341
+ tft.canvas ((TFT_WIDTH - time_str_width) / 2 , y, time_str_width, 32 );
342
+ tft.set_background (COLOR_BACKGROUND);
343
+ tft_string.set (elapsed_str);
344
+ uint16_t text_pos_x = tft_string.center (time_str_width - image_width);
345
+ tft.add_image (text_pos_x, 0 , imgFeedRate, COLOR_PRINT_TIME);
346
+ tft.add_text (text_pos_x + image_width, 1 , COLOR_PRINT_TIME, tft_string);
347
+ #else
348
+ // Print duration so far (time elapsed) - aligned under feed rate
349
+ char elapsed_str[18 ];
350
+ duration_t elapsed = print_job_timer.duration ();
351
+ elapsed.toString (elapsed_str, true );
352
+
353
+ tft.canvas (96 , y, 144 , 32 );
354
+ tft.set_background (COLOR_BACKGROUND);
355
+ tft.add_image (0 , 0 , imgFeedRate, COLOR_PRINT_TIME);
356
+ tft_string.set (elapsed_str);
357
+ tft.add_text (36 , 1 , COLOR_PRINT_TIME, tft_string);
358
+
359
+ // Print time remaining estimation - aligned under flow rate
360
+ char estimate_str[18 ];
361
+ const progress_t progress = TERN (HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
362
+
363
+ // Get the estimate, first from M73
364
+ uint32_t estimate_remaining = (0
365
+ #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
366
+ + get_remaining_time ()
367
+ #endif
368
+ );
369
+ // If no M73 estimate is available but we have progress data, calculate time remaining assuming time elapsed is linear with progress
370
+ if (!estimate_remaining && progress > 0 ) {
371
+ estimate_remaining = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress;
372
+ }
373
+
374
+ // Generate estimate string
375
+ if (!estimate_remaining) {
376
+ tft_string.set (" N/A" );
377
+ }
378
+ else {
379
+ duration_t estimation = estimate_remaining;
380
+ estimation.toString (estimate_str, true );
381
+ tft_string.set (estimate_str);
382
+ }
383
+
384
+ // Push out the estimate to the screen
385
+ tft.canvas (256 , y, 144 , 32 );
386
+ tft.set_background (COLOR_BACKGROUND);
387
+ color = printingIsActive () ? COLOR_PRINT_TIME : COLOR_INACTIVE;
388
+ tft.add_image (0 , 0 , imgFeedRate, color);
389
+ tft.add_text (36 , 1 , color, tft_string);
390
+ #endif
391
+
392
+ y += TERN (HAS_UI_480x272, 36 , 44 );
337
393
// progress bar
338
- const uint8_t progress = ui.get_progress_percent ();
339
394
tft.canvas (4 , y, TFT_WIDTH - 8 , 9 );
340
395
tft.set_background (COLOR_PROGRESS_BG);
341
396
tft.add_rectangle (0 , 0 , TFT_WIDTH - 8 , 9 , COLOR_PROGRESS_FRAME);
342
397
if (progress)
343
- tft.add_bar (1 , 1 , ((TFT_WIDTH - 10 ) * progress) / 100 , 7 , COLOR_PROGRESS_BAR);
398
+ tft.add_bar (1 , 1 , ((TFT_WIDTH - 10 ) * progress / (PROGRESS_SCALE) ) / 100 , 7 , COLOR_PROGRESS_BAR);
344
399
345
- y += 20 ;
400
+ y += 12 ;
346
401
// status message
347
- tft.canvas (0 , y, TFT_WIDTH, FONT_LINE_HEIGHT - 5 );
402
+ // canvas height should be 40px on 480x320 and 28 on 480x272
403
+ uint16_t status_height = TFT_HEIGHT - y;
404
+ tft.canvas (0 , y, TFT_WIDTH, status_height);
348
405
tft.set_background (COLOR_BACKGROUND);
349
406
tft_string.set (status_message);
350
407
tft_string.trim ();
351
- tft.add_text (tft_string.center (TFT_WIDTH), 0 , COLOR_STATUS_MESSAGE, tft_string);
408
+ tft.add_text (tft_string.center (TFT_WIDTH), (status_height - FONT_LINE_HEIGHT) / 2 , COLOR_STATUS_MESSAGE, tft_string);
352
409
}
353
410
354
411
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
0 commit comments