From 683916e17a6fe35c9726ad7e57e73c519fc96222 Mon Sep 17 00:00:00 2001 From: Dmitry Plastinin Date: Thu, 8 Jun 2023 07:14:34 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Portrait=20TS35=20move=20axis=20?= =?UTF-8?q?screen=20(#25945)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/tft/ui_480x320.cpp | 311 +++++++++++++++++++++--------- Marlin/src/lcd/tft/ui_480x320.h | 4 + 2 files changed, 223 insertions(+), 92 deletions(-) diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 38a706ea1b..edf75dabbd 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -639,16 +639,17 @@ static void quick_feedback() { #define CUR_STEP_VALUE_WIDTH 104 static void drawCurStepValue() { tft_string.set(ftostr52sp(motionAxisState.currentStepSize)); + tft_string.trim(); tft_string.add(F("mm")); tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT); tft.set_background(COLOR_BACKGROUND); - tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); + tft.add_text(0, 0, COLOR_AXIS_HOMED, tft_string); } #if HAS_Z_AXIS static void drawCurZSelection() { tft_string.set('Z'); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), FONT_LINE_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, Z_BTN_COLOR, tft_string); @@ -669,13 +670,17 @@ static void drawCurStepValue() { tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set('E'); - tft.add_text(0, 0, E_BTN_COLOR , tft_string); - tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); + tft_string.add(utostr3(motionAxisState.e_selection)); + tft.add_text(tft_string.center(BTN_WIDTH), 0, E_BTN_COLOR, tft_string); } #endif static void drawMessage(PGM_P const msg) { - tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - Y_OFFSET, TFT_HEIGHT / 2, Y_OFFSET); + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + tft.canvas(X_MARGIN, TFT_HEIGHT - 2 * MOVE_AXIS_MARGIN_SIZE - BTN_HEIGHT - FONT_LINE_HEIGHT, TFT_WIDTH - X_MARGIN * 2, FONT_LINE_HEIGHT); + #else + tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - Y_OFFSET, TFT_HEIGHT / 2, Y_OFFSET); + #endif tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, COLOR_YELLOW, msg); } @@ -707,7 +712,8 @@ static void drawAxisValue(const AxisEnum axis) { 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); + tft_string.trim(); + tft.add_text(tft_string.center(BTN_WIDTH + X_MARGIN), 0, color, tft_string); } static void moveAxis(const AxisEnum axis, const int8_t direction) { @@ -898,108 +904,229 @@ void MarlinUI::move_axis_screen() { if (busy) motionAxisState.z_selection = Z_SELECTION_Z_PROBE; #endif - // ROW 1 -> E+ Y+ CurY Z+ - int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + #if ENABLED(TFT_COLOR_UI_PORTRAIT) - TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy)); + int y = MOVE_AXIS_MARGIN_SIZE; - spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; - x += BTN_WIDTH + spacing; + /************************************************************************** + * 1st: | Button "E+" | Button "Y+" | Button "Z+" | + *************************************************************************/ - TERN_(HAS_Y_AXIS, drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy)); + TERN_(HAS_EXTRUDERS, drawBtn(TFT_WIDTH / 6 - BTN_WIDTH / 2, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy)); + TERN_(HAS_Y_AXIS, drawBtn(TFT_WIDTH / 2 - BTN_WIDTH / 2, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy)); + TERN_(HAS_Z_AXIS, drawBtn(TFT_WIDTH * 5 / 6 - BTN_WIDTH / 2, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET))); - x += BTN_WIDTH; + y += BTN_HEIGHT + 4; - // Cur Y - #if HAS_Y_AXIS - motionAxisState.yValuePos.set(x + 2, y); - drawAxisValue(Y_AXIS); - #endif + /************************************************************************** + * 2nd: | Label "Ex" (E0, E1, etc.) | Y value | Label "Z" | + *************************************************************************/ - x += spacing; - #if HAS_Z_AXIS - drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step - #endif - - // ROW 2 -> "Ex" X- HOME X+ "Z" - y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; - x = X_MARGIN; - spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; - - #if HAS_EXTRUDERS - motionAxisState.eNamePos.set(x, y); - drawCurESelection(); - TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); - #endif - - x += BTN_WIDTH + spacing; - - TERN_(HAS_X_AXIS, drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy)); - - x += BTN_WIDTH + spacing; //imgHome is 64x64 - - #if ALL(HAS_X_AXIS, TOUCH_SCREEN) - add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy); - #endif - - x += BTN_WIDTH + spacing; - uint16_t xplus_x = x; - - TERN_(HAS_X_AXIS, drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy)); - - x += BTN_WIDTH + spacing; - - #if HAS_Z_AXIS - motionAxisState.zTypePos.set(x, y); - drawCurZSelection(); - #if ALL(HAS_BED_PROBE, TOUCH_SCREEN) - if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, Y_OFFSET * 2, (intptr_t)z_select); + // Label "Ex" (E0, E1, etc.) + #if HAS_EXTRUDERS + motionAxisState.eNamePos.set(TFT_WIDTH / 6 - BTN_WIDTH / 2, y); + drawCurESelection(); + #if ENABLED(TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select); + #endif #endif - #endif - // ROW 3 -> E- CurX Y- Z- - y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; - x = X_MARGIN; - spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + // Y value + #if HAS_Y_AXIS + motionAxisState.yValuePos.set(TFT_WIDTH / 2 - (BTN_WIDTH + X_MARGIN) / 2, y); + drawAxisValue(Y_AXIS); + #endif - #if HAS_EXTRUDERS - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); - motionAxisState.eValuePos.set(x, y + BTN_HEIGHT + 2); - drawAxisValue(E_AXIS); - #endif + // Label "Z" + #ifdef HAS_Z_AXIS + motionAxisState.zTypePos.set(TFT_WIDTH * 5 / 6 - BTN_WIDTH / 2, y); + drawCurZSelection(); + #if ALL(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, BTN_WIDTH, FONT_LINE_HEIGHT * 2, (intptr_t)z_select); + #endif + #endif - #if HAS_X_AXIS - motionAxisState.xValuePos.set(BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4, y - 10); - TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); - #endif + y += BTN_HEIGHT + MOVE_AXIS_MARGIN_SIZE; - x += BTN_WIDTH + spacing; - TERN_(HAS_Y_AXIS, drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy)); + /************************************************************************** + * 3rd: | Button "X-" | Button "Homing" | Button "X+" | + *************************************************************************/ - x += BTN_WIDTH + spacing; - #if HAS_Z_AXIS - drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step - #endif + #if HAS_X_AXIS + drawBtn(TFT_WIDTH / 6 - BTN_WIDTH / 2, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + drawBtn(TFT_WIDTH * 5 / 6 - BTN_WIDTH / 2, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); + #endif - // Cur Z - #if HAS_Z_AXIS - motionAxisState.zValuePos.set(x, y + BTN_HEIGHT + 2); - drawAxisValue(Z_AXIS); - #endif + y += BTN_HEIGHT + 4; - // ROW 4 -> step_size disable steppers back - y = TFT_HEIGHT - Y_MARGIN - TERN(HAS_UI_480x272, BTN_WIDTH / 2, 32); - x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2; - motionAxisState.stepValuePos.set(x, y); - if (!busy) { - drawCurStepValue(); - TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); - } + /************************************************************************** + * 4th: | X value | + *************************************************************************/ - // aligned with x+ - drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + #ifdef HAS_X_AXIS + motionAxisState.xValuePos.set(TFT_WIDTH / 6 - (BTN_WIDTH + X_MARGIN) / 2, y); + drawAxisValue(X_AXIS); + #endif - TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); + y += BTN_HEIGHT + MOVE_AXIS_MARGIN_SIZE; + + /************************************************************************** + * 5th: | Button "E-" | Button "Y-" | Button "Z-" + *************************************************************************/ + + TERN_(HAS_EXTRUDERS, drawBtn(TFT_WIDTH / 6 - BTN_WIDTH / 2, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy)); + TERN_(HAS_Y_AXIS, drawBtn(TFT_WIDTH / 2 - BTN_WIDTH / 2, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy)); + TERN_(HAS_Z_AXIS, drawBtn(TFT_WIDTH * 5 / 6 - BTN_WIDTH / 2, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET))); + + y += BTN_HEIGHT + 4; + + /************************************************************************** + * 6th: | Current Ex value | Z value | + *************************************************************************/ + + // Current Ex value + #ifdef HAS_EXTRUDERS + motionAxisState.eValuePos.set(TFT_WIDTH / 6 - (BTN_WIDTH + X_MARGIN) / 2, y); + drawAxisValue(E_AXIS); + #endif + + #ifdef HAS_Z_AXIS + motionAxisState.zValuePos.set(TFT_WIDTH * 5 / 6 - (BTN_WIDTH + X_MARGIN) / 2, y); + drawAxisValue(Z_AXIS); + #endif + + y += BTN_HEIGHT + MOVE_AXIS_MARGIN_SIZE; + + /************************************************************************** + * 7th: | Message - drawMessage(...) function | + *************************************************************************/ + + y += FONT_LINE_HEIGHT + MOVE_AXIS_MARGIN_SIZE; + + /************************************************************************** + * 8th: | Step size | Button "Disable steppers" | Button "Back" | + *************************************************************************/ + + // Step size + motionAxisState.stepValuePos.set(X_MARGIN, y + 12); + if (!busy) { + drawCurStepValue(); + TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y + 12, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + } + + // Button "Disable steppers" + drawBtn(TFT_WIDTH / 2, y, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + // Button "Back" + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH * 5 / 6 - Images[imgBack].width / 2, y + 12, BACK, imgBack)); + + #else // !TFT_COLOR_UI_PORTRAIT + + // 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)); + + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + x += BTN_WIDTH + spacing; + + TERN_(HAS_Y_AXIS, drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy)); + + x += BTN_WIDTH; + + // Cur Y + #if HAS_Y_AXIS + motionAxisState.yValuePos.set(x + 2, y); + drawAxisValue(Y_AXIS); + #endif + + x += spacing; + #if HAS_Z_AXIS + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif + + // ROW 2 -> "Ex" X- HOME X+ "Z" + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; + + #if HAS_EXTRUDERS + motionAxisState.eNamePos.set(x, y); + drawCurESelection(); + TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #endif + + x += BTN_WIDTH + spacing; + + TERN_(HAS_X_AXIS, drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy)); + + x += BTN_WIDTH + spacing; //imgHome is 64x64 + + #if ALL(HAS_X_AXIS, TOUCH_SCREEN) + add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy); + #endif + + x += BTN_WIDTH + spacing; + uint16_t xplus_x = x; + + TERN_(HAS_X_AXIS, drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy)); + + x += BTN_WIDTH + spacing; + + #if HAS_Z_AXIS + motionAxisState.zTypePos.set(x, y); + drawCurZSelection(); + #if ALL(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, Y_OFFSET * 2, (intptr_t)z_select); + #endif + #endif + + // ROW 3 -> E- CurX Y- Z- + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + + #if HAS_EXTRUDERS + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + motionAxisState.eValuePos.set(x, y + BTN_HEIGHT + 2); + drawAxisValue(E_AXIS); + #endif + + #if HAS_X_AXIS + motionAxisState.xValuePos.set(BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4, y - 10); + TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); + #endif + + x += BTN_WIDTH + spacing; + TERN_(HAS_Y_AXIS, drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy)); + + x += BTN_WIDTH + spacing; + #if HAS_Z_AXIS + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif + + // Cur Z + #if HAS_Z_AXIS + motionAxisState.zValuePos.set(x, y + BTN_HEIGHT + 2); + drawAxisValue(Z_AXIS); + #endif + + // ROW 4 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - TERN(HAS_UI_480x272, BTN_WIDTH / 2, 32); + x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2; + motionAxisState.stepValuePos.set(x, y); + if (!busy) { + drawCurStepValue(); + TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + } + + // aligned with x+ + drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); + + #endif // !TFT_COLOR_UI_PORTRAIT } #endif // HAS_UI_480x320 || HAS_UI_480x272 diff --git a/Marlin/src/lcd/tft/ui_480x320.h b/Marlin/src/lcd/tft/ui_480x320.h index 785f4c3cbf..d3036d0981 100644 --- a/Marlin/src/lcd/tft/ui_480x320.h +++ b/Marlin/src/lcd/tft/ui_480x320.h @@ -107,6 +107,10 @@ #if ENABLED(TOUCH_SCREEN) #define STATUS_TOTAL_ROWS_HEIGHT (2 * FONT_LINE_HEIGHT + 120 + 32 + 64 + 29 + 7) #define STATUS_MARGINS_REGIONS 8 + + #define MOVE_AXIS_TOTAL_ROWS_HEIGHT (7 * BTN_HEIGHT + FONT_LINE_HEIGHT + 12) + #define MOVE_AXIS_MARGIN_REGIONS 6 + #define MOVE_AXIS_MARGIN_SIZE ((TFT_HEIGHT - MOVE_AXIS_TOTAL_ROWS_HEIGHT) / MOVE_AXIS_MARGIN_REGIONS) #else #define STATUS_TOTAL_ROWS_HEIGHT (2 * FONT_LINE_HEIGHT + 120 + 32 + 29 + 7) #define STATUS_MARGINS_REGIONS 7