Skip to content

Commit 7b581ae

Browse files
uncellonEvilGremlin
authored andcommitted
🚸 TS35 portrait display (MarlinFirmware#25629)
1 parent 9dfbe50 commit 7b581ae

File tree

3 files changed

+152
-61
lines changed

3 files changed

+152
-61
lines changed

Marlin/src/inc/Conditionals_LCD.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -1686,8 +1686,13 @@
16861686
#define TFT_HEIGHT 272
16871687
#define GRAPHICAL_TFT_UPSCALE 2
16881688
#elif ENABLED(TFT_RES_480x320)
1689-
#define TFT_WIDTH 480
1690-
#define TFT_HEIGHT 320
1689+
#if ENABLED(TFT_COLOR_UI_PORTRAIT)
1690+
#define TFT_WIDTH 320
1691+
#define TFT_HEIGHT 480
1692+
#else
1693+
#define TFT_WIDTH 480
1694+
#define TFT_HEIGHT 320
1695+
#endif
16911696
#define GRAPHICAL_TFT_UPSCALE 3
16921697
#elif ENABLED(TFT_RES_1024x600)
16931698
#define TFT_WIDTH 1024
@@ -1708,7 +1713,7 @@
17081713
#elif ENABLED(TFT_INTERFACE_FSMC)
17091714
#define TFT_320x240
17101715
#endif
1711-
#elif TFT_HEIGHT == 320
1716+
#elif TFT_HEIGHT == 320 || (TFT_HEIGHT == 480 && ENABLED(TFT_COLOR_UI_PORTRAIT))
17121717
#if ENABLED(TFT_INTERFACE_SPI)
17131718
#define TFT_480x320_SPI
17141719
#elif ENABLED(TFT_INTERFACE_FSMC)

Marlin/src/lcd/tft/ui_480x320.cpp

+79-58
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void MarlinUI::tft_idle() {
4949
#if ENABLED(TOUCH_SCREEN)
5050
if (TERN0(HAS_TOUCH_SLEEP, lcd_sleep_task())) return;
5151
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);
5555
draw_menu_navigation = false;
5656
}
5757
#endif
@@ -222,11 +222,10 @@ void MarlinUI::draw_status_screen() {
222222

223223
TERN_(TOUCH_SCREEN, touch.clear());
224224

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);
230229
switch (i) {
231230
#if HAS_EXTRUDERS
232231
case ITEM_E0: draw_heater_status(x, y, H_E0); break;
@@ -252,12 +251,13 @@ void MarlinUI::draw_status_screen() {
252251
}
253252
}
254253

255-
y += TERN(HAS_UI_480x272, 120, 128);
254+
y += STATUS_MARGIN_SIZE + 114;
256255

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);
259259
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);
261261

262262
if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) {
263263
#if ENABLED(LCD_SHOW_E_TOTAL)
@@ -270,67 +270,86 @@ void MarlinUI::draw_status_screen() {
270270
#endif
271271
}
272272
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+
274277
const bool nhx = axis_should_home(X_AXIS);
275278
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);
277284

278-
tft.add_text(192, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Y");
279285
const bool nhy = axis_should_home(Y_AXIS);
280286
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);
282289
}
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+
285294
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);
293299

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);
298300
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
299301

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
304308
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);
305314
tft.add_image(0, 0, imgFeedRate, color);
306-
tft_string.set(i16tostr3rj(feedrate_percentage));
307-
tft_string.add('%');
308315
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));
310317

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)
316319
tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
317320
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);
318329
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
320335

321336
#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
323341
#if HAS_MEDIA
324342
const bool cm = card.isMounted(), pa = printingIsActive();
325343
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);
327345
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
329347
#endif
348+
349+
y += STATUS_MARGIN_SIZE + TERN(TFT_COLOR_UI_PORTRAIT, 64, 44);
330350
#endif
331351

332-
y += TERN(HAS_UI_480x272, 39, 44);
333-
// print duration
352+
// Print duration
334353
char buffer[14];
335354
duration_t elapsed = print_job_timer.duration();
336355
elapsed.toDigital(buffer);
@@ -340,17 +359,19 @@ void MarlinUI::draw_status_screen() {
340359
tft_string.set(buffer);
341360
tft.add_text(tft_string.center(128), tft_string.vcenter(29), COLOR_PRINT_TIME, tft_string);
342361

343-
y += TERN(HAS_UI_480x272, 29, 36);
344-
// progress bar
362+
y += STATUS_MARGIN_SIZE + 29;
363+
364+
// Progress bar
345365
const uint8_t progress = ui.get_progress_percent();
346366
tft.canvas(4, y, TFT_WIDTH - 8, 9);
347367
tft.set_background(COLOR_PROGRESS_BG);
348368
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
349369
if (progress)
350370
tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
351371

352-
y += 15;
353-
// status message
372+
y += STATUS_MARGIN_SIZE + 7;
373+
374+
// Status message
354375
tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT);
355376
tft.set_background(COLOR_BACKGROUND);
356377
tft_string.set(status_message);
@@ -397,7 +418,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
397418

398419
if (ui.can_show_slider()) {
399420

400-
#define SLIDER_LENGTH 336
421+
#define SLIDER_LENGTH TFT_WIDTH * 0.7
401422
#define SLIDER_Y_POSITION 186
402423

403424
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
420441

421442
void TFT::draw_edit_screen_buttons() {
422443
#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);
426447
#endif
427448
}
428449

@@ -451,8 +472,8 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
451472
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
452473
}
453474
#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));
456477
#endif
457478
}
458479

@@ -898,7 +919,7 @@ void MarlinUI::move_axis_screen() {
898919
drawAxisValue(Z_AXIS);
899920

900921
// ROW 4 -> step_size disable steppers back
901-
y = TFT_HEIGHT - Y_MARGIN - 32; //
922+
y = TFT_HEIGHT - Y_MARGIN - 32;
902923
x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2;
903924
motionAxisState.stepValuePos.x = x;
904925
motionAxisState.stepValuePos.y = y;

Marlin/src/lcd/tft/ui_480x320.h

+65
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,69 @@
6363

6464
#define MENU_LINE_HEIGHT (MENU_ITEM_HEIGHT + 2)
6565

66+
/**
67+
* Status screen - portrait layout:
68+
*
69+
* | FAN E0 BED .. | - 120px
70+
* | Coordinates | - FONT_LINE_HEIGHT
71+
* | Feedrate Flowrate | - 32px
72+
* | SD Settings | - 64px if ENABLED(TOUCHSCREEN), else 0px
73+
* | Print duration time | - 29px
74+
* | Progress bar | - 7px
75+
* | Status message | - FONT_LINE_HEIGHT
76+
*
77+
* Summary with touchscreen:
78+
* - Total height: 252px + 2 * FONT_LINE_HEIGHT (320px if FONT_LINE_HEIGHT is 34px)
79+
* - Rows count: 7
80+
* - Margins count: 8
81+
*
82+
* Summary without touchscreen:
83+
* - Total height: 188px + 2 * FONT_LINE_HEIGHT (256px if FONT_LINE_HEIGHT is 34px)
84+
* - Rows count: 6
85+
* - Margins count: 7
86+
*
87+
* Status screen - landscape layout:
88+
*
89+
* | FAN E0 BED ... | - 120px
90+
* | Coordinates | - FONT_LINE_HEIGHT
91+
* | SD Flowrate Feedrate Settings | - 44px for TOUCHSCREEN, else 32px
92+
* | Print duration time | - 29px
93+
* | Progress bar | - 7px
94+
* | Status message | - FONT_LINE_HEIGHT
95+
*
96+
* Summary with touchscreen:
97+
* - Total height: 200px (268px if FONT_LINE_HEIGHT is 34px)
98+
* - Rows count: 6
99+
* - Margins count: 7
100+
*
101+
* Summary without touchscreen:
102+
* - Total height: 188px + 2 * FONT_LINE_HEIGHT (256px if FONT_LINE_HEIGHT is 34px)
103+
* - Rows count: 6
104+
* - Margins count: 7
105+
*/
106+
#ifdef TFT_COLOR_UI_PORTRAIT
107+
#if ENABLED(TOUCH_SCREEN)
108+
#define STATUS_TOTAL_ROWS_HEIGHT (2 * FONT_LINE_HEIGHT + 120 + 32 + 64 + 29 + 7)
109+
#define STATUS_MARGINS_REGIONS 8
110+
#else
111+
#define STATUS_TOTAL_ROWS_HEIGHT (2 * FONT_LINE_HEIGHT + 120 + 32 + 29 + 7)
112+
#define STATUS_MARGINS_REGIONS 7
113+
#endif
114+
115+
#define FEEDRATE_X(W) ((TFT_WIDTH - 2 * (W)) / 4)
116+
#define FLOWRATE_X(W) ((3 * TFT_WIDTH - 2 * (W)) / 4)
117+
#define SETTINGS_X (3 * TFT_WIDTH / 4 - 32)
118+
#define SDCARD_X (TFT_WIDTH / 4 - 32)
119+
#else
120+
#define STATUS_TOTAL_ROWS_HEIGHT (2 * FONT_LINE_HEIGHT + 120 + TERN(TOUCH_SCREEN, 44, 32) + 29 + 7)
121+
#define STATUS_MARGINS_REGIONS 7
122+
123+
#define FEEDRATE_X(W) (3 * TFT_WIDTH / 8 - (W) / 2)
124+
#define FLOWRATE_X(W) (5 * TFT_WIDTH / 8 - (W) / 2)
125+
#define SETTINGS_X (TFT_WIDTH / 8 - 32)
126+
#define SDCARD_X (7 * TFT_WIDTH / 8 - 32)
127+
#endif
128+
129+
#define STATUS_MARGIN_SIZE ((TFT_HEIGHT - STATUS_TOTAL_ROWS_HEIGHT) / STATUS_MARGINS_REGIONS)
130+
66131
#include "tft_font.h"

0 commit comments

Comments
 (0)