Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

320x240 LCD portrait mode UI #25207

Merged
merged 12 commits into from
Jan 17, 2023
90 changes: 62 additions & 28 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1524,30 +1524,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
Expand All @@ -1572,8 +1548,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)
Expand Down Expand Up @@ -1610,9 +1640,13 @@
#define HAS_UI_1024x600 1
#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
#if ENABLED(TFT_COLOR_UI_PORTRAIT)
#define LCD_HEIGHT (9 - ENABLED(TOUCH_SCREEN)) // One less line with touch buttons onscreen
#else
#define LCD_HEIGHT (7 - ENABLED(TOUCH_SCREEN))
#endif
#elif HAS_UI_1024x600
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13) // Fewer lines with touch buttons onscreen
#define LCD_HEIGHT (13 - ENABLED(TOUCH_SCREEN))
#endif

// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/ia_creality/creality_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ namespace ExtUI {
DEBUG_ECHOLNPGM("Refresh");
injectCommands(F("M22\nM21"));
}
else if (recdat.data[0] == 0) { // return to main page
else if (recdat.data[0] == 0) { // return to main page
InforShowStatus = true;
TPShowStatus = false;
}
Expand Down
16 changes: 0 additions & 16 deletions Marlin/src/lcd/tft/tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/tft/tft_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ extern const uint8_t SYMBOLS_FONT_NAME[];
extern const uint8_t EXTRA_FONT_NAME[];
#endif


#endif // HAS_GRAPHICAL_TFT
20 changes: 9 additions & 11 deletions Marlin/src/lcd/tft/ui_1024x600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/tft/ui_1024x600.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading