Skip to content

Commit

Permalink
TFT Refactoring (#19192)
Browse files Browse the repository at this point in the history
* split tft folder in two: tft for color ui; tft_io for shared tft code

* after the files got moved, now the code was moved to the right place

* classic ui using TFT IO init lcd codes

* feature to compile tft_io when enabled

* compiling fix

* lvgl spi tft working with tft io init codes

* there is no need for separeted fsmc and spi class in lvgl anymore, as tft io handle everything

* remove debug

* base for TFT rotation and mirroring API, and ILI9488 support

* ST7796S rotate and mirror support

* ST7789V rotate and mirror support

* ST7735 rotate and mirror support

* ILI9341 rotate and mirror support

* ILI9328 rotate and mirror support

* R61505 rotate and mirror support

* MKS TFT definitions

* more configs for mks tfts

* update config

* naming typo

* to configure the user interface

* ANYCUBIC_TFT35

* tft configs

* support for SSD1963

* tft display types

* updated conditionals lcd; first board fully working with the new code - all 3 ui!

* compatiblity

* changed name

* move classic ui file name

* rename TURN -> ROTATE

* GRAPHICAL_TFT_ROTATE_180 deprecated

* first fsmc board fully working - chitu v5

* mks robin nano v1.2 + tft 35 ok!

* right pin name

* anycubic tft tested in a TRIGORILLA_PRO

* chitu v6

* nano 32 tft orientation

* mks tft43

* mks tft43 rotation

* fixed LONGER LK tft setup

* GRAPHICAL_TFT_UPSCALE defined by the display type

* better offsets defaults

* Update Configuration.h

* Update tft_fsmc.cpp

* Update Conditionals_LCD.h

* Tweak comments

* update nano tests

* Revert "update nano tests"

This reverts commit a071ebb.

* default tft

* outdated comments

* to not break non-vscode builds

* upscale tft 35

* support tft 180 rotation for color ui

* Each TFT Driver is responsible for its default color mode.

* use auto detect in mks displays, because some of them could be shipped with diferent drivers

* extra s

* unused code

* wrong -1

* missing mirror options

* Smaller regex pattern

* Comment updates

* Clean up old defines

* Apply pins formatting

* GRAPHICAL_TFT_ROTATE_180 => TFT_ROTATE_180

* MKS_ROBIN_TFT_V1_1R

* merge fix

* correct resolution

* auto is default, dont need be there, and it will allow the user to configure it even for named displays

* to not use rotation with MKS_ROBIN_TFT_V1_1R

* i like () in macros

* avoid sleepy commits

* default for st7789 is rgb

* nano follow up

* to allow ili9328 rotation

* default is rgb

* boards merge follow up

* to match bootloader orientation

* HAS_TOUCH_XPT2046 is not hal specific anymore

* lets not forget LPC

* 180 rotation for ili9328 and R61505

* Clean up whitespace

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
  • Loading branch information
3 people committed Apr 29, 2021
1 parent f163f19 commit 9b1ed45
Show file tree
Hide file tree
Showing 56 changed files with 1,000 additions and 1,476 deletions.
74 changes: 39 additions & 35 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2205,43 +2205,47 @@
//=============================== Graphical TFTs ==============================
//=============================================================================

//
// TFT display with optional touch screen
// Color Marlin UI with standard menu system
//
//#define TFT_320x240
//#define TFT_320x240_SPI
//#define TFT_480x320
//#define TFT_480x320_SPI

//
// Skip autodetect and force specific TFT driver
// Mandatory for SPI screens with no MISO line
// Available drivers are: ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
//
//#define TFT_DRIVER AUTO

//
// SPI display (MKS Robin Nano V2.0, MKS Gen L V2.0)
// Upscaled 128x64 Marlin UI
//
//#define SPI_GRAPHICAL_TFT
/**
* TFT Type - Select your Display type
*
* Available options are:
* MKS_TS35_V2_0,
* MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35,
* MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R
* TFT_TRONXY_X5SA, ANYCUBIC_TFT35, LONGER_LK_TFT28
* TFT_GENERIC
*
* For TFT_GENERIC, you need to configure these 3 options:
* Driver: TFT_DRIVER
* Current Drivers are: AUTO, ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
* Resolution: TFT_WIDTH and TFT_HEIGHT
* Interface: TFT_INTERFACE_FSMC or TFT_INTERFACE_SPI
*/
//#define TFT_GENERIC

//
// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
// Upscaled 128x64 Marlin UI
//
//#define FSMC_GRAPHICAL_TFT
/**
* TFT UI - User Interface Selection. Enable one of the following options:
*
* TFT_CLASSIC_UI - Emulated DOGM - 128x64 Upscaled
* TFT_COLOR_UI - Marlin Default Menus, Touch Friendly, using full TFT capabilities
* TFT_LVGL_UI - A Modern UI using LVGL
*
* For LVGL_UI also copy the 'assets' folder from the build directory to the
* root of your SD card, together with the compiled firmware.
*/
//#define TFT_CLASSIC_UI
//#define TFT_COLOR_UI
//#define TFT_LVGL_UI

//
// TFT LVGL UI
//
// Using default MKS icons and fonts from: https://git.io/JJvzK
// Just copy the 'assets' folder from the build directory to the
// root of your SD card, together with the compiled firmware.
//
//#define TFT_LVGL_UI_FSMC // Robin nano v1.2 uses FSMC
//#define TFT_LVGL_UI_SPI // Robin nano v2.0 uses SPI
/**
* TFT Rotation. Set to one of the following values:
*
* TFT_ROTATE_90, TFT_ROTATE_90_MIRROR_X, TFT_ROTATE_90_MIRROR_Y,
* TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y,
* TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
* TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
*/
//#define TFT_ROTATION TFT_NO_ROTATION

//=============================================================================
//============================ Other Controllers ============================
Expand Down
3 changes: 1 addition & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1560,10 +1560,9 @@
#endif

//
// FSMC / SPI Graphical TFT
// Classic UI Options
//
#if TFT_SCALED_DOGLCD
//#define GRAPHICAL_TFT_ROTATE_180
//#define TFT_MARLINUI_COLOR 0xFFFF // White
//#define TFT_MARLINBG_COLOR 0x0000 // Black
//#define TFT_DISABLED_COLOR 0x0003 // Almost black
Expand Down
7 changes: 0 additions & 7 deletions Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,3 @@
#if HAS_FSMC_TFT
#error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768."
#endif

// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
#undef TOUCH_SCREEN
#undef TOUCH_SCREEN_CALIBRATION
#define HAS_TOUCH_XPT2046 1
#endif
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/tft/tft_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#define DATASIZE_8BIT SSP_DATABIT_8
#define DATASIZE_16BIT SSP_DATABIT_16
#define TFT_IO TFT_SPI
#define TFT_IO_DRIVER TFT_SPI

#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/tft/tft_fsmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#define DATASIZE_8BIT SPI_DATASIZE_8BIT
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
#define TFT_IO TFT_FSMC
#define TFT_IO_DRIVER TFT_FSMC

#ifdef STM32F1xx
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/tft/tft_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#define DATASIZE_8BIT SPI_DATASIZE_8BIT
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
#define TFT_IO TFT_SPI
#define TFT_IO_DRIVER TFT_SPI

class TFT_SPI {
private:
Expand Down
7 changes: 0 additions & 7 deletions Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,3 @@
//#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
#undef SD_CHECK_AND_RETRY
#endif

// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
#undef TOUCH_SCREEN
#undef TOUCH_SCREEN_CALIBRATION
#define HAS_TOUCH_XPT2046 1
#endif
13 changes: 0 additions & 13 deletions Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,12 @@ void TFT_FSMC::Init() {
uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN;
uint32_t controllerAddress;

#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
#endif

#if ENABLED(LCD_USE_DMA_FSMC)
dma_init(FSMC_DMA_DEV);
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
#endif

#if PIN_EXISTS(TFT_RESET)
OUT_WRITE(TFT_RESET_PIN, HIGH);
delay(100);
#endif

#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif

struct fsmc_nor_psram_reg_map* fsmcPsramRegion;

if (fsmcInit) return;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/tft/tft_fsmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define DATASIZE_8BIT DMA_SIZE_8BITS
#define DATASIZE_16BIT DMA_SIZE_16BITS
#define TFT_IO TFT_FSMC
#define TFT_IO_DRIVER TFT_FSMC

typedef struct {
__IO uint16_t REG;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/tft/tft_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#define DATASIZE_8BIT DATA_SIZE_8BIT
#define DATASIZE_16BIT DATA_SIZE_16BIT
#define TFT_IO TFT_SPI
#define TFT_IO_DRIVER TFT_SPI

#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
#define _END_OF_ARGUMENTS_() 0


// Simple Inline IF Macros, friendly to use in other macro definitions
#define IF(O, A, B) ((O) ? (A) : (B))
#define IF_0(O, A) IF(O, A, 0)
#define IF_1(O, A) IF(O, A, 1)

//
// REPEAT core macros. Recurse N times with ascending I.
//
Expand Down
Loading

0 comments on commit 9b1ed45

Please sign in to comment.