Skip to content

Commit 7976cec

Browse files
thinkyheadhelakejr
andcommitted
Fix TFT menu positioning
Co-Authored-By: Ed <751406+helakejr@users.noreply.github.com>
1 parent 322d5dc commit 7976cec

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Marlin/src/lcd/tft/ui_480x320.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ struct {
623623
#define BTN_HEIGHT 52
624624
#define X_MARGIN 20
625625
#define Y_MARGIN 15
626+
#define Y_OFFSET TERN(HAS_UI_480x272, 28, 34)
626627

627628
static void quick_feedback() {
628629
#if HAS_CHIRP
@@ -652,7 +653,7 @@ static void drawCurStepValue() {
652653
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
653654
tft.queue.sync();
654655
tft_string.set(F("Offset"));
655-
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
656+
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + Y_OFFSET, tft_string.width(), Y_OFFSET TERN_(HAS_UI_480x272, - 10));
656657
tft.set_background(COLOR_BACKGROUND);
657658
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE)
658659
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
@@ -670,7 +671,7 @@ static void drawCurStepValue() {
670671
#endif
671672

672673
static void drawMessage(PGM_P const msg) {
673-
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
674+
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - Y_OFFSET, TFT_HEIGHT / 2, Y_OFFSET);
674675
tft.set_background(COLOR_BACKGROUND);
675676
tft.add_text(0, 0, COLOR_YELLOW, msg);
676677
}
@@ -699,7 +700,7 @@ static void drawAxisValue(const AxisEnum axis) {
699700
#endif
700701
default: return;
701702
}
702-
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
703+
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, B_HEIGHT TERN_(HAS_UI_480x272, / 2));
703704
tft.set_background(COLOR_BACKGROUND);
704705
tft_string.set(ftostr52sp(value));
705706
tft.add_text(0, 0, color, tft_string);
@@ -891,7 +892,7 @@ void MarlinUI::move_axis_screen() {
891892

892893
TERN_(HAS_Z_AXIS, motionAxisState.z_selection = Z_SELECTION_Z_PROBE);
893894

894-
// ROW 1 -> E- Y- CurY Z+
895+
// ROW 1 -> E+ Y+ CurY Z+
895896
int x = X_MARGIN, y = Y_MARGIN, spacing = 0;
896897

897898
TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy));
@@ -941,7 +942,7 @@ void MarlinUI::move_axis_screen() {
941942
motionAxisState.zTypePos.y = y;
942943
TERN_(HAS_Z_AXIS, drawCurZSelection());
943944
#if ALL(HAS_BED_PROBE, TOUCH_SCREEN)
944-
if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select);
945+
if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, Y_OFFSET * 2, (intptr_t)z_select);
945946
#endif
946947

947948
// ROW 3 -> E- CurX Y- Z-
@@ -975,7 +976,7 @@ void MarlinUI::move_axis_screen() {
975976
TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
976977

977978
// ROW 4 -> step_size disable steppers back
978-
y = TFT_HEIGHT - Y_MARGIN - 32;
979+
y = TFT_HEIGHT - Y_MARGIN - TERN(HAS_UI_480x272, BTN_WIDTH / 2, 32);
979980
x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2;
980981
motionAxisState.stepValuePos.x = x;
981982
motionAxisState.stepValuePos.y = y;
@@ -990,4 +991,4 @@ void MarlinUI::move_axis_screen() {
990991
TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack));
991992
}
992993

993-
#endif // HAS_UI_480x320
994+
#endif // HAS_UI_480x320 || HAS_UI_480x272

0 commit comments

Comments
 (0)