@@ -49,9 +49,9 @@ void MarlinUI::tft_idle() {
49
49
#if ENABLED(TOUCH_SCREEN)
50
50
if (TERN0 (HAS_TOUCH_SLEEP, lcd_sleep_task ())) return ;
51
51
if (draw_menu_navigation) {
52
- add_control (104 , TFT_HEIGHT - 34 , PAGE_UP, imgPageUp, encoderTopLine > 0 );
53
- add_control (344 , TFT_HEIGHT - 34 , PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
54
- add_control (224 , TFT_HEIGHT - 34 , BACK, imgBack);
52
+ add_control (TFT_WIDTH / 6 - 16 , TFT_HEIGHT - 34 , PAGE_UP, imgPageUp, encoderTopLine > 0 );
53
+ add_control (TFT_WIDTH / 2 - 16 , TFT_HEIGHT - 34 , PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
54
+ add_control (5 * TFT_WIDTH / 6 - 16 , TFT_HEIGHT - 34 , BACK, imgBack);
55
55
draw_menu_navigation = false ;
56
56
}
57
57
#endif
@@ -222,11 +222,10 @@ void MarlinUI::draw_status_screen() {
222
222
223
223
TERN_ (TOUCH_SCREEN, touch.clear ());
224
224
225
- // heaters and fan
226
- uint16_t i, x, y = TFT_STATUS_TOP_Y;
227
-
228
- for (i = 0 ; i < ITEMS_COUNT; i++) {
229
- x = (TFT_WIDTH / ITEMS_COUNT - 80 ) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
225
+ // Statuses of heaters and fans
226
+ uint16_t y = STATUS_MARGIN_SIZE;
227
+ for (uint16_t i = 0 ; i < ITEMS_COUNT; i++) {
228
+ uint16_t x = (TFT_WIDTH / ITEMS_COUNT - 80 ) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
230
229
switch (i) {
231
230
#if HAS_EXTRUDERS
232
231
case ITEM_E0: draw_heater_status (x, y, H_E0); break ;
@@ -252,12 +251,13 @@ void MarlinUI::draw_status_screen() {
252
251
}
253
252
}
254
253
255
- y += TERN (HAS_UI_480x272, 120 , 128 ) ;
254
+ y += STATUS_MARGIN_SIZE + 114 ;
256
255
257
- // coordinates
258
- tft.canvas (4 , y, TFT_WIDTH - 8 , FONT_LINE_HEIGHT);
256
+ // Coordinates
257
+ constexpr uint16_t coords_width = TFT_WIDTH - 8 ;
258
+ tft.canvas ((TFT_WIDTH - coords_width) / 2 , y, coords_width, FONT_LINE_HEIGHT);
259
259
tft.set_background (COLOR_BACKGROUND);
260
- tft.add_rectangle (0 , 0 , TFT_WIDTH - 8 , FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
260
+ tft.add_rectangle (0 , 0 , coords_width , FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
261
261
262
262
if (TERN0 (LCD_SHOW_E_TOTAL, printingIsActive ())) {
263
263
#if ENABLED(LCD_SHOW_E_TOTAL)
@@ -270,67 +270,86 @@ void MarlinUI::draw_status_screen() {
270
270
#endif
271
271
}
272
272
else {
273
- tft.add_text ( 16 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , " X" );
273
+ // Coords in mask "X____Y____Z____"
274
+ tft_string.set (" X" );
275
+ tft.add_text (coords_width / 30 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
276
+
274
277
const bool nhx = axis_should_home (X_AXIS);
275
278
tft_string.set (blink && nhx ? " ?" : ftostr4sign (LOGICAL_X_POSITION (current_position.x )));
276
- tft.add_text (102 - tft_string.width (), tft_string.vcenter (FONT_LINE_HEIGHT), nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
279
+ tft_string.ltrim ();
280
+ tft.add_text (coords_width / 5 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
281
+
282
+ tft_string.set (" Y" );
283
+ tft.add_text (11 * coords_width / 30 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
277
284
278
- tft.add_text (192 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , " Y" );
279
285
const bool nhy = axis_should_home (Y_AXIS);
280
286
tft_string.set (blink && nhy ? " ?" : ftostr4sign (LOGICAL_Y_POSITION (current_position.y )));
281
- tft.add_text (280 - tft_string.width (), tft_string.vcenter (FONT_LINE_HEIGHT), nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
287
+ tft_string.ltrim ();
288
+ tft.add_text (8 * coords_width / 15 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
282
289
}
283
- tft.add_text (330 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , " Z" );
284
- uint16_t offset = 32 ;
290
+
291
+ tft_string.set (" Z" );
292
+ tft.add_text (7 * coords_width / 10 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
293
+
285
294
const bool nhz = axis_should_home (Z_AXIS);
286
- if (blink && nhz)
287
- tft_string.set (' ?' );
288
- else {
289
- const float z = LOGICAL_Z_POSITION (current_position.z );
290
- tft_string.set (ftostr52sp ((int16_t )z));
291
- tft_string.rtrim ();
292
- offset += tft_string.width ();
295
+ tft_string.set (blink && nhz ? " ?" : ftostr52sp (LOGICAL_Z_POSITION (current_position.z )));
296
+ tft_string.ltrim ();
297
+ tft_string.rtrim ();
298
+ tft.add_text (13 * coords_width / 15 - tft_string.width () / 2 , tft_string.vcenter (FONT_LINE_HEIGHT), nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
293
299
294
- tft_string.set (ftostr52sp (z));
295
- offset -= tft_string.width ();
296
- }
297
- tft.add_text (455 - tft_string.width () - offset, tft_string.vcenter (FONT_LINE_HEIGHT), nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
298
300
TERN_ (TOUCH_SCREEN, touch.add_control (MOVE_AXIS, 4 , y, TFT_WIDTH - 8 , FONT_LINE_HEIGHT));
299
301
300
- y += TERN (HAS_UI_480x272, 34 , 48 );
301
- // feed rate
302
- tft.canvas (96 , y, 128 , 32 );
303
- tft.set_background (COLOR_BACKGROUND);
302
+ y += STATUS_MARGIN_SIZE + 34 ;
303
+
304
+ // Feed rate (preparing)
305
+ tft_string.set (i16tostr3rj (feedrate_percentage));
306
+ tft_string.add (" %" );
307
+ uint16_t component_width = 36 + tft_string.width (); // 32px icon size + 4px margin before text
304
308
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
309
+ uint16_t x = FEEDRATE_X (component_width);
310
+
311
+ // Feed rate (drawing)
312
+ tft.canvas (x, y, component_width, 32 );
313
+ tft.set_background (COLOR_BACKGROUND);
305
314
tft.add_image (0 , 0 , imgFeedRate, color);
306
- tft_string.set (i16tostr3rj (feedrate_percentage));
307
- tft_string.add (' %' );
308
315
tft.add_text (36 , tft_string.vcenter (30 ), color , tft_string);
309
- TERN_ (TOUCH_SCREEN, touch.add_control (FEEDRATE, 96 , y, 128 , 32 ));
316
+ TERN_ (TOUCH_SCREEN, touch.add_control (FEEDRATE, x , y, component_width , 32 ));
310
317
311
- // flow rate
312
- tft.canvas (284 , y, 128 , 32 );
313
- tft.set_background (COLOR_BACKGROUND);
314
- color = planner.flow_percentage [0 ] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
315
- tft.add_image (0 , 0 , imgFlowRate, color);
318
+ // Flow rate (preparing)
316
319
tft_string.set (i16tostr3rj (planner.flow_percentage [active_extruder]));
317
320
tft_string.add (' %' );
321
+ component_width = 36 + tft_string.width ();
322
+ color = planner.flow_percentage [0 ] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
323
+ x = FLOWRATE_X (component_width);
324
+
325
+ // Flow rate (drawing)
326
+ tft.canvas (x, y, component_width, 32 );
327
+ tft.set_background (COLOR_BACKGROUND);
328
+ tft.add_image (0 , 0 , imgFlowRate, color);
318
329
tft.add_text (36 , tft_string.vcenter (30 ), color , tft_string);
319
- TERN_ (TOUCH_SCREEN, touch.add_control (FLOWRATE, 284 , y, 128 , 32 , active_extruder));
330
+ TERN_ (TOUCH_SCREEN, touch.add_control (FLOWRATE, x, y, component_width, 32 , active_extruder));
331
+
332
+ #if TFT_COLOR_UI_PORTRAIT || DISABLED(TOUCH_SCREEN)
333
+ y += STATUS_MARGIN_SIZE + 32 ;
334
+ #endif
320
335
321
336
#if ENABLED(TOUCH_SCREEN)
322
- add_control (404 , y, menu_main, imgSettings);
337
+ // Settings button
338
+ add_control (SETTINGS_X, y, menu_main, imgSettings);
339
+
340
+ // SD-card button / Cancel button
323
341
#if HAS_MEDIA
324
342
const bool cm = card.isMounted (), pa = printingIsActive ();
325
343
if (cm && pa)
326
- add_control (12 , y, STOP, imgCancel, true , COLOR_CONTROL_CANCEL);
344
+ add_control (SDCARD_X , y, STOP, imgCancel, true , COLOR_CONTROL_CANCEL);
327
345
else
328
- add_control (12 , y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED);
346
+ add_control (SDCARD_X , y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED); // 64px icon size
329
347
#endif
348
+
349
+ y += STATUS_MARGIN_SIZE + TERN (TFT_COLOR_UI_PORTRAIT, 64 , 44 );
330
350
#endif
331
351
332
- y += TERN (HAS_UI_480x272, 39 , 44 );
333
- // print duration
352
+ // Print duration
334
353
char buffer[14 ];
335
354
duration_t elapsed = print_job_timer.duration ();
336
355
elapsed.toDigital (buffer);
@@ -340,17 +359,19 @@ void MarlinUI::draw_status_screen() {
340
359
tft_string.set (buffer);
341
360
tft.add_text (tft_string.center (128 ), tft_string.vcenter (29 ), COLOR_PRINT_TIME, tft_string);
342
361
343
- y += TERN (HAS_UI_480x272, 29 , 36 );
344
- // progress bar
362
+ y += STATUS_MARGIN_SIZE + 29 ;
363
+
364
+ // Progress bar
345
365
const uint8_t progress = ui.get_progress_percent ();
346
366
tft.canvas (4 , y, TFT_WIDTH - 8 , 9 );
347
367
tft.set_background (COLOR_PROGRESS_BG);
348
368
tft.add_rectangle (0 , 0 , TFT_WIDTH - 8 , 9 , COLOR_PROGRESS_FRAME);
349
369
if (progress)
350
370
tft.add_bar (1 , 1 , ((TFT_WIDTH - 10 ) * progress) / 100 , 7 , COLOR_PROGRESS_BAR);
351
371
352
- y += 15 ;
353
- // status message
372
+ y += STATUS_MARGIN_SIZE + 7 ;
373
+
374
+ // Status message
354
375
tft.canvas (0 , y, TFT_WIDTH, FONT_LINE_HEIGHT);
355
376
tft.set_background (COLOR_BACKGROUND);
356
377
tft_string.set (status_message);
@@ -397,7 +418,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
397
418
398
419
if (ui.can_show_slider ()) {
399
420
400
- #define SLIDER_LENGTH 336
421
+ #define SLIDER_LENGTH TFT_WIDTH * 0.7
401
422
#define SLIDER_Y_POSITION 186
402
423
403
424
tft.canvas ((TFT_WIDTH - SLIDER_LENGTH) / 2 , SLIDER_Y_POSITION, SLIDER_LENGTH, 16 );
@@ -420,9 +441,9 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
420
441
421
442
void TFT::draw_edit_screen_buttons () {
422
443
#if ENABLED(TOUCH_SCREEN)
423
- add_control (64 , TFT_HEIGHT - 64 , DECREASE, imgDecrease);
424
- add_control (352 , TFT_HEIGHT - 64 , INCREASE, imgIncrease);
425
- add_control (208 , TFT_HEIGHT - 64 , CLICK, imgConfirm);
444
+ add_control ((TFT_WIDTH - 3 * 64 ) / 6 , TFT_HEIGHT - 64 , DECREASE, imgDecrease);
445
+ add_control ((TFT_WIDTH - 64 ) / 2 , TFT_HEIGHT - 64 , INCREASE, imgIncrease);
446
+ add_control ((TFT_WIDTH * 5 - 3 * 64 ) / 6 , TFT_HEIGHT - 64 , CLICK, imgConfirm);
426
447
#endif
427
448
}
428
449
@@ -451,8 +472,8 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
451
472
tft.add_text (tft_string.center (TFT_WIDTH), 0 , COLOR_MENU_TEXT, tft_string);
452
473
}
453
474
#if ENABLED(TOUCH_SCREEN)
454
- if (no) add_control ( 88 , TFT_HEIGHT - 64 , CANCEL, imgCancel, true , yesno ? HALF (COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
455
- if (yes) add_control (328 , TFT_HEIGHT - 64 , CONFIRM, imgConfirm, true , yesno ? COLOR_CONTROL_CONFIRM : HALF (COLOR_CONTROL_CONFIRM));
475
+ if (no) add_control (TFT_WIDTH / 4 - 32 , TFT_HEIGHT - 64 , CANCEL, imgCancel, true , yesno ? HALF (COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
476
+ if (yes) add_control (TFT_WIDTH * 3 / 4 - 32 , TFT_HEIGHT - 64 , CONFIRM, imgConfirm, true , yesno ? COLOR_CONTROL_CONFIRM : HALF (COLOR_CONTROL_CONFIRM));
456
477
#endif
457
478
}
458
479
@@ -898,7 +919,7 @@ void MarlinUI::move_axis_screen() {
898
919
drawAxisValue (Z_AXIS);
899
920
900
921
// ROW 4 -> step_size disable steppers back
901
- y = TFT_HEIGHT - Y_MARGIN - 32 ; //
922
+ y = TFT_HEIGHT - Y_MARGIN - 32 ;
902
923
x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2 ;
903
924
motionAxisState.stepValuePos .x = x;
904
925
motionAxisState.stepValuePos .y = y;
0 commit comments