Skip to content

Commit

Permalink
🚸 Fix TFT menu positioning (#25942)
Browse files Browse the repository at this point in the history
Co-authored-by: Ed <751406+helakejr@users.noreply.github.com>
  • Loading branch information
thinkyhead and helakejr committed Jun 8, 2023
1 parent d1e9956 commit 54a82b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ struct {
#define BTN_HEIGHT 52
#define X_MARGIN 20
#define Y_MARGIN 15
#define Y_OFFSET TERN(HAS_UI_480x272, 28, 34)

static void quick_feedback() {
#if HAS_CHIRP
Expand Down Expand Up @@ -652,7 +653,7 @@ static void drawCurStepValue() {
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
tft.queue.sync();
tft_string.set(F("Offset"));
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + Y_OFFSET, tft_string.width(), Y_OFFSET TERN_(HAS_UI_480x272, - 10));
tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE)
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
Expand All @@ -670,7 +671,7 @@ static void drawCurStepValue() {
#endif

static void drawMessage(PGM_P const msg) {
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - Y_OFFSET, TFT_HEIGHT / 2, Y_OFFSET);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(0, 0, COLOR_YELLOW, msg);
}
Expand Down Expand Up @@ -699,7 +700,7 @@ static void drawAxisValue(const AxisEnum axis) {
#endif
default: return;
}
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT TERN_(HAS_UI_480x272, / 2));
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ftostr52sp(value));
tft.add_text(0, 0, color, tft_string);
Expand Down Expand Up @@ -891,7 +892,7 @@ void MarlinUI::move_axis_screen() {

TERN_(HAS_Z_AXIS, motionAxisState.z_selection = Z_SELECTION_Z_PROBE);

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

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

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

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

#endif // HAS_UI_480x320
#endif // HAS_UI_480x320 || HAS_UI_480x272

0 comments on commit 54a82b4

Please sign in to comment.