Skip to content

Commit

Permalink
✨ TFT 320x240 portrait (#25207)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
alexgrach and thinkyhead committed Apr 10, 2023
1 parent 6b48517 commit e5bdfe9
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 216 deletions.
84 changes: 58 additions & 26 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 @@ -1515,30 +1515,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 @@ -1563,8 +1539,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 @@ -1602,6 +1632,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
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

0 comments on commit e5bdfe9

Please sign in to comment.