diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 88d7c91c6ef3..af9dd2255799 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -324,7 +324,7 @@ #define IS_ULTIPANEL 1 #endif -// TFT Compatibility +// TFT Legacy Compatibility #if ANY(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI) #define IS_LEGACY_TFT 1 #define TFT_GENERIC @@ -1525,30 +1525,6 @@ #endif #endif -#if ENABLED(TFT_RES_320x240) - #define TFT_WIDTH 320 - #define TFT_HEIGHT 240 - #define GRAPHICAL_TFT_UPSCALE 2 -#elif ENABLED(TFT_RES_480x272) - #define TFT_WIDTH 480 - #define TFT_HEIGHT 272 - #define GRAPHICAL_TFT_UPSCALE 2 -#elif ENABLED(TFT_RES_480x320) - #define TFT_WIDTH 480 - #define TFT_HEIGHT 320 - #define GRAPHICAL_TFT_UPSCALE 3 -#elif ENABLED(TFT_RES_1024x600) - #define TFT_WIDTH 1024 - #define TFT_HEIGHT 600 - #if ENABLED(TOUCH_SCREEN) - #define GRAPHICAL_TFT_UPSCALE 6 - #define TFT_PIXEL_OFFSET_X 120 - #else - #define GRAPHICAL_TFT_UPSCALE 8 - #define TFT_PIXEL_OFFSET_X 0 - #endif -#endif - // FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi|ltdc).h #if ENABLED(TFT_INTERFACE_FSMC) #define HAS_FSMC_TFT 1 @@ -1573,8 +1549,62 @@ #endif #endif +// Set TFT_COLOR_UI_PORTRAIT flag, if needed +#if defined(TFT_ROTATION) && (HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT) + #define _CMP_TFT_ROTATE_90 90 + #define _CMP_TFT_ROTATE_270 270 + #define _CMP_TFT_ROTATE_90_MIRROR_X 90 + #define _CMP_TFT_ROTATE_90_MIRROR_Y 90 + #define _CMP_TFT_ROTATE_270_MIRROR_X 270 + #define _CMP_TFT_ROTATE_270_MIRROR_Y 270 + #define _ISROT(N) || (_CAT(_CMP_, TFT_ROTATION) == N) + #define ISROT(V...) (0 MAP(_ISROT, V)) + + #if ISROT(90, 270) + #define TFT_COLOR_UI_PORTRAIT 1 + #endif + + #undef _CMP_TFT_ROTATE_90 + #undef _CMP_TFT_ROTATE_270 + #undef _CMP_TFT_ROTATE_90_MIRROR_X + #undef _CMP_TFT_ROTATE_90_MIRROR_Y + #undef _CMP_TFT_ROTATE_270_MIRROR_X + #undef _CMP_TFT_ROTATE_270_MIRROR_Y + #undef _ISROT + #undef ISROT +#endif + +#if ENABLED(TFT_RES_320x240) + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + #define TFT_WIDTH 240 + #define TFT_HEIGHT 320 + #else + #define TFT_WIDTH 320 + #define TFT_HEIGHT 240 + #endif + #define GRAPHICAL_TFT_UPSCALE 2 +#elif ENABLED(TFT_RES_480x272) + #define TFT_WIDTH 480 + #define TFT_HEIGHT 272 + #define GRAPHICAL_TFT_UPSCALE 2 +#elif ENABLED(TFT_RES_480x320) + #define TFT_WIDTH 480 + #define TFT_HEIGHT 320 + #define GRAPHICAL_TFT_UPSCALE 3 +#elif ENABLED(TFT_RES_1024x600) + #define TFT_WIDTH 1024 + #define TFT_HEIGHT 600 + #if ENABLED(TOUCH_SCREEN) + #define GRAPHICAL_TFT_UPSCALE 6 + #define TFT_PIXEL_OFFSET_X 120 + #else + #define GRAPHICAL_TFT_UPSCALE 8 + #define TFT_PIXEL_OFFSET_X 0 + #endif +#endif + #if ENABLED(TFT_COLOR_UI) - #if TFT_HEIGHT == 240 + #if (TFT_WIDTH == 320 && TFT_HEIGHT == 240) || (TFT_WIDTH == 240 && TFT_HEIGHT == 320) #if ENABLED(TFT_INTERFACE_SPI) #define TFT_320x240_SPI #elif ENABLED(TFT_INTERFACE_FSMC) @@ -1612,6 +1642,8 @@ #endif #if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272) #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen +#elif HAS_UI_240x320 + #define LCD_HEIGHT TERN(TOUCH_SCREEN, 8, 6) // Fewer lines with touch buttons onscreen #elif HAS_UI_1024x600 #define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13) // Fewer lines with touch buttons onscreen #endif diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 6df4c22d5191..7dc3996148ab 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -37,22 +37,6 @@ #define ENDIAN_COLOR(C) (C) #endif -#if HAS_UI_320x240 - #define TFT_WIDTH 320 - #define TFT_HEIGHT 240 -#elif HAS_UI_480x320 - #define TFT_WIDTH 480 - #define TFT_HEIGHT 320 -#elif HAS_UI_480x272 - #define TFT_WIDTH 480 - #define TFT_HEIGHT 272 -#elif HAS_UI_1024x600 - #define TFT_WIDTH 1024 - #define TFT_HEIGHT 600 -#else - #error "Unsupported display resolution!" -#endif - #ifndef TFT_BUFFER_SIZE #ifdef STM32F103xB #define TFT_BUFFER_SIZE 1024 diff --git a/Marlin/src/lcd/tft/tft_font.h b/Marlin/src/lcd/tft/tft_font.h index 5ed5f8380cc5..6c8838ed7c48 100644 --- a/Marlin/src/lcd/tft/tft_font.h +++ b/Marlin/src/lcd/tft/tft_font.h @@ -37,5 +37,4 @@ extern const uint8_t SYMBOLS_FONT_NAME[]; extern const uint8_t EXTRA_FONT_NAME[]; #endif - #endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 6511757d7dfa..f3eb83eb9f50 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -700,12 +700,12 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { probe.offset.z = new_offs; else TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(""); // clear the error + drawMessage(F("")); // clear the error drawAxisValue(axis); } - else { + else drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } + #elif HAS_BED_PROBE // only change probe.offset.z probe.offset.z += diff; @@ -717,9 +717,9 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } - else { - drawMessage(""); // clear the error - } + else + drawMessage(F("")); // clear the error + drawAxisValue(axis); #endif return; @@ -765,10 +765,8 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } #if ENABLED(TOUCH_SCREEN) static void e_select() { - motionAxisState.e_selection++; - if (motionAxisState.e_selection >= EXTRUDERS) { + if (++motionAxisState.e_selection >= EXTRUDERS) motionAxisState.e_selection = 0; - } quick_feedback(); drawCurESelection(); @@ -810,8 +808,8 @@ static void disable_steppers() { } static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { - uint16_t width = Images[imgBtn52Rounded].width; - uint16_t height = Images[imgBtn52Rounded].height; + uint16_t width = Images[imgBtn52Rounded].width, + height = Images[imgBtn52Rounded].height; if (!enabled) bgColor = COLOR_CONTROL_DISABLED; diff --git a/Marlin/src/lcd/tft/ui_1024x600.h b/Marlin/src/lcd/tft/ui_1024x600.h index 855b0db865f9..c6b5d9f85ec1 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.h +++ b/Marlin/src/lcd/tft/ui_1024x600.h @@ -35,15 +35,15 @@ #define MENU_ITEM_ICON_Y 5 #define MENU_ITEM_ICON_SPACE 42 +#define MENU_ITEM_HEIGHT 43 +#define MENU_LINE_HEIGHT (MENU_ITEM_HEIGHT + 2) + #if (TFT_FONT == NOTOSANS) || (TFT_FONT == HELVETICA) #define FONT_SIZE 19 #elif TFT_FONT == UNIFONT #define FONT_SIZE 20 #endif -#define MENU_ITEM_HEIGHT 43 #define FONT_LINE_HEIGHT 34 -#define MENU_LINE_HEIGHT (MENU_ITEM_HEIGHT + 2) - #include "tft_font.h" diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 85ed59b2cce9..07fa95732726 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -49,9 +49,11 @@ void MarlinUI::tft_idle() { #if ENABLED(TOUCH_SCREEN) if (TERN0(HAS_TOUCH_SLEEP, lcd_sleep_task())) return; if (draw_menu_navigation) { - add_control(48, 206, PAGE_UP, imgPageUp, encoderTopLine > 0); - add_control(240, 206, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items); - add_control(144, 206, BACK, imgBack); + constexpr uint16_t cx = TERN(TFT_COLOR_UI_PORTRAIT, 16, 48), + cy = TERN(TFT_COLOR_UI_PORTRAIT, 286, 206); + add_control(cx, cy, PAGE_UP, imgPageUp, encoderTopLine > 0); + add_control(cx + 192, cy, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items); + add_control(cx + 96, cy, BACK, imgBack); draw_menu_navigation = false; } #endif @@ -97,19 +99,19 @@ void MarlinUI::draw_kill_screen() { tft.queue.reset(); tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_KILL_SCREEN_BG); - tft.canvas(0, 60, TFT_WIDTH, 24); + tft.canvas(0, 60, TFT_WIDTH, FONT_LINE_HEIGHT); tft.set_background(COLOR_KILL_SCREEN_BG); tft_string.set(status_message); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_KILL_SCREEN_TEXT, tft_string); - tft.canvas(0, 120, TFT_WIDTH, 24); + tft.canvas(0, 120, TFT_WIDTH, FONT_LINE_HEIGHT); tft.set_background(COLOR_KILL_SCREEN_BG); tft_string.set(GET_TEXT(MSG_HALTED)); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_KILL_SCREEN_TEXT, tft_string); - tft.canvas(0, 160, TFT_WIDTH, 24); + tft.canvas(0, 160, TFT_WIDTH, FONT_LINE_HEIGHT); tft.set_background(COLOR_KILL_SCREEN_BG); tft_string.set(GET_TEXT(MSG_PLEASE_RESET)); tft_string.trim(); @@ -185,13 +187,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft_string.set(i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); - tft.add_text(tft_string.center(64) + 2, 69 + tft_string.vcenter(24), Color, tft_string); + tft.add_text(tft_string.center(64) + 2, 69 + tft_string.vcenter(FONT_LINE_HEIGHT), Color, tft_string); if (targetTemperature >= 0) { tft_string.set(i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); - tft.add_text(tft_string.center(64) + 2, 5 + tft_string.vcenter(24), Color, tft_string); + tft.add_text(tft_string.center(64) + 2, 5 + tft_string.vcenter(FONT_LINE_HEIGHT), Color, tft_string); } } @@ -214,7 +216,7 @@ void draw_fan_status(uint16_t x, uint16_t y, const bool blink) { tft_string.set(ui8tostr4pctrj(thermalManager.fan_speed[0])); tft_string.trim(); - tft.add_text(tft_string.center(64) + 6, 69 + tft_string.vcenter(24), COLOR_FAN, tft_string); + tft.add_text(tft_string.center(64) + 6, 69 + tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_FAN, tft_string); } void MarlinUI::draw_status_screen() { @@ -226,7 +228,7 @@ void MarlinUI::draw_status_screen() { uint16_t i, x, y = TFT_STATUS_TOP_Y; for (i = 0 ; i < ITEMS_COUNT; i++) { - x = (320 / ITEMS_COUNT - 64) / 2 + (320 * i / ITEMS_COUNT); + x = (TFT_WIDTH / ITEMS_COUNT - 64) / 2 + (TFT_WIDTH * i / ITEMS_COUNT); switch (i) { #ifdef ITEM_E0 case ITEM_E0: draw_heater_status(x, y, H_E0); break; @@ -253,33 +255,60 @@ void MarlinUI::draw_status_screen() { } // coordinates - tft.canvas(4, 103, 312, 24); + tft.canvas(4, 103, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 232, FONT_LINE_HEIGHT * 2 + #else + 312, FONT_LINE_HEIGHT + #endif + ); tft.set_background(COLOR_BACKGROUND); - tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED); + tft.add_rectangle(0, 0, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 232, FONT_LINE_HEIGHT * 2 + #else + 312, FONT_LINE_HEIGHT + #endif + , COLOR_AXIS_HOMED + ); if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { #if ENABLED(LCD_SHOW_E_TOTAL) - tft.add_text( 10, tft_string.vcenter(24), COLOR_AXIS_HOMED , "E"); + tft.add_text( 10, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "E"); const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm tft_string.set(ftostr4sign(e_move_accumulator / escale)); tft_string.add(escale == 10 ? 'c' : 'm'); tft_string.add('m'); - tft.add_text(127 - tft_string.width(), tft_string.vcenter(24), COLOR_AXIS_HOMED, tft_string); + tft.add_text(127 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); #endif } else { - tft.add_text( 10, tft_string.vcenter(24), COLOR_AXIS_HOMED , "X"); + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 32, 10), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "X"); const bool nhx = axis_should_home(X_AXIS); tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text( 68 - tft_string.width(), tft_string.vcenter(24), nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 32 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 68 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string + ); - tft.add_text(127, tft_string.vcenter(24), COLOR_AXIS_HOMED , "Y"); + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 110, 127), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Y"); const bool nhy = axis_should_home(Y_AXIS); tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text(185 - tft_string.width(), tft_string.vcenter(24), nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 110 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 185 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string + ); } - tft.add_text(219, tft_string.vcenter(24), COLOR_AXIS_HOMED , "Z"); + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 192, 219), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Z"); const bool nhz = axis_should_home(Z_AXIS); uint16_t offset = 25; if (blink && nhz) @@ -293,61 +322,138 @@ void MarlinUI::draw_status_screen() { tft_string.set(ftostr52sp(z)); offset -= tft_string.width(); } - tft.add_text(301 - tft_string.width() - offset, tft_string.vcenter(24), nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, 312, 24)); + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 192 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 301 - tft_string.width() - offset, tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 232, FONT_LINE_HEIGHT * 2 + #else + 312, FONT_LINE_HEIGHT + #endif + )); // feed rate - tft.canvas(70, 136, 84, 32); + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 30, 172, 80 + #else + 70, 136, 84 + #endif + , 32 + ); tft.set_background(COLOR_BACKGROUND); uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; tft.add_image(0, 0, imgFeedRate, color); tft_string.set(i16tostr3rj(feedrate_percentage)); tft_string.add('%'); tft.add_text(32, tft_string.vcenter(30), color , tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 70, 136, 84, 32)); + TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 30, 172, 80 + #else + 70, 136, 84 + #endif + , 32 + )); // flow rate - tft.canvas(170, 136, 84, 32); + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 140, 172, 80 + #else + 170, 136, 84 + #endif + , 32 + ); tft.set_background(COLOR_BACKGROUND); color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; tft.add_image(0, 0, imgFlowRate, color); tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); tft_string.add('%'); tft.add_text(32, tft_string.vcenter(30), color , tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 170, 136, 84, 32, active_extruder)); + TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 140, 172, 80 + #else + 170, 136, 84 + #endif + , 32, active_extruder + )); // print duration char buffer[14]; duration_t elapsed = print_job_timer.duration(); elapsed.toDigital(buffer); - tft.canvas(96, 173, 128, 24); + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 56, 256, 128 + #else + 96, 173, 128 + #endif + , FONT_LINE_HEIGHT + ); tft.set_background(COLOR_BACKGROUND); tft_string.set(buffer); - tft.add_text(tft_string.center(128), tft_string.vcenter(24), COLOR_PRINT_TIME, tft_string); + tft.add_text(tft_string.center(128), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_PRINT_TIME, tft_string); // progress bar const uint8_t progress = ui.get_progress_percent(); - tft.canvas(4, 198, 312, 9); + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 4, 278, 232 + #else + 4, 198, 312 + #endif + , 9 + ); tft.set_background(COLOR_PROGRESS_BG); - tft.add_rectangle(0, 0, 312, 9, COLOR_PROGRESS_FRAME); + tft.add_rectangle(0, 0, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 232, 9 + #else + 312, 9 + #endif + , COLOR_PROGRESS_FRAME + ); if (progress) - tft.add_bar(1, 1, (310 * progress) / 100, 7, COLOR_PROGRESS_BAR); + tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR); // status message - tft.canvas(0, 212, 320, 24); + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 0, 296, 240 + #else + 0, 212, 320 + #endif + , FONT_LINE_HEIGHT + ); tft.set_background(COLOR_BACKGROUND); tft_string.set(status_message); tft_string.trim(); - tft.add_text(tft_string.center(TFT_WIDTH), tft_string.vcenter(24), COLOR_STATUS_MESSAGE, tft_string); + tft.add_text(tft_string.center(TFT_WIDTH), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_STATUS_MESSAGE, tft_string); #if ENABLED(TOUCH_SCREEN) - add_control(256, 130, menu_main, imgSettings); + { + add_control( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 176, 210 + #else + 256, 130 + #endif + , menu_main, imgSettings + ); #if ENABLED(SDSUPPORT) const bool cm = card.isMounted(), pa = printingIsActive(); - add_control(0, 130, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + add_control(0, TERN(TFT_COLOR_UI_PORTRAIT, 210, 130), menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); #endif - #endif + } // (sublime) + #endif // TOUCH_SCREEN } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace @@ -412,9 +518,9 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va void TFT::draw_edit_screen_buttons() { #if ENABLED(TOUCH_SCREEN) - add_control(32, TFT_HEIGHT - 64, DECREASE, imgDecrease); - add_control(224, TFT_HEIGHT - 64, INCREASE, imgIncrease); - add_control(128, TFT_HEIGHT - 64, CLICK, imgConfirm); + add_control(TERN(TFT_COLOR_UI_PORTRAIT, 16, 32), TFT_HEIGHT - 64, DECREASE, imgDecrease); + add_control(TERN(TFT_COLOR_UI_PORTRAIT, 172, 224), TFT_HEIGHT - 64, INCREASE, imgIncrease); + add_control(TERN(TFT_COLOR_UI_PORTRAIT, 96, 128), TFT_HEIGHT - 64, CLICK, imgConfirm); #endif } @@ -443,8 +549,8 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - if (no) add_control( 48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - if (yes) add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + if (no) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 32, 48), TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + if (yes) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 172, 208), TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -625,9 +731,16 @@ static void drawCurESelection() { } static void drawMessage(PGM_P const msg) { - tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 29, (TFT_WIDTH / 2) - (BTN_WIDTH / 2) - X_MARGIN, 20); + tft.canvas(X_MARGIN, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + TFT_HEIGHT - 2 * BTN_HEIGHT, TFT_WIDTH - X_MARGIN + #else + TFT_HEIGHT - Y_MARGIN - 29, (TFT_WIDTH / 2) - (BTN_WIDTH / 2) - X_MARGIN + #endif + , FONT_LINE_HEIGHT + ); tft.set_background(COLOR_BACKGROUND); - tft.add_text(0, 0, COLOR_YELLOW, msg); + tft.add_text(0, 0, COLOR_STATUS_MESSAGE, msg); } static void drawMessage(FSTR_P const fmsg) { drawMessage(FTOP(fmsg)); } @@ -646,7 +759,7 @@ static void drawAxisValue(const AxisEnum axis) { case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; default: return; } - tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, 20); + tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, FONT_LINE_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(ftostr52sp(value)); tft.add_text(0, 0, color, tft_string); @@ -745,10 +858,8 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } #if ENABLED(TOUCH_SCREEN) static void e_select() { - motionAxisState.e_selection++; - if (motionAxisState.e_selection >= EXTRUDERS) { + if (++motionAxisState.e_selection >= EXTRUDERS) motionAxisState.e_selection = 0; - } quick_feedback(); drawCurESelection(); @@ -773,16 +884,17 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } quick_feedback(); drawCurStepValue(); } -#endif -#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) - static void z_select() { - motionAxisState.z_selection *= -1; - quick_feedback(); - drawCurZSelection(); - drawAxisValue(Z_AXIS); - } -#endif + #if HAS_BED_PROBE + static void z_select() { + motionAxisState.z_selection *= -1; + quick_feedback(); + drawCurZSelection(); + drawAxisValue(Z_AXIS); + } + #endif + +#endif // TOUCH_SCREEN static void disable_steppers() { quick_feedback(); @@ -805,12 +917,12 @@ static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage tft_string.trim(); tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string); } - else { + else tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); - } TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); } + void MarlinUI::move_axis_screen() { // Reset defer_status_screen(true); @@ -827,93 +939,187 @@ void MarlinUI::move_axis_screen() { if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) motionAxisState.z_selection = Z_SELECTION_Z_PROBE; - // ROW 1 -> E- Y- CurY Z+ - int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + #if ENABLED(TFT_COLOR_UI_PORTRAIT) - drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + // ROW 1 -> E+ Y+ Z+ + int x = X_MARGIN, y = Y_MARGIN, spacing = 0; - spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; - x += BTN_WIDTH + spacing; - uint16_t yplus_x = x; - drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); - // Cur Y - x += BTN_WIDTH; - motionAxisState.yValuePos.x = x + 2; - motionAxisState.yValuePos.y = y; - drawAxisValue(Y_AXIS); + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + x += BTN_WIDTH + spacing; + uint16_t yplus_x = x; + drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); - x += spacing; - 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 + x += BTN_WIDTH + spacing; + uint16_t zplus_x = x; + 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 - // 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; + // ROW 2 -> "Ex" CurY "Z" + x = X_MARGIN; + y += BTN_HEIGHT + 2; - motionAxisState.eNamePos.x = x; - motionAxisState.eNamePos.y = y; - drawCurESelection(); - TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + motionAxisState.eNamePos.x = x; + motionAxisState.eNamePos.y = y; + drawCurESelection(); + TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); - x += BTN_WIDTH + spacing; - drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + motionAxisState.yValuePos.x = yplus_x; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); - x += BTN_WIDTH + spacing; //imgHome is 64x64 - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + motionAxisState.zTypePos.x = zplus_x; + motionAxisState.zTypePos.y = y; + drawCurZSelection(); - x += BTN_WIDTH + spacing; - uint16_t xplus_x = x; - drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); + // ROW 3 -> X- HOME X+ + y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2; + x = X_MARGIN; - x += BTN_WIDTH + spacing; - motionAxisState.zTypePos.x = x; - motionAxisState.zTypePos.y = y; - drawCurZSelection(); - #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) - if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); - #endif + drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); - // 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; + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + drawBtn(zplus_x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); - // Cur E - motionAxisState.eValuePos.x = x; - motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(E_AXIS); + #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); + #endif - // Cur X - motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos - motionAxisState.xValuePos.y = y - 10; - drawAxisValue(X_AXIS); + // ROW 4 -> Cur X + y += BTN_HEIGHT + 2; - x += BTN_WIDTH + spacing; - drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + motionAxisState.xValuePos.x = x; + motionAxisState.xValuePos.y = y; + drawAxisValue(X_AXIS); - x += BTN_WIDTH + spacing; - 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 + // ROW 5 -> E- CurX Y- Z- + y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2; + x = X_MARGIN; - // Cur Z - motionAxisState.zValuePos.x = x; - motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(Z_AXIS); + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); - // ROW 4 -> step_size disable steppers back - y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // - x = xplus_x - CUR_STEP_VALUE_WIDTH - 10; - motionAxisState.stepValuePos.x = yplus_x + BTN_WIDTH - CUR_STEP_VALUE_WIDTH; - motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; - if (!busy) { - drawCurStepValue(); - TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); - } + // Cur E + motionAxisState.eValuePos.x = x; + motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(E_AXIS); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + 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 + + // Cur Z + motionAxisState.zValuePos.x = x; + motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(Z_AXIS); + + // ROW 6 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // + x = zplus_x - CUR_STEP_VALUE_WIDTH - 10; + motionAxisState.stepValuePos.x = X_MARGIN + BTN_WIDTH - CUR_STEP_VALUE_WIDTH; + motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; + + if (!busy) { + drawCurStepValue(); + TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + } + + // aligned with x+ + drawBtn(yplus_x, y, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + #else // !TFT_COLOR_UI_PORTRAIT + + // ROW 1 -> E+ Y+ CurY Z+ + int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + + 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; + uint16_t yplus_x = x; + drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + + // Cur Y + x += BTN_WIDTH; + motionAxisState.yValuePos.x = x + 2; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); + + x += spacing; + 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 + + // 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; + + motionAxisState.eNamePos.x = x; + motionAxisState.eNamePos.y = y; + drawCurESelection(); + TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; //imgHome is 64x64 + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + + x += BTN_WIDTH + spacing; + uint16_t xplus_x = x; + drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + motionAxisState.zTypePos.x = x; + motionAxisState.zTypePos.y = y; + drawCurZSelection(); + #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); + #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; + + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + + // Cur E + motionAxisState.eValuePos.x = x; + motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(E_AXIS); + + // Cur X + motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos + motionAxisState.xValuePos.y = y - 10; + drawAxisValue(X_AXIS); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + 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 + + // Cur Z + motionAxisState.zValuePos.x = x; + motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(Z_AXIS); + + // ROW 4 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // + x = xplus_x - CUR_STEP_VALUE_WIDTH - 10; + motionAxisState.stepValuePos.x = yplus_x + BTN_WIDTH - CUR_STEP_VALUE_WIDTH; + motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; + if (!busy) { + drawCurStepValue(); + TERN_(HAS_TFT_XPT2046, 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, y, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); - // aligned with x+ - drawBtn(xplus_x, y, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + #endif // !TFT_COLOR_UI_PORTRAIT TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } diff --git a/Marlin/src/lcd/tft/ui_320x240.h b/Marlin/src/lcd/tft/ui_320x240.h index 72aafbf245c0..555ca3616a09 100644 --- a/Marlin/src/lcd/tft/ui_320x240.h +++ b/Marlin/src/lcd/tft/ui_320x240.h @@ -44,4 +44,6 @@ #define FONT_SIZE 10 #endif +#define FONT_LINE_HEIGHT 24 + #include "tft_font.h" diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index e8d51d89a10f..02e9ca196aba 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -746,10 +746,8 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } #if ENABLED(TOUCH_SCREEN) static void e_select() { - motionAxisState.e_selection++; - if (motionAxisState.e_selection >= EXTRUDERS) { + if (++motionAxisState.e_selection >= EXTRUDERS) motionAxisState.e_selection = 0; - } quick_feedback(); drawCurESelection(); @@ -791,8 +789,8 @@ static void disable_steppers() { } static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { - uint16_t width = Images[imgBtn52Rounded].width; - uint16_t height = Images[imgBtn52Rounded].height; + uint16_t width = Images[imgBtn52Rounded].width, + height = Images[imgBtn52Rounded].height; if (!enabled) bgColor = COLOR_CONTROL_DISABLED; diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index c1c4a8e3b192..8f68d789009d 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -49,19 +49,14 @@ #define TFT_MIRROR_X (TFT_INVERT_Y) #define TFT_MIRROR_Y (TFT_INVERT_X) -#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_INVERT_Y) -#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_INVERT_X) +#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_MIRROR_X) +#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_MIRROR_Y) -#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y) -#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X) +#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_MIRROR_X) +#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_MIRROR_Y) -#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_INVERT_Y) -#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_INVERT_X) - -// TFT_ROTATION is user configurable -#ifndef TFT_ROTATION - #define TFT_ROTATION TFT_NO_ROTATION -#endif +#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_MIRROR_X) +#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_MIRROR_Y) // TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION #define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION)) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 59441dc80609..cd4989d73d49 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -149,26 +149,27 @@ * If the screen stays white, disable 'LCD_RESET_PIN' * to let the bootloader init the screen. */ -#if EITHER(HAS_FSMC_GRAPHICAL_TFT, TFT_320x240) - #define FSMC_CS_PIN PD7 // NE4 - #define FSMC_RS_PIN PD11 // A0 +#if HAS_FSMC_TFT - #define TFT_CS_PIN FSMC_CS_PIN - #define TFT_RS_PIN FSMC_RS_PIN + #define TFT_CS_PIN PD7 // NE4 + #define TFT_RS_PIN PD11 // A0 + #define LCD_RESET_PIN PC6 // FSMC_RST + #define LCD_BACKLIGHT_PIN PD13 + + #define FSMC_CS_PIN TFT_CS_PIN // NE4 + #define FSMC_RS_PIN TFT_RS_PIN // A0 #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define LCD_RESET_PIN PC6 // FSMC_RST - #define LCD_BACKLIGHT_PIN PD13 -#endif + #if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PC2 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #endif -#if BOTH(NEED_TOUCH_PINS, HAS_FSMC_GRAPHICAL_TFT) || ENABLED(TFT_320x240) - #define TOUCH_CS_PIN PC2 // SPI2_NSS - #define TOUCH_SCK_PIN PB13 // SPI2_SCK - #define TOUCH_MISO_PIN PB14 // SPI2_MISO - #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI #endif #if ENABLED(TFT_320x240) // TFT32/28 diff --git a/buildroot/tests/mks_robin_nano_v1v2_maple b/buildroot/tests/mks_robin_nano_v1v2_maple index ebd5466ce61c..e241c14b9fe6 100755 --- a/buildroot/tests/mks_robin_nano_v1v2_maple +++ b/buildroot/tests/mks_robin_nano_v1v2_maple @@ -40,11 +40,10 @@ exec_test $1 $2 "MKS Robin v2 nano LVGL SPI w/ WiFi" "$3" # (Robin v2 nano has no FSMC interface) # use_example_configs Mks/Robin -opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 -opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240 -opt_enable TFT_INTERFACE_SPI TFT_RES_480x320 -opt_enable BINARY_FILE_TRANSFER -exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI + BINARY_FILE_TRANSFER" "$3" +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 TFT_ROTATION TFT_ROTATE_90 +opt_disable TFT_INTERFACE_FSMC +opt_enable TFT_INTERFACE_SPI BINARY_FILE_TRANSFER +exec_test $1 $2 "MKS Robin v2 nano New Color UI 240x320 SPI + BINARY_FILE_TRANSFER" "$3" # # MKS Robin v2 nano LVGL SPI + TMC