TFT Refactoring (#19192)

* 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 a071ebbfad30e28855a4a5695ec8a726542a1a65.

* 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>
This commit is contained in:
Victor Oliveira 2020-10-12 18:38:07 -03:00 committed by GitHub
parent bcf65aa503
commit c0920bbf6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 1000 additions and 1476 deletions

View File

@ -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
/**
* 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
//
// 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
/**
* 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
//
// SPI display (MKS Robin Nano V2.0, MKS Gen L V2.0)
// Upscaled 128x64 Marlin UI
//
//#define SPI_GRAPHICAL_TFT
//
// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
// Upscaled 128x64 Marlin UI
//
//#define FSMC_GRAPHICAL_TFT
//
// 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 ============================

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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.
//

View File

@ -311,13 +311,40 @@
#define IS_ULTIPANEL
#endif
// Compatibility
#if ENABLED(FSMC_GRAPHICAL_TFT)
#define TFT_CLASSIC_UI
#define TFT_INTERFACE_FSMC
#define TFT_GENERIC
#elif ENABLED(SPI_GRAPHICAL_TFT)
#define TFT_CLASSIC_UI
#define TFT_INTERFACE_SPI
#define TFT_GENERIC
#elif EITHER(TFT_320x240, TFT_480x320)
#define TFT_COLOR_UI
#define TFT_INTERFACE_FSMC
#define TFT_GENERIC
#elif EITHER(TFT_320x240_SPI, TFT_480x320_SPI)
#define TFT_COLOR_UI
#define TFT_INTERFACE_SPI
#define TFT_GENERIC
#elif ENABLED(TFT_LVGL_UI_FSMC)
#define TFT_LVGL_UI
#define TFT_INTERFACE_FSMC
#define TFT_GENERIC
#elif ENABLED(TFT_LVGL_UI_SPI)
#define TFT_LVGL_UI
#define TFT_INTERFACE_SPI
#define TFT_GENERIC
#endif
// FSMC/SPI TFT Panels (LVGL)
#if EITHER(TFT_LVGL_UI_SPI, TFT_LVGL_UI_FSMC)
#if ENABLED(TFT_LVGL_UI)
#define HAS_TFT_LVGL_UI 1
#endif
// FSMC/SPI TFT Panels
#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT)
#if ENABLED(TFT_CLASSIC_UI)
#define TFT_SCALED_DOGLCD 1
#endif
@ -325,32 +352,16 @@
#define DOGLCD
#define IS_ULTIPANEL
#define DELAYED_BACKLIGHT_INIT
#elif ENABLED(TFT_LVGL_UI_SPI)
#elif ENABLED(TFT_LVGL_UI)
#define DELAYED_BACKLIGHT_INIT
#endif
// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h
#if ANY(TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC, FSMC_GRAPHICAL_TFT)
#define HAS_FSMC_TFT 1
#elif ANY(TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI, SPI_GRAPHICAL_TFT)
#define HAS_SPI_TFT 1
#endif
// Color UI
#if ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI)
#if ENABLED(TFT_COLOR_UI)
#define HAS_GRAPHICAL_TFT 1
#define IS_ULTIPANEL
#endif
// Fewer lines with touch buttons on-screen
#if EITHER(TFT_320x240, TFT_320x240_SPI)
#define HAS_UI_320x240 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#elif EITHER(TFT_480x320, TFT_480x320_SPI)
#define HAS_UI_480x320 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#endif
/**
* I2C Panels
*/
@ -810,3 +821,128 @@
#ifndef EXTRUDE_MINTEMP
#define EXTRUDE_MINTEMP 170
#endif
/**
* TFT Displays
*
* Configure parameters for TFT displays:
* - TFT_DEFAULT_ORIENTATION
* - TFT_DRIVER
* - TFT_WIDTH
* - TFT_HEIGHT
* - TFT_INTERFACE_(SPI|FSMC)
* - TFT_COLOR
* - GRAPHICAL_TFT_UPSCALE
*/
#if ENABLED(MKS_TS35_V2_0)
// Most common: ST7796
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
#define TFT_INTERFACE_SPI
#define GRAPHICAL_TFT_UPSCALE 3
#elif ENABLED(MKS_ROBIN_TFT24)
// Most common: ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif ENABLED(MKS_ROBIN_TFT28)
// Most common: ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif ENABLED(MKS_ROBIN_TFT32)
// Most common: ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif ENABLED(MKS_ROBIN_TFT35)
// Most common: ILI9488
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 3
#elif ENABLED(MKS_ROBIN_TFT43)
#define TFT_DEFAULT_ORIENTATION 0
#define TFT_DRIVER SSD1963
#define TFT_WIDTH 480
#define TFT_HEIGHT 272
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif ENABLED(MKS_ROBIN_TFT_V1_1R)
// ILI9328 or R61505
#define TFT_DEFAULT_ORIENTATION (TFT_INVERT_X | TFT_INVERT_Y | TFT_EXCHANGE_XY)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35)
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_DRIVER ILI9488
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 3
#elif ENABLED(LONGER_LK_TFT28)
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_INTERFACE_FSMC
#define GRAPHICAL_TFT_UPSCALE 2
#elif ENABLED(TFT_GENERIC)
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#endif
// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h
#if ENABLED(TFT_INTERFACE_FSMC)
#define HAS_FSMC_TFT 1
#if ENABLED(TFT_CLASSIC_UI)
#define FSMC_GRAPHICAL_TFT
#elif ENABLED(TFT_LVGL_UI)
#define TFT_LVGL_UI_FSMC
#endif
#elif ENABLED(TFT_INTERFACE_SPI)
#define HAS_SPI_TFT 1
#if ENABLED(TFT_CLASSIC_UI)
#define SPI_GRAPHICAL_TFT
#elif ENABLED(TFT_LVGL_UI)
#define TFT_LVGL_UI_SPI
#endif
#endif
#if ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 240
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_320x240_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_320x240
#endif
#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 320
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_480x320_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x320
#endif
#endif
// Fewer lines with touch buttons on-screen
#if EITHER(TFT_320x240, TFT_320x240_SPI)
#define HAS_UI_320x240 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#elif EITHER(TFT_480x320, TFT_480x320_SPI)
#define HAS_UI_480x320 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#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

View File

@ -447,8 +447,6 @@
#error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h."
#elif defined(MKS_ROBIN_TFT)
#error "MKS_ROBIN_TFT is now FSMC_GRAPHICAL_TFT. Please update your configuration."
#elif defined(TFT_LVGL_UI)
#error "TFT_LVGL_UI is now TFT_LVGL_UI_FSMC. Please update your configuration."
#elif defined(SDPOWER)
#error "SDPOWER is now SDPOWER_PIN. Please update your configuration and/or pins."
#elif defined(STRING_SPLASH_LINE1) || defined(STRING_SPLASH_LINE2)
@ -535,6 +533,8 @@
#error "ANYCUBIC_TFT_MODEL is now ANYCUBIC_LCD_I3MEGA. Please update your Configuration.h."
#elif defined(EVENT_GCODE_SD_STOP)
#error "EVENT_GCODE_SD_STOP is now EVENT_GCODE_SD_ABORT. Please update your Configuration.h."
#elif defined(GRAPHICAL_TFT_ROTATE_180)
#error "GRAPHICAL_TFT_ROTATE_180 is now TFT_ROTATION set to TFT_ROTATE_180. Please update your Configuration.h."
#elif defined(FIL_RUNOUT_INVERTING)
#if FIL_RUNOUT_INVERTING
#error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH. Please update your Configuration.h."

View File

@ -66,12 +66,7 @@
#define HAS_LCD_IO 1
#endif
#if ENABLED(SPI_GRAPHICAL_TFT)
#include HAL_PATH(../../HAL, tft/tft_spi.h)
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
#endif
#include "../tft_io/tft_io.h"
TFT_IO tftio;
#define WIDTH LCD_PIXEL_WIDTH
@ -132,299 +127,10 @@ TFT_IO tftio;
#define TFT_BTOKMENU_COLOR COLOR_RED
#endif
static uint32_t lcd_id = 0;
#define ST7789V_CASET 0x2A /* Column address register */
#define ST7789V_RASET 0x2B /* Row address register */
#define ST7789V_WRITE_RAM 0x2C /* Write data to GRAM */
/* Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X */
#define ILI9328_HASET 0x20 /* Horizontal GRAM address register (0-255) */
#define ILI9328_VASET 0x21 /* Vertical GRAM address register (0-511)*/
#define ILI9328_WRITE_RAM 0x22 /* Write data to GRAM */
#define ILI9328_HASTART 0x50 /* Horizontal address start position (0-255) */
#define ILI9328_HAEND 0x51 /* Horizontal address end position (0-255) */
#define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */
#define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */
static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
#if HAS_LCD_IO
tftio.DataTransferBegin(DATASIZE_8BIT);
#define IO_REG_DATA(R,D) do { tftio.WriteReg(R); tftio.WriteData(D); }while(0)
#else
#define IO_REG_DATA(R,D) do { u8g_WriteByte(u8g, dev, R); u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&D); }while(0)
#endif
#if NONE(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI)
u8g_SetAddress(u8g, dev, 0);
#endif
IO_REG_DATA(ILI9328_HASTART, Ymin);
IO_REG_DATA(ILI9328_HAEND, Ymax);
IO_REG_DATA(ILI9328_VASTART, Xmin);
IO_REG_DATA(ILI9328_VAEND, Xmax);
IO_REG_DATA(ILI9328_HASET, Ymin);
IO_REG_DATA(ILI9328_VASET, Xmin);
#if HAS_LCD_IO
tftio.WriteReg(ILI9328_WRITE_RAM);
tftio.DataTransferEnd();
#else
u8g_WriteByte(u8g, dev, ILI9328_WRITE_RAM);
u8g_SetAddress(u8g, dev, 1);
#endif
static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
tftio.set_window(Xmin, Ymin, Xmax, Ymax);
}
static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
#if HAS_LCD_IO
tftio.DataTransferBegin(DATASIZE_8BIT);
tftio.WriteReg(ST7789V_CASET);
tftio.WriteData((Xmin >> 8) & 0xFF);
tftio.WriteData(Xmin & 0xFF);
tftio.WriteData((Xmax >> 8) & 0xFF);
tftio.WriteData(Xmax & 0xFF);
tftio.WriteReg(ST7789V_RASET);
tftio.WriteData((Ymin >> 8) & 0xFF);
tftio.WriteData(Ymin & 0xFF);
tftio.WriteData((Ymax >> 8) & 0xFF);
tftio.WriteData(Ymax & 0xFF);
tftio.WriteReg(ST7789V_WRITE_RAM);
tftio.DataTransferEnd();
#else
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_CASET); u8g_SetAddress(u8g, dev, 1);
u8g_WriteByte(u8g, dev, (Xmin >> 8) & 0xFF);
u8g_WriteByte(u8g, dev, Xmin & 0xFF);
u8g_WriteByte(u8g, dev, (Xmax >> 8) & 0xFF);
u8g_WriteByte(u8g, dev, Xmax & 0xFF);
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_RASET); u8g_SetAddress(u8g, dev, 1);
u8g_WriteByte(u8g, dev, (Ymin >> 8) & 0xFF);
u8g_WriteByte(u8g, dev, Ymin & 0xFF);
u8g_WriteByte(u8g, dev, (Ymax >> 8) & 0xFF);
u8g_WriteByte(u8g, dev, Ymax & 0xFF);
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_WRITE_RAM); u8g_SetAddress(u8g, dev, 1);
#endif
}
static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {}
void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none;
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF
#define ESC_FFFF 0xFFFF, 0xFFFF
#if HAS_LCD_IO
void writeEscSequence(const uint16_t *sequence) {
uint16_t data;
for (;;) {
data = *sequence++;
if (data != 0xFFFF) {
tftio.WriteData(data);
continue;
}
data = *sequence++;
if (data == 0x7FFF) return;
if (data == 0xFFFF) {
tftio.WriteData(data);
} else if (data & 0x8000) {
delay(data & 0x7FFF);
} else if ((data & 0xFF00) == 0) {
tftio.WriteReg(data);
}
}
}
#define WRITE_ESC_SEQUENCE(V) writeEscSequence(V)
#define WRITE_ESC_SEQUENCE16(V) writeEscSequence(V)
#else
void writeEscSequence8(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) {
uint16_t data;
u8g_SetAddress(u8g, dev, 1);
for (;;) {
data = *sequence++;
if (data != 0xFFFF) {
u8g_WriteByte(u8g, dev, data & 0xFF);
continue;
}
data = *sequence++;
if (data == 0x7FFF) return;
if (data == 0xFFFF) {
u8g_WriteByte(u8g, dev, data & 0xFF);
} else if (data & 0x8000) {
delay(data & 0x7FFF);
} else if ((data & 0xFF00) == 0) {
u8g_SetAddress(u8g, dev, 0);
u8g_WriteByte(u8g, dev, data & 0xFF);
u8g_SetAddress(u8g, dev, 1);
}
}
}
#define WRITE_ESC_SEQUENCE(V) writeEscSequence8(u8g, dev, V)
void writeEscSequence16(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) {
uint16_t data;
u8g_SetAddress(u8g, dev, 0);
for (;;) {
data = *sequence++;
if (data != 0xFFFF) {
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data);
continue;
}
data = *sequence++;
if (data == 0x7FFF) return;
if (data == 0xFFFF) {
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data);
} else if (data & 0x8000) {
delay(data & 0x7FFF);
} else if ((data & 0xFF00) == 0) {
u8g_WriteByte(u8g, dev, data & 0xFF);
}
}
u8g_SetAddress(u8g, dev, 1);
}
#define WRITE_ESC_SEQUENCE16(V) writeEscSequence16(u8g, dev, V)
#endif
static const uint16_t st7789v_init[] = {
ESC_REG(0x0010), ESC_DELAY(10),
ESC_REG(0x0001), ESC_DELAY(200),
ESC_REG(0x0011), ESC_DELAY(120),
ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0060, 0x00A0),
ESC_REG(0x003A), 0x0055,
ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F,
ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF,
ESC_REG(0x00B2), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033,
ESC_REG(0x00B7), 0x0035,
ESC_REG(0x00BB), 0x001F,
ESC_REG(0x00C0), 0x002C,
ESC_REG(0x00C2), 0x0001, 0x00C3,
ESC_REG(0x00C4), 0x0020,
ESC_REG(0x00C6), 0x000F,
ESC_REG(0x00D0), 0x00A4, 0x00A1,
ESC_REG(0x0029),
ESC_REG(0x0011),
ESC_END
};
static const uint16_t ili9328_init[] = {
ESC_REG(0x0001), 0x0100,
ESC_REG(0x0002), 0x0400,
ESC_REG(0x0003), 0x1038,
ESC_REG(0x0004), 0x0000,
ESC_REG(0x0008), 0x0202,
ESC_REG(0x0009), 0x0000,
ESC_REG(0x000A), 0x0000,
ESC_REG(0x000C), 0x0000,
ESC_REG(0x000D), 0x0000,
ESC_REG(0x000F), 0x0000,
ESC_REG(0x0010), 0x0000,
ESC_REG(0x0011), 0x0007,
ESC_REG(0x0012), 0x0000,
ESC_REG(0x0013), 0x0000,
ESC_REG(0x0007), 0x0001,
ESC_DELAY(200),
ESC_REG(0x0010), 0x1690,
ESC_REG(0x0011), 0x0227,
ESC_DELAY(50),
ESC_REG(0x0012), 0x008C,
ESC_DELAY(50),
ESC_REG(0x0013), 0x1500,
ESC_REG(0x0029), 0x0004,
ESC_REG(0x002B), 0x000D,
ESC_DELAY(50),
ESC_REG(0x0050), 0x0000,
ESC_REG(0x0051), 0x00EF,
ESC_REG(0x0052), 0x0000,
ESC_REG(0x0053), 0x013F,
ESC_REG(0x0020), 0x0000,
ESC_REG(0x0021), 0x0000,
ESC_REG(0x0060), 0x2700,
ESC_REG(0x0061), 0x0001,
ESC_REG(0x006A), 0x0000,
ESC_REG(0x0080), 0x0000,
ESC_REG(0x0081), 0x0000,
ESC_REG(0x0082), 0x0000,
ESC_REG(0x0083), 0x0000,
ESC_REG(0x0084), 0x0000,
ESC_REG(0x0085), 0x0000,
ESC_REG(0x0090), 0x0010,
ESC_REG(0x0092), 0x0600,
ESC_REG(0x0007), 0x0133,
ESC_REG(0x0022),
ESC_END
};
static const uint16_t ili9341_init[] = {
ESC_REG(0x0010), ESC_DELAY(10),
ESC_REG(0x0001), ESC_DELAY(200),
ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0028, 0x00E8),
ESC_REG(0x003A), 0x0055,
ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F,
ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF,
ESC_REG(0x00C5), 0x003E, 0x0028,
ESC_REG(0x00C7), 0x0086,
ESC_REG(0x00B1), 0x0000, 0x0018,
ESC_REG(0x00C0), 0x0023,
ESC_REG(0x00C1), 0x0010,
ESC_REG(0x0029),
ESC_REG(0x0011),
ESC_DELAY(100),
ESC_END
};
static const uint16_t ili9488_init[] = {
ESC_REG(0x00E0), 0x0000, 0x0007, 0x000F, 0x000D, 0x001B, 0x000A, 0x003C, 0x0078, 0x004A, 0x0007, 0x000E, 0x0009, 0x001B, 0x001E, 0x000F,
ESC_REG(0x00E1), 0x0000, 0x0022, 0x0024, 0x0006, 0x0012, 0x0007, 0x0036, 0x0047, 0x0047, 0x0006, 0x000A, 0x0007, 0x0030, 0x0037, 0x000F,
ESC_REG(0x00C0), 0x0010, 0x0010,
ESC_REG(0x00C1), 0x0041,
ESC_REG(0x00C5), 0x0000, 0x0022, 0x0080,
ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00A8, 0x0068),
ESC_REG(0x003A), 0x0055,
ESC_REG(0x00B0), 0x0000,
ESC_REG(0x00B1), 0x00B0, 0x0011,
ESC_REG(0x00B4), 0x0002,
ESC_REG(0x00B6), 0x0002, 0x0042,
ESC_REG(0x00B7), 0x00C6,
ESC_REG(0x00E9), 0x0000,
ESC_REG(0x00F0), 0x00A9, 0x0051, 0x002C, 0x0082,
ESC_REG(0x0029),
ESC_REG(0x0011),
ESC_DELAY(100),
ESC_END
};
static const uint16_t st7796_init[] = {
ESC_REG(0x0010), ESC_DELAY(120),
ESC_REG(0x0001), ESC_DELAY(120),
ESC_REG(0x0011), ESC_DELAY(120),
ESC_REG(0x00F0), 0x00C3,
ESC_REG(0x00F0), 0x0096,
ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00E8, 0x0028),
ESC_REG(0x003A), 0x0055,
ESC_REG(0x00B4), 0x0001,
ESC_REG(0x00B7), 0x00C6,
ESC_REG(0x00E8), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,
ESC_REG(0x00C1), 0x0006,
ESC_REG(0x00C2), 0x00A7,
ESC_REG(0x00C5), 0x0018,
ESC_REG(0x00E0), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0015, 0x002F, 0x0054, 0x0042, 0x003C, 0x0017, 0x0014, 0x0018, 0x001B,
ESC_REG(0x00E1), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0003, 0x002D, 0x0043, 0x0042, 0x003B, 0x0016, 0x0014, 0x0017, 0x001B,
ESC_REG(0x00F0), 0x003C,
ESC_REG(0x00F0), 0x0069, ESC_DELAY(120),
ESC_REG(0x0029),
ESC_REG(0x0011),
ESC_DELAY(100),
ESC_END
};
#if HAS_TOUCH_XPT2046
static const uint8_t buttonD[] = {
@ -640,43 +346,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
switch (msg) {
case U8G_DEV_MSG_INIT:
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, &lcd_id);
tftio.DataTransferBegin(DATASIZE_8BIT);
switch (lcd_id & 0xFFFF) {
case 0x8552: // ST7789V
WRITE_ESC_SEQUENCE(st7789v_init);
setWindow = setWindow_st7789v;
break;
case 0x9328: // ILI9328
WRITE_ESC_SEQUENCE16(ili9328_init);
setWindow = setWindow_ili9328;
break;
case 0x9341: // ILI9341
WRITE_ESC_SEQUENCE(ili9341_init);
setWindow = setWindow_st7789v;
break;
case 0x8066: // Anycubic / TronXY TFTs (480x320)
WRITE_ESC_SEQUENCE(ili9488_init);
setWindow = setWindow_st7789v;
break;
case 0x7796:
WRITE_ESC_SEQUENCE(st7796_init);
setWindow = setWindow_st7789v;
break;
case 0x9488:
WRITE_ESC_SEQUENCE(ili9488_init);
setWindow = setWindow_st7789v;
case 0x0404: // No connected display on FSMC
lcd_id = 0;
return 0;
case 0xFFFF: // No connected display on SPI
lcd_id = 0;
return 0;
default:
setWindow = (lcd_id & 0xFF000000) ? setWindow_st7789v : setWindow_ili9328;
break;
}
tftio.DataTransferEnd();
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, NULL);
tftio.Init();
tftio.InitTFT();
if (preinit) {
preinit = false;
@ -771,14 +443,7 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p
case U8G_COM_MSG_STOP: break;
case U8G_COM_MSG_INIT:
u8g_SetPIOutput(u8g, U8G_PI_RESET);
u8g_Delay(50);
tftio.Init();
if (arg_ptr) {
*((uint32_t *)arg_ptr) = tftio.GetID();
}
isCommand = 0;
break;

View File

@ -22,7 +22,7 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(TFT_LVGL_UI_SPI)
#if HAS_TFT_LVGL_UI
#include "SPI_TFT.h"
#include "pic_manager.h"
@ -32,6 +32,8 @@
#include <SPI.h>
#include "draw_ui.h"
TFT SPI_TFT;
// use SPI1 for the spi tft.
@ -39,142 +41,48 @@ void TFT::spi_init(uint8_t spiRate) {
tftio.Init();
}
void TFT::LCD_WR_REG(uint8_t cmd) {
tftio.WriteReg(cmd);
}
void TFT::LCD_WR_DATA(uint8_t data) {
tftio.WriteData(data);
}
void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) {
if ((x > 480) || (y > 320)) return;
SetWindows(x, y, 1, 1);
setWindow(x, y, 1, 1);
tftio.WriteMultiple(point, (uint16_t)1);
}
void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
tftio.DataTransferBegin(DATASIZE_8BIT);
LCD_WR_REG(0x2A);
LCD_WR_DATA(x >> 8);
LCD_WR_DATA(x);
LCD_WR_DATA((x + with - 1) >> 8);
LCD_WR_DATA((x + with - 1));
LCD_WR_REG(0x2B);
LCD_WR_DATA(y >> 8);
LCD_WR_DATA(y);
LCD_WR_DATA((y + height - 1) >> 8);
LCD_WR_DATA(y + height - 1);
LCD_WR_REG(0X2C);
tftio.DataTransferEnd();
void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
tftio.set_window(x, y, (x + with - 1), (y + height - 1));
}
void TFT::LCD_init() {
TFT_BLK_L;
TFT_RST_H;
delay(150);
TFT_RST_L;
delay(150);
TFT_RST_H;
tftio.DataTransferBegin(DATASIZE_8BIT);
delay(120);
LCD_WR_REG(0x11);
delay(120);
LCD_WR_REG(0xF0);
LCD_WR_DATA(0xC3);
LCD_WR_REG(0xF0);
LCD_WR_DATA(0x96);
LCD_WR_REG(0x36);
LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80));
LCD_WR_REG(0x3A);
LCD_WR_DATA(0x55);
LCD_WR_REG(0xB4);
LCD_WR_DATA(0x01);
LCD_WR_REG(0xB7);
LCD_WR_DATA(0xC6);
LCD_WR_REG(0xE8);
LCD_WR_DATA(0x40);
LCD_WR_DATA(0x8A);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x29);
LCD_WR_DATA(0x19);
LCD_WR_DATA(0xA5);
LCD_WR_DATA(0x33);
LCD_WR_REG(0xC1);
LCD_WR_DATA(0x06);
LCD_WR_REG(0xC2);
LCD_WR_DATA(0xA7);
LCD_WR_REG(0xC5);
LCD_WR_DATA(0x18);
LCD_WR_REG(0xE0); // Positive Voltage Gamma Control
LCD_WR_DATA(0xF0);
LCD_WR_DATA(0x09);
LCD_WR_DATA(0x0B);
LCD_WR_DATA(0x06);
LCD_WR_DATA(0x04);
LCD_WR_DATA(0x15);
LCD_WR_DATA(0x2F);
LCD_WR_DATA(0x54);
LCD_WR_DATA(0x42);
LCD_WR_DATA(0x3C);
LCD_WR_DATA(0x17);
LCD_WR_DATA(0x14);
LCD_WR_DATA(0x18);
LCD_WR_DATA(0x1B);
LCD_WR_REG(0xE1); // Negative Voltage Gamma Control
LCD_WR_DATA(0xF0);
LCD_WR_DATA(0x09);
LCD_WR_DATA(0x0B);
LCD_WR_DATA(0x06);
LCD_WR_DATA(0x04);
LCD_WR_DATA(0x03);
LCD_WR_DATA(0x2D);
LCD_WR_DATA(0x43);
LCD_WR_DATA(0x42);
LCD_WR_DATA(0x3B);
LCD_WR_DATA(0x16);
LCD_WR_DATA(0x14);
LCD_WR_DATA(0x17);
LCD_WR_DATA(0x1B);
LCD_WR_REG(0xF0);
LCD_WR_DATA(0x3C);
LCD_WR_REG(0xF0);
LCD_WR_DATA(0x69);
delay(120); // Delay 120ms
LCD_WR_REG(0x29); // Display ON
tftio.DataTransferEnd();
LCD_clear(0x0000); //
tftio.InitTFT();
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
#endif
delay(100);
LCD_clear(0x0000);
LCD_Draw_Logo();
TFT_BLK_H;
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif
#if HAS_LOGO_IN_FLASH
delay(2000);
#endif
}
void TFT::LCD_clear(uint16_t color) {
SetWindows(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
setWindow(0, 0, (TFT_WIDTH), (TFT_HEIGHT));
tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
}
extern unsigned char bmp_public_buf[17 * 1024];
void TFT::LCD_Draw_Logo() {
SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT);
#if HAS_LOGO_IN_FLASH
setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
}
#endif
}
#endif // HAS_TFT_LVGL_UI_SPI
#endif // HAS_TFT_LVGL_UI

View File

@ -23,29 +23,21 @@
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(TFT_LVGL_UI_SPI)
#include HAL_PATH(../../HAL, tft/tft_spi.h)
#elif ENABLED(TFT_LVGL_UI_FSMC)
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
#endif
#if HAS_TFT_LVGL_UI
#define TFT_RST_H OUT_WRITE(TFT_RESET_PIN, HIGH)
#define TFT_RST_L OUT_WRITE(TFT_RESET_PIN, LOW)
#define TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH)
#define TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW)
#include "../../../tft_io/tft_io.h"
class TFT {
public:
TFT_IO tftio;
void spi_init(uint8_t spiRate);
void LCD_WR_REG(uint8_t cmd);
void LCD_WR_DATA(uint8_t data);
void SetPoint(uint16_t x, uint16_t y, uint16_t point);
void SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height);
void setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height);
void LCD_init();
void LCD_clear(uint16_t color);
void LCD_Draw_Logo();
};
extern TFT SPI_TFT;
#endif // HAS_TFT_LVGL_UI

View File

@ -23,9 +23,7 @@
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI_SPI)
#include "SPI_TFT.h"
#endif
#include "lv_conf.h"
#include "draw_ui.h"
@ -77,7 +75,7 @@ void lv_draw_error_message(PGM_P const msg) {
lv_task_handler();
#endif
TERN(TFT_LVGL_UI_SPI, SPI_TFT.LCD_clear, LCD_Clear)(0x0000);
SPI_TFT.LCD_clear(0x0000);
if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000);
disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000);
disp_string((TFT_WIDTH - strlen("Please Reset") * 16) / 2, 180, "Please Reset", 0xFFFF, 0x0000);

View File

@ -23,9 +23,7 @@
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI_SPI)
#include "SPI_TFT.h"
#endif
#include "tft_lvgl_configuration.h"
@ -165,7 +163,7 @@ void gCfgItems_init() {
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100);
}
const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE);
const byte rot = (TFT_ROTATION & TFT_ROTATE_180) ? 0xEE : 0x00;
if (gCfgItems.disp_rotation_180 != rot) {
gCfgItems.disp_rotation_180 = rot;
update_spi_flash();
@ -655,12 +653,7 @@ char *creat_title_text() {
}
card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
#else
LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_WriteRAM_Prepare();
#endif
SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
j = i = 0;
@ -673,20 +666,11 @@ char *creat_title_text() {
}
if (j >= 400) break;
}
#if ENABLED(TFT_LVGL_UI_SPI)
for (i = 0; i < 400; i += 2) {
p_index = (uint16_t *)(&bmp_public_buf[i]);
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
}
SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
#else
for (i = 0; i < 400;) {
p_index = (uint16_t *)(&bmp_public_buf[i]);
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
LCD_IO_WriteData(*p_index);
i += 2;
}
#endif
#if HAS_BAK_VIEW_IN_FLASH
W25QXX.init(SPI_QUARTER_SPEED);
if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
@ -768,7 +752,7 @@ char *creat_title_text() {
card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
#else
LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_WriteRAM_Prepare();
@ -901,34 +885,9 @@ char *creat_title_text() {
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
#endif
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
SPI_TFT.setWindow(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20);
#else
int x_off = 0;
uint16_t temp_p;
int i = 0;
uint16_t *p_index;
LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
LCD_WriteRAM_Prepare();
for (int _y = y_off * 20; _y < (y_off + 1) * 20; _y++) {
for (x_off = 0; x_off < 200; x_off++) {
if (sel == 1) {
temp_p = (uint16_t)(bmp_public_buf[i] | bmp_public_buf[i + 1] << 8);
p_index = &temp_p;
}
else {
p_index = (uint16_t *)(&bmp_public_buf[i]);
}
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
LCD_IO_WriteData(*p_index);
i += 2;
}
if (i >= 8000) break;
}
#endif // TFT_LVGL_UI_SPI
y_off++;
}
W25QXX.init(SPI_QUARTER_SPEED);

View File

@ -23,9 +23,7 @@
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI_SPI)
#include "SPI_TFT.h"
#endif
#include "tft_lvgl_configuration.h"
#include "draw_ready_print.h"
@ -626,10 +624,8 @@ static const uint16_t ASCII_Table_16x24[] PROGMEM = {
void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor) {
for (uint16_t i = 0; i < 24; i++) {
const uint16_t tmp_char = pgm_read_word(&ASCII_Table_16x24[((c - 0x20) * 24) + i]);
for (uint16_t j = 0; j < 16; j++) {
TERN(TFT_LVGL_UI_SPI, SPI_TFT.SetPoint, tft_set_point)
(x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor);
}
for (uint16_t j = 0; j < 16; j++)
SPI_TFT.SetPoint(x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor);
}
}
@ -643,7 +639,7 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor
//static lv_obj_t * scr_test;
void disp_assets_update() {
TERN(TFT_LVGL_UI_SPI,, LCD_Clear(0x0000));
SPI_TFT.LCD_clear(0x0000);
disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000);
}

View File

@ -1,60 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfig.h"
#if ENABLED(TFT_LVGL_UI_FSMC)
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
TFT_IO tftio;
void LCD_IO_Init(uint8_t cs, uint8_t rs);
void LCD_IO_WriteData(uint16_t RegValue);
void LCD_IO_WriteReg(uint16_t Reg);
#ifdef LCD_USE_DMA_FSMC
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
#endif
void LCD_IO_Init(uint8_t cs, uint8_t rs) {
tftio.Init();
}
void LCD_IO_WriteData(uint16_t RegValue) {
tftio.WriteData(RegValue);
}
void LCD_IO_WriteReg(uint16_t Reg) {
tftio.WriteReg(Reg);
}
#ifdef LCD_USE_DMA_FSMC
void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
tftio.WriteMultiple(color, count);
}
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) {
tftio.WriteSequence(data, length);
}
#endif // LCD_USE_DMA_FSMC
#endif // HAS_TFT_LVGL_UI

View File

@ -1,30 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

View File

@ -29,9 +29,7 @@
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI_SPI)
#include "SPI_TFT.h"
#endif
#include "tft_lvgl_configuration.h"
#include "draw_ready_print.h"
@ -74,24 +72,6 @@ lv_group_t* g;
uint16_t DeviceCode = 0x9488;
extern uint8_t sel_id;
#define SetCs
#define ClrCs
#define HDP 799 // Horizontal Display Period
#define HT 1000 // Horizontal Total
#define HPS 51 // LLINE Pulse Start Position
#define LPS 3 // Horizontal Display Period Start Position
#define HPW 8 // LLINE Pulse Width
#define VDP 479 // Vertical Display Period
#define VT 530 // Vertical Total
#define VPS 24 // LFRAME Pulse Start Position
#define FPS 23 // Vertical Display Period Start Positio
#define VPW 3 // LFRAME Pulse Width
#define MAX_HZ_POSX HDP+1
#define MAX_HZ_POSY VDP+1
extern uint8_t gcode_preview_over, flash_preview_begin, default_preview_flg;
uint8_t bmp_public_buf[17 * 1024];
@ -125,317 +105,7 @@ void SysTick_Callback() {
}
}
#if DISABLED(TFT_LVGL_UI_SPI)
extern void LCD_IO_Init(uint8_t cs, uint8_t rs);
extern void LCD_IO_WriteData(uint16_t RegValue);
extern void LCD_IO_WriteReg(uint16_t Reg);
extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count);
void tft_set_cursor(uint16_t x, uint16_t y) {
LCD_IO_WriteReg(0x002A);
LCD_IO_WriteData(x >> 8);
LCD_IO_WriteData(x & 0x00FF);
LCD_IO_WriteData(x >> 8);
LCD_IO_WriteData(x & 0x00FF);
//ILI9488_WriteData(0x01);
//ILI9488_WriteData(0xDF);
LCD_IO_WriteReg(0x002B);
LCD_IO_WriteData(y >> 8);
LCD_IO_WriteData(y & 0x00FF);
LCD_IO_WriteData(y >> 8);
LCD_IO_WriteData(y & 0x00FF);
//ILI9488_WriteData(0x01);
//ILI9488_WriteData(0x3F);
}
void LCD_WriteRAM_Prepare(void) {
#if 0
switch (DeviceCode) {
case 0x9325: case 0x9328: case 0x8989: {
ClrCs
LCD->LCD_REG = R34;
SetCs
} break;
default: LCD_WrtReg(0x002C);
}
#else
LCD_IO_WriteReg(0x002C);
#endif
}
void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
//if (DeviceCode == 0x9488) {
if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return;
//}
tft_set_cursor(x, y);
LCD_WriteRAM_Prepare();
//LCD_WriteRAM(point);
LCD_IO_WriteData(point);
}
void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue) {
/* Write 16-bit Index, then Write Reg */
ClrCs
LCD_IO_WriteReg(LCD_Reg);
/* Write 16-bit Reg */
LCD_IO_WriteData(LCD_RegValue);
SetCs
}
void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh) {
uint16_t s_h, s_l, e_h, e_l;
uint16_t xEnd, yEnd;
xEnd = StartX + width;
yEnd = StartY + heigh - 1;
if (DeviceCode == 0x8989) {
/*LCD_WriteReg(0x0044, (StartX & 0xFF) | (xEnd << 8));
LCD_WriteReg(0x0045, StartY);
LCD_WriteReg(0x0046, yEnd);*/
LCD_WriteReg(0x0044, (StartY & 0xFF) | (yEnd << 8));
LCD_WriteReg(0x0045, StartX);
LCD_WriteReg(0x0046, xEnd);
}
else if (DeviceCode == 0x9488) {
s_h = (StartX >> 8) & 0x00FF;
s_l = StartX & 0x00FF;
e_h = ((StartX + width - 1) >> 8) & 0x00FF;
e_l = (StartX + width - 1) & 0x00FF;
LCD_IO_WriteReg(0x002A);
LCD_IO_WriteData(s_h);
LCD_IO_WriteData(s_l);
LCD_IO_WriteData(e_h);
LCD_IO_WriteData(e_l);
s_h = (StartY >> 8) & 0x00FF;
s_l = StartY & 0x00FF;
e_h = ((StartY + heigh - 1) >> 8) & 0x00FF;
e_l = (StartY + heigh - 1) & 0x00FF;
LCD_IO_WriteReg(0x002B);
LCD_IO_WriteData(s_h);
LCD_IO_WriteData(s_l);
LCD_IO_WriteData(e_h);
LCD_IO_WriteData(e_l);
}
else if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x1505)) {
/* LCD_WriteReg(0x0050, StartX);
LCD_WriteReg(0x0052, StartY);
LCD_WriteReg(0x0051, xEnd);
LCD_WriteReg(0x0053, yEnd);*/
LCD_WriteReg(0x0050, StartY); // Specify the start/end positions of the window address in the horizontal direction by an address unit
LCD_WriteReg(0x0051, yEnd); // Specify the start positions of the window address in the vertical direction by an address unit
LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd);
LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit
}
else {
s_h = (StartX >> 8) & 0xFF;
s_l = StartX & 0xFF;
e_h = ((StartX + width - 1) >> 8) & 0xFF;
e_l = (StartX + width - 1) & 0xFF;
LCD_IO_WriteReg(0x2A);
LCD_IO_WriteData(s_h);
LCD_IO_WriteData(s_l);
LCD_IO_WriteData(e_h);
LCD_IO_WriteData(e_l);
s_h = (StartY >> 8) & 0xFF;
s_l = StartY & 0xFF;
e_h = ((StartY + heigh - 1) >> 8) & 0xFF;
e_l = (StartY + heigh - 1) & 0xFF;
LCD_IO_WriteReg(0x2B);
LCD_IO_WriteData(s_h);
LCD_IO_WriteData(s_l);
LCD_IO_WriteData(e_h);
LCD_IO_WriteData(e_l);
}
}
void LCD_Clear(uint16_t Color) {
uint32_t index = 0;
unsigned int count;
if (DeviceCode == 0x9488) {
tft_set_cursor(0, 0);
LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
LCD_WriteRAM_Prepare();
#ifdef LCD_USE_DMA_FSMC
LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
#else
//index = (TFT_HEIGHT) / 2 * (TFT_WIDTH);
for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++)
LCD_IO_WriteData(Color);
#endif
//LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
//while(index --) LCD_IO_WriteData(Color);
}
else if (DeviceCode == 0x5761) {
LCD_IO_WriteReg(0x002A);
LCD_IO_WriteData(0);
LCD_IO_WriteData(0);
LCD_IO_WriteData(HDP >> 8);
LCD_IO_WriteData(HDP & 0x00FF);
LCD_IO_WriteReg(0x002B);
LCD_IO_WriteData(0);
LCD_IO_WriteData(0);
LCD_IO_WriteData(VDP >> 8);
LCD_IO_WriteData(VDP & 0x00FF);
LCD_IO_WriteReg(0x002C);
LCD_IO_WriteReg(0x002C);
for (count = 0; count < (HDP + 1) * (VDP + 1); count++)
LCD_IO_WriteData(Color);
}
else {
tft_set_cursor(0, 0);
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
for (index = 0; index < 76800; index++)
LCD_IO_WriteData(Color);
}
}
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
extern TFT_IO tftio;
void fsmc_tft_init() {
uint16_t i;
TERN_(HAS_LCD_CONTRAST, refresh_contrast());
#ifdef 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
LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN);
_delay_ms(5);
DeviceCode = tftio.GetID() & 0xFFFF;
// Chitu and others
if (DeviceCode == 0x8066) DeviceCode = 0x9488;
if (DeviceCode == 0x9488) {
LCD_IO_WriteReg(0x00E0);
LCD_IO_WriteData(0x0000);
LCD_IO_WriteData(0x0007);
LCD_IO_WriteData(0x000F);
LCD_IO_WriteData(0x000D);
LCD_IO_WriteData(0x001B);
LCD_IO_WriteData(0x000A);
LCD_IO_WriteData(0x003C);
LCD_IO_WriteData(0x0078);
LCD_IO_WriteData(0x004A);
LCD_IO_WriteData(0x0007);
LCD_IO_WriteData(0x000E);
LCD_IO_WriteData(0x0009);
LCD_IO_WriteData(0x001B);
LCD_IO_WriteData(0x001E);
LCD_IO_WriteData(0x000F);
LCD_IO_WriteReg(0x00E1);
LCD_IO_WriteData(0x0000);
LCD_IO_WriteData(0x0022);
LCD_IO_WriteData(0x0024);
LCD_IO_WriteData(0x0006);
LCD_IO_WriteData(0x0012);
LCD_IO_WriteData(0x0007);
LCD_IO_WriteData(0x0036);
LCD_IO_WriteData(0x0047);
LCD_IO_WriteData(0x0047);
LCD_IO_WriteData(0x0006);
LCD_IO_WriteData(0x000A);
LCD_IO_WriteData(0x0007);
LCD_IO_WriteData(0x0030);
LCD_IO_WriteData(0x0037);
LCD_IO_WriteData(0x000F);
LCD_IO_WriteReg(0x00C0);
LCD_IO_WriteData(0x0010);
LCD_IO_WriteData(0x0010);
LCD_IO_WriteReg(0x00C1);
LCD_IO_WriteData(0x0041);
LCD_IO_WriteReg(0x00C5);
LCD_IO_WriteData(0x0000);
LCD_IO_WriteData(0x0022);
LCD_IO_WriteData(0x0080);
LCD_IO_WriteReg(0x0036);
LCD_IO_WriteData(TERN(GRAPHICAL_TFT_ROTATE_180, 0xE8, 0x0068));
LCD_IO_WriteReg(0x003A); //Interface Mode Control
LCD_IO_WriteData(0x0055);
LCD_IO_WriteReg(0x00B0); //Interface Mode Control
LCD_IO_WriteData(0x0000);
LCD_IO_WriteReg(0x00B1); //Frame rate 70HZ
LCD_IO_WriteData(0x00B0);
LCD_IO_WriteData(0x0011);
LCD_IO_WriteReg(0x00B4);
LCD_IO_WriteData(0x0002);
LCD_IO_WriteReg(0x00B6); //RGB/MCU Interface Control
LCD_IO_WriteData(0x0002);
LCD_IO_WriteData(0x0042);
LCD_IO_WriteReg(0x00B7);
LCD_IO_WriteData(0x00C6);
//WriteComm(0xBE);
//WriteData(0x00);
//WriteData(0x04);
LCD_IO_WriteReg(0x00E9);
LCD_IO_WriteData(0x0000);
LCD_IO_WriteReg(0x00F7);
LCD_IO_WriteData(0x00A9);
LCD_IO_WriteData(0x0051);
LCD_IO_WriteData(0x002C);
LCD_IO_WriteData(0x0082);
LCD_IO_WriteReg(0x0011);
for (i = 0; i < 65535; i++) { /* do nothing */ }
LCD_IO_WriteReg(0x0029);
LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
OUT_WRITE(LCD_BACKLIGHT_PIN, LOW);
LCD_Clear(0x0000);
TERN_(HAS_LOGO_IN_FLASH, lcd_draw_logo());
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
delay(2000);
}
}
extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
void lcd_draw_logo() {
LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
LCD_WriteRAM_Prepare();
for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
#ifdef LCD_USE_DMA_FSMC
LCD_IO_WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
#else
int index = 0;,x_off = 0;
for (x_off = 0; x_off < TFT_WIDTH; x_off++) {
LCD_IO_WriteData((uint16_t)bmp_public_buf[index]);
index += 2;
}
#endif
}
}
#endif // !TFT_LVGL_UI_SPI
extern uint8_t bmp_public_buf[17 * 1024];
void tft_lvgl_init() {
@ -448,12 +118,8 @@ void tft_lvgl_init() {
disp_language_init();
//init tft first!
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.spi_init(SPI_FULL_SPEED);
SPI_TFT.LCD_init();
#else
fsmc_tft_init();
#endif
//spi_flash_read_test();
#if ENABLED(SDSUPPORT)
@ -548,41 +214,18 @@ void tft_lvgl_init() {
}
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
#if ENABLED(TFT_LVGL_UI_SPI)
uint16_t i, width, height;
width = area->x2 - area->x1 + 1;
height = area->y2 - area->y1 + 1;
SPI_TFT.SetWindows((uint16_t)area->x1, (uint16_t)area->y1, width, height);
SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
for (i = 0; i < height; i++) {
SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
}
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
W25QXX.init(SPI_QUARTER_SPEED);
#else // !TFT_LVGL_UI_SPI
#if 1
uint16_t i, width, height;
//uint16_t clr_temp;
width = area->x2 - area->x1 + 1;
height = area->y2 - area->y1 + 1;
LCD_setWindowArea((uint16_t)area->x1, (uint16_t)area->y1, width, height);
LCD_WriteRAM_Prepare();
for (i = 0; i < width * height - 2; i++) {
//clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11)
//| ((uint16_t)color_p->ch.green << 5)
//| ((uint16_t)color_p->ch.blue));
LCD_IO_WriteData(color_p->full);
color_p++;
}
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
#endif
#endif // !TFT_LVGL_UI_SPI
}
#define TICK_CYCLE 1
@ -599,7 +242,7 @@ static bool get_point(int16_t *x, int16_t *y) {
*y = int16_t((int32_t(*y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
}
#if ENABLED(GRAPHICAL_TFT_ROTATE_180)
#if (TFT_ROTATION & TFT_ROTATE_180)
*x = int16_t((TFT_WIDTH) - (int)(*x));
*y = int16_t((TFT_HEIGHT) - (int)(*y));
#endif

View File

@ -32,7 +32,7 @@
#include <lvgl.h>
//#define GRAPHICAL_TFT_ROTATE_180
//#define TFT_ROTATION TFT_ROTATE_180
#define USE_WIFI_FUNCTION 0
extern void tft_lvgl_init();

View File

@ -43,8 +43,13 @@
#endif
#ifndef TFT_PIXEL_OFFSET_X
#if GRAPHICAL_TFT_UPSCALE == 2
#define TFT_PIXEL_OFFSET_X 32
#else
#define TFT_PIXEL_OFFSET_X 48
#endif
#ifndef TFT_PIXEL_OFFSET_Y
#define TFT_PIXEL_OFFSET_Y 48
#endif
#ifndef TFT_PIXEL_OFFSET_Y
// 32 is better for both 320x240 and 480x320
#define TFT_PIXEL_OFFSET_Y 32
#endif

View File

@ -25,173 +25,16 @@
#if HAS_GRAPHICAL_TFT
#include "tft.h"
#include "st7735.h"
#include "st7789v.h"
#include "st7796s.h"
#include "r65105.h"
#include "ili9328.h"
#include "ili9341.h"
#include "ili9488.h"
//#define DEBUG_GRAPHICAL_TFT
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
#include "../../core/debug_out.h"
uint16_t TFT::buffer[];
uint32_t TFT::lcd_id = 0xFFFFFFFF;
void TFT::init() {
if (lcd_id != 0xFFFFFFFF) return;
io.Init();
#if TFT_DRIVER != AUTO
lcd_id = TFT_DRIVER;
#endif
#if TFT_DRIVER == ST7735
write_esc_sequence(st7735_init);
#elif TFT_DRIVER == ST7789
write_esc_sequence(st7789v_init);
#elif TFT_DRIVER == ST7796
write_esc_sequence(st7796s_init);
#elif TFT_DRIVER == R61505
write_esc_sequence(r61505_init);
#elif TFT_DRIVER == ILI9328
write_esc_sequence(ili9328_init);
#elif TFT_DRIVER == ILI9341
write_esc_sequence(ili9341_init);
#elif TFT_DRIVER == ILI9488
write_esc_sequence(ili9488_init);
#elif TFT_DRIVER == LERDGE_ST7796
lcd_id = ST7796;
write_esc_sequence(lerdge_st7796s_init);
#elif TFT_DRIVER == AUTO // autodetect
lcd_id = io.GetID() & 0xFFFF;
switch (lcd_id) {
case ST7796: // ST7796S 480x320
DEBUG_ECHO_MSG(" ST7796S");
write_esc_sequence(st7796s_init);
break;
case ST7789: // ST7789V 320x240
DEBUG_ECHO_MSG(" ST7789V");
write_esc_sequence(st7789v_init);
break;
case ST7735: // ST7735 160x128
DEBUG_ECHO_MSG(" ST7735");
write_esc_sequence(st7735_init);
break;
case R61505: // R61505U 320x240
DEBUG_ECHO_MSG(" R61505U");
write_esc_sequence(r61505_init);
break;
case ILI9328: // ILI9328 320x240
DEBUG_ECHO_MSG(" ILI9328");
write_esc_sequence(ili9328_init);
break;
case ILI9341: // ILI9341 320x240
DEBUG_ECHO_MSG(" ILI9341");
write_esc_sequence(ili9341_init);
break;
case ILI9488: // ILI9488 480x320
DEBUG_ECHO_MSG(" ILI9488");
write_esc_sequence(ili9488_init);
break;
default:
lcd_id = 0;
}
#else
#error Unsupported TFT driver
#endif
}
void TFT::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
#ifdef OFFSET_X
Xmin += OFFSET_X; Xmax += OFFSET_X;
#endif
#ifdef OFFSET_Y
Ymin += OFFSET_Y; Ymax += OFFSET_Y;
#endif
switch (lcd_id) {
case ST7735: // ST7735 160x128
case ST7789: // ST7789V 320x240
case ST7796: // ST7796 480x320
case ILI9341: // ILI9341 320x240
case ILI9488: // ILI9488 480x320
io.DataTransferBegin(DATASIZE_8BIT);
// CASET: Column Address Set
io.WriteReg(ILI9341_CASET);
io.WriteData((Xmin >> 8) & 0xFF);
io.WriteData(Xmin & 0xFF);
io.WriteData((Xmax >> 8) & 0xFF);
io.WriteData(Xmax & 0xFF);
// RASET: Row Address Set
io.WriteReg(ILI9341_PASET);
io.WriteData((Ymin >> 8) & 0xFF);
io.WriteData(Ymin & 0xFF);
io.WriteData((Ymax >> 8) & 0xFF);
io.WriteData(Ymax & 0xFF);
// RAMWR: Memory Write
io.WriteReg(ILI9341_RAMWR);
break;
case R61505: // R61505U 320x240
case ILI9328: // ILI9328 320x240
io.DataTransferBegin(DATASIZE_16BIT);
// Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
io.WriteReg(ILI9328_HASTART);
io.WriteData(Ymin);
io.WriteReg(ILI9328_HAEND);
io.WriteData(Ymax);
io.WriteReg(ILI9328_VASTART);
io.WriteData(Xmin);
io.WriteReg(ILI9328_VAEND);
io.WriteData(Xmax);
io.WriteReg(ILI9328_HASET);
io.WriteData(Ymin);
io.WriteReg(ILI9328_VASET);
io.WriteData(Xmin);
io.WriteReg(ILI9328_RAMWR);
break;
default:
break;
}
io.DataTransferEnd();
}
void TFT::write_esc_sequence(const uint16_t *Sequence) {
uint16_t dataWidth, data;
dataWidth = *Sequence++;
io.DataTransferBegin(dataWidth);
for (;;) {
data = *Sequence++;
if (data != 0xFFFF) {
io.WriteData(data);
continue;
}
data = *Sequence++;
if (data == 0x7FFF) return;
if (data == 0xFFFF)
io.WriteData(0xFFFF);
else if (data & 0x8000)
delay(data & 0x7FFF);
else if ((data & 0xFF00) == 0)
io.WriteReg(data);
}
io.DataTransferEnd();
io.InitTFT();
}
TFT tft;

View File

@ -26,7 +26,7 @@
#include "tft_color.h"
#include "tft_string.h"
#include "tft_image.h"
#include "tft_io.h"
#include "../tft_io/tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -40,20 +40,6 @@
#error "Unsupported display resolution!"
#endif
#define ST7735 0x89F0
#define ST7789 0x8552
#define ST7796 0x7796
#define R61505 0x1505
#define ILI9328 0x9328
#define ILI9341 0x9341
#define ILI9488 0x9488
#define LERDGE_ST7796 0xFFFE
#define AUTO 0xFFFF
#ifndef TFT_DRIVER
#define TFT_DRIVER AUTO
#endif
#ifndef TFT_BUFFER_SIZE
#ifdef STM32F103xB
#define TFT_BUFFER_SIZE 1024
@ -71,14 +57,8 @@
#error "TFT_BUFFER_SIZE can not exceed 65535"
#endif
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF
#define ESC_FFFF 0xFFFF, 0xFFFF
class TFT {
private:
static uint32_t lcd_id;
static TFT_String string;
static TFT_IO io;
@ -91,13 +71,11 @@ class TFT {
static inline void set_font(const uint8_t *Font) { string.set_font(Font); }
static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); }
static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
static void write_esc_sequence(const uint16_t *Sequence);
static inline bool is_busy() { return io.isBusy(); }
static inline void abort() { io.Abort(); }
static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); }
static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }
static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); }
static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); }
static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }

View File

@ -1,30 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../inc/MarlinConfig.h"
#if HAS_SPI_TFT
#include HAL_PATH(../../HAL, tft/tft_spi.h)
#elif HAS_FSMC_TFT
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
#endif

View File

@ -295,6 +295,10 @@ bool Touch::get_point(int16_t *x, int16_t *y) {
if (is_touched && calibration.orientation != TOUCH_ORIENTATION_NONE) {
*x = int16_t((int32_t(*x) * calibration.x) >> 16) + calibration.offset_x;
*y = int16_t((int32_t(*y) * calibration.y) >> 16) + calibration.offset_y;
#if (TFT_ROTATION & TFT_ROTATE_180)
*x = TFT_WIDTH - *x;
*y = TFT_HEIGHT - *y;
#endif
}
return is_touched;
}

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -40,8 +40,29 @@
#define ILI9328_ETMOD_AM 0x0008 // 0 - Horizontal / 1 - Vertical
// MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
#if TFT_ROTATION == TFT_ROTATE_180
#define ILI9328_DRVCTL_DATA 0x0000
#define ILI9328_GATE_SCANCTL1_DATA 0xA700
#else
#define ILI9328_DRVCTL_DATA ILI9328_DRVCTL_SS
#define ILI9328_ETMOD_DATA ILI9328_ETMOD_BGR | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0 | ILI9328_ETMOD_AM
#define ILI9328_GATE_SCANCTL1_DATA 0x2700
#endif
// #define ILI9328_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9328_ETMOD_AM) | \
// IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9328_ETMOD_ID1) | \
// IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9328_ETMOD_ID0)
#define ILI9328_ETMOD_ORIENTATION (ILI9328_ETMOD_AM | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define ILI9328_ETMOD_COLOR ILI9328_ETMOD_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define ILI9328_ETMOD_COLOR ILI9328_ETMOD_RGB
#endif
#define ILI9328_ETMOD_DATA (ILI9328_ETMOD_ORIENTATION) | (ILI9328_ETMOD_COLOR)
#define ILI9328_RDDID 0x00 // ID code - 0x9328
#define ILI9328_DRVCTL 0x01 // Driver Output Control
@ -134,7 +155,7 @@ static const uint16_t ili9328_init[] = {
ESC_REG(ILI9328_PWCTRL7), 0x0004,
ESC_REG(ILI9328_FRMCTR), 0x000D,
ESC_DELAY(50),
ESC_REG(ILI9328_GATE_SCANCTL1), 0x2700,
ESC_REG(ILI9328_GATE_SCANCTL1), ILI9328_GATE_SCANCTL1_DATA,
ESC_REG(ILI9328_GATE_SCANCTL2), 0x0001,
ESC_REG(ILI9328_GATE_SCANCTL3), 0x0000,
ESC_REG(ILI9328_PLTPOS1), 0x0000,

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -38,13 +38,17 @@
#define ILI9341_ORIENTATION_LEFT ILI9341_MADCTL_MY | ILI9341_MADCTL_MX | ILI9341_MADCTL_MV // 320x240 ; Cable on the left side
#define ILI9341_ORIENTATION_DOWN ILI9341_MADCTL_MX // 240x320 ; Cable on the upper side
#ifndef ILI9341_COLOR_RGB
#define ILI9341_COLOR_BGR
#define ILI9341_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9341_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9341_MADCTL_MX) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9341_MADCTL_MY)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define ILI9341_COLOR ILI9341_MADCTL_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define ILI9341_COLOR ILI9341_MADCTL_RGB
#endif
#ifndef ILI9341_ORIENTATION
#define ILI9341_ORIENTATION ILI9341_ORIENTATION_LEFT
#endif
#define ILI9341_MADCTL_DATA (ILI9341_ORIENTATION | TERN(ILI9341_COLOR_BGR, ILI9341_MADCTL_BGR, ILI9341_MADCTL_RGB))
#define ILI9341_MADCTL_DATA (ILI9341_ORIENTATION) | (ILI9341_COLOR)
#define ILI9341_NOP 0x00 // No Operation
#define ILI9341_SWRESET 0x01 // Software Reset

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -38,13 +38,17 @@
#define ILI9488_ORIENTATION_LEFT ILI9488_MADCTL_MY | ILI9488_MADCTL_MX | ILI9488_MADCTL_MV // 480x320 ; Cable on the left side
#define ILI9488_ORIENTATION_DOWN ILI9488_MADCTL_MX // 320x480 ; Cable on the upper side
#ifndef ILI9488_COLOR_RGB
#define ILI9488_COLOR_BGR
#define ILI9488_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9488_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9488_MADCTL_MX) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9488_MADCTL_MY)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define ILI9488_COLOR ILI9488_MADCTL_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define ILI9488_COLOR ILI9488_MADCTL_RGB
#endif
#ifndef ILI9488_ORIENTATION
#define ILI9488_ORIENTATION ILI9488_ORIENTATION_LEFT
#endif
#define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION | TERN(ILI9488_COLOR_BGR, ILI9488_MADCTL_BGR, ILI9488_MADCTL_RGB))
#define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION) | (ILI9488_COLOR)
#define ILI9488_NOP 0x00 // No Operation
#define ILI9488_SWRESET 0x01 // Software Reset

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -42,9 +42,28 @@
#define R61505_DRVCTRL_GS 0x8000 // Gate Scan direction
// MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
#if TFT_ROTATION == TFT_ROTATE_180
#define R61505_DRVCTL_DATA 0x0000
#define R61505_DRVCTRL_DATA (0x2700 | R61505_DRVCTRL_GS)
#else
#define R61505_DRVCTL_DATA R61505_DRVCTL_SS
#define R61505_ETMOD_DATA R61505_ETMOD_BGR | R61505_ETMOD_ID1 | R61505_ETMOD_ID0 | R61505_ETMOD_AM
#define R61505_DRVCTRL_GSDIR R61505_DRVCTRL_GS
#define R61505_DRVCTRL_DATA 0x2700
#endif
// #define R61505_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, R61505_ETMOD_AM) | \
// IF_0((TFT_ORIENTATION) & TFT_INVERT_X, R61505_ETMOD_ID0) | \
// IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, R61505_ETMOD_ID1)
#define R61505_ETMOD_ORIENTATION (R61505_ETMOD_AM | R61505_ETMOD_ID0 | R61505_ETMOD_ID1)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define R61505_ETMOD_COLOR R61505_ETMOD_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define R61505_ETMOD_COLOR R61505_ETMOD_RGB
#endif
#define R61505_ETMOD_DATA (R61505_ETMOD_ORIENTATION) | (R61505_ETMOD_COLOR)
#define R61505_RDDID 0x00 // ID code - 0x1505
@ -141,7 +160,7 @@ static const uint16_t r61505_init[] = {
ESC_REG(R61505_GAMCTRL9), 0x0700,
ESC_REG(R61505_GAMCTRLA), 0x0A1F,
ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_GSDIR | 0x2700,
ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_DATA,
ESC_REG(R61505_BASE_IMAGE_CTRL), 0x0001,
ESC_REG(R61505_VSCROLL_CTRL), 0x0000,

View File

@ -0,0 +1,131 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
#define SSD1963_MADCTL_MY 0x80 // Row Address Order
#define SSD1963_MADCTL_MX 0x40 // Column Address Order
#define SSD1963_MADCTL_MV 0x20 // Row/Column Exchange
#define SSD1963_MADCTL_MH 0x10 // Horizontal Refresh Order
#define SSD1963_MADCTL_BGR 0x08 // RGB-BGR ORDER
#define SSD1963_MADCTL_RGB 0x00
#define SSD1963_MADCTL_ML 0x04 // Vertical Refresh Order
#define SSD1963_MADCTL_FH 0x02 // Flip Horizontal
#define SSD1963_MADCTL_FV 0x01 // Flip Vertical
#define SSD1963_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, SSD1963_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, SSD1963_MADCTL_FH) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, SSD1963_MADCTL_FV)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define SSD1963_COLOR SSD1963_MADCTL_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define SSD1963_COLOR SSD1963_MADCTL_RGB
#endif
#define SSD1963_MADCTL_DATA (SSD1963_ORIENTATION) | (SSD1963_COLOR)
#define SSD1963_NOP 0x00 // No Operation
#define SSD1963_SWRESET 0x01 // Software reset
#define SSD1963_RDDPM 0x0A // Read Display Power Mode
#define SSD1963_RDDMADCTL 0x0B // Read Display MADCTL
#define SSD1963_RDDCOLMOD 0x0C // Read Display Pixel Format
#define SSD1963_RDDIM 0x0D // Read Display Image Mode
#define SSD1963_RDDSM 0x0E // Read Display Signal Mode
#define SSD1963_SLPIN 0x10 // Sleep In
#define SSD1963_SLPOUT 0x11 // Sleep Out
#define SSD1963_PTLON 0x12 // Partial Display Mode On
#define SSD1963_NORON 0x13 // Normal Display Mode On
#define SSD1963_INVOFF 0x20 // Display Inversion Off
#define SSD1963_INVON 0x21 // Display Inversion On
#define SSD1963_GAMSET 0x26 // Gamma Set
#define SSD1963_DISPOFF 0x28 // Display Off
#define SSD1963_DISPON 0x29 // Display On
#define SSD1963_CASET 0x2A // Column Address Set
#define SSD1963_RASET 0x2B // Row Address Set
#define SSD1963_RAMWR 0x2C // Memory Write
#define SSD1963_RAMRD 0x2E // Memory Read
#define SSD1963_PTLAR 0x30 // Partial Area
#define SSD1963_VSCRDEF 0x33 // Vertical Scrolling Definition
#define SSD1963_TEOFF 0x34 // Tearing Effect Line OFF
#define SSD1963_TEON 0x35 // Tearing Effect Line ON
#define SSD1963_MADCTL 0x36 // Memory Data Access Control
#define SSD1963_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
#define SSD1963_IDMOFF 0x38 // Idle Mode Off
#define SSD1963_IDMON 0x39 // Idle Mode On
#define SSD1963_WRMEMC 0x3C // Write Memory Continue
#define SSD1963_RDMEMC 0x3E // Read Memory Continue
#define SSD1963_STE 0x44 // Set Tear Scanline
#define SSD1963_GSCAN 0x45 // Get Scanline
#define SSD1963_WRDISBV 0x51 // Write Display Brightness
#define SSD1963_RDDISBV 0x52 // Read Display Brightness
#define SSD1963_WRCTRLD 0x53 // Write CTRL Display
#define SSD1963_RDCTRLD 0x54 // Read CTRL Value Display
#define SSD1963_WRCACE 0x55 // Write Content Adaptive Brightness Control and Color Enhancement
#define SSD1963_RDCABC 0x56 // Read Content Adaptive Brightness Control
#define SSD1963_WRCABCMB 0x5E // Write CABC Minimum Brightness
#define SSD1963_RDCABCMB 0x5F // Read CABC Minimum Brightness
#define SSD1963_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result
#define SSD1963_RDDDB 0xA1 // Read Device Descriptor Block
#define SSD1963_SLCDMODE 0xB0 // Set the LCD panel mode and resolution
#define SSD1963_SHSYNC 0xB4 // Set HSYNC
#define SSD1963_GHSYNC 0xB5 // Get HSYNC
#define SSD1963_SVSYNC 0xB6 // Set VSYNC
#define SSD1963_GVSYNC 0xB7 // Get VSYNC
#define SSD1963_SGPIOCFG 0xB8 // Set GPIO Conf
#define SSD1963_SGPIOV 0xBA // Set GPIO Value
#define SSD1963_SPWMCFG 0xBE // Set PWM Conf
#define SSD1963_GPWMCFG 0xBF // Get PWM Conf
#define SSD1963_SDBCCFG 0xD0 // Set Dynamic Back Light Config
#define SSD1963_GDBCCFG 0xD1 // Get Dynamic Back Light Config
#define SSD1963_PLLON 0xE0 // PLL Enable
#define SSD1963_PLLMN 0xE2 // Set PLL Multiplier
#define SSD1963_SLSHIFT 0xE6 // Set the LSHIFT (pixel clock) frequency
#define SSD1963_COLMOD 0xF0 // Interface Pixel Format
static const uint16_t ssd1963_init[] = {
DATASIZE_8BIT,
ESC_REG(SSD1963_PLLMN), 0x0023, 0x0002, 0x0054,
ESC_REG(SSD1963_PLLON), 0x0001, ESC_DELAY(10),
ESC_REG(SSD1963_PLLON), 0x0003, ESC_DELAY(10),
ESC_REG(SSD1963_SWRESET), ESC_DELAY(100),
ESC_REG(SSD1963_SLSHIFT), 0x0001, 0x001F, 0x00FF,
ESC_REG(SSD1963_SLCDMODE), 0x0020, 0x0000, 0x0001, 0x00DF, 0x0001, 0x000F, 0x0000,
ESC_REG(SSD1963_SHSYNC), 0x0002, 0x0013, 0x0000, 0x0008, 0x002B, 0x0000, 0x0002, 0x0000,
ESC_REG(SSD1963_SVSYNC), 0x0001, 0x0020, 0x0000, 0x0004, 0x000C, 0x0000, 0x0002,
ESC_REG(SSD1963_SGPIOV), 0x000F,
ESC_REG(SSD1963_SGPIOCFG), 0x0007, 0x0001,
ESC_REG(SSD1963_MADCTL), SSD1963_MADCTL_DATA,
ESC_REG(SSD1963_COLMOD), 0x0003, ESC_DELAY(1),//RBG 565
ESC_REG(SSD1963_NORON),
ESC_REG(SSD1963_DISPON),
ESC_REG(SSD1963_SPWMCFG), 0x0006, 0x00f0, 0x0001, 0x00f0, 0x0000, 0x0000,
ESC_REG(SSD1963_SDBCCFG), 0x000D,
ESC_END
};

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -38,9 +38,17 @@
#define ST7735_ORIENTATION_LEFT ST7735_MADCTL_MV | ST7735_MADCTL_MX // 160x128 ; Cable on the left side
#define ST7735_ORIENTATION_DOWN ST7735_MADCTL_MX | ST7735_MADCTL_MY // 128x160 ; Cable on the lower side
//#define ST7735_COLOR_BGR
#define ST7735_ORIENTATION ST7735_ORIENTATION_DOWN
#define ST7735_MADCTL_DATA (ST7735_ORIENTATION | TERN(ST7735_COLOR_BGR, ST7735_MADCTL_BGR, ST7735_MADCTL_RGB))
#define ST7735_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7735_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7735_MADCTL_MX) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7735_MADCTL_MY)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
#define ST7735_COLOR ST7735_MADCTL_RGB
#elif TFT_COLOR == TFT_COLOR_BGR
#define ST7735_COLOR ST7735_MADCTL_BGR
#endif
#define ST7735_MADCTL_DATA (ST7735_ORIENTATION) | (ST7735_COLOR)
#define ST7735_NOP 0x00 // No Operation
#define ST7735_SWRESET 0x01 // Software reset

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -38,11 +38,17 @@
#define ST7789V_ORIENTATION_LEFT ST7789V_MADCTL_MY | ST7789V_MADCTL_MV // 320x240 ; Cable on the left side
#define ST7789V_ORIENTATION_DOWN 0 // 240x320 ; Cable on the lower side
//#define ST7789V_COLOR_BGR
#ifndef ST7789V_ORIENTATION
#define ST7789V_ORIENTATION ST7789V_ORIENTATION_LEFT
#define ST7789V_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7789V_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7789V_MADCTL_MX) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7789V_MADCTL_MY)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
#define ST7789V_COLOR ST7789V_MADCTL_RGB
#elif TFT_COLOR == TFT_COLOR_BGR
#define ST7789V_COLOR ST7789V_MADCTL_BGR
#endif
#define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION | TERN(ST7789V_COLOR_BGR, ST7789V_MADCTL_BGR, ST7789V_MADCTL_RGB))
#define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION) | (ST7789V_COLOR)
#define ST7789V_NOP 0x00 // No Operation
#define ST7789V_SWRESET 0x01 // Software reset

View File

@ -21,7 +21,7 @@
*/
#pragma once
#include "tft.h"
#include "tft_io.h"
#include "../../inc/MarlinConfig.h"
@ -33,9 +33,17 @@
#define ST7796S_MADCTL_RGB 0x00
#define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order
#define ST7796S_COLOR_BGR
#define ST7796S_ORIENTATION ST7796S_MADCTL_MV
#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB))
#define ST7796S_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7796S_MADCTL_MV) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7796S_MADCTL_MX) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7796S_MADCTL_MY)
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
#define ST7796S_COLOR ST7796S_MADCTL_BGR
#elif TFT_COLOR == TFT_COLOR_RGB
#define ST7796S_COLOR ST7796S_MADCTL_RGB
#endif
#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION) | (ST7796S_COLOR)
#define ST7796S_NOP 0x00 // No Operation
#define ST7796S_SWRESET 0x01 // Software reset

View File

@ -0,0 +1,226 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "tft_io.h"
#if HAS_SPI_TFT || HAS_FSMC_TFT
#include "st7735.h"
#include "st7789v.h"
#include "st7796s.h"
#include "r65105.h"
#include "ili9328.h"
#include "ili9341.h"
#include "ili9488.h"
#include "ssd1963.h"
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
#include "../../core/debug_out.h"
TFT_IO_DRIVER TFT_IO::io;
uint32_t TFT_IO::lcd_id = 0xFFFFFFFF;
void TFT_IO::InitTFT() {
if (lcd_id != 0xFFFFFFFF) return;
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
#endif
#if PIN_EXISTS(TFT_RESET)
OUT_WRITE(TFT_RESET_PIN, HIGH);
delay(10);
OUT_WRITE(TFT_RESET_PIN, LOW);
delay(10);
OUT_WRITE(TFT_RESET_PIN, HIGH);
#endif
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
#endif
// io.Init();
delay(100);
#if TFT_DRIVER != AUTO
lcd_id = TFT_DRIVER;
#endif
#if TFT_DRIVER == ST7735
write_esc_sequence(st7735_init);
#elif TFT_DRIVER == SSD1963
write_esc_sequence(ssd1963_init);
#elif TFT_DRIVER == ST7789
write_esc_sequence(st7789v_init);
#elif TFT_DRIVER == ST7796
write_esc_sequence(st7796s_init);
#elif TFT_DRIVER == R61505
write_esc_sequence(r61505_init);
#elif TFT_DRIVER == ILI9328
write_esc_sequence(ili9328_init);
#elif TFT_DRIVER == ILI9341
write_esc_sequence(ili9341_init);
#elif TFT_DRIVER == ILI9488
write_esc_sequence(ili9488_init);
#elif TFT_DRIVER == LERDGE_ST7796
lcd_id = ST7796;
write_esc_sequence(lerdge_st7796s_init);
#elif TFT_DRIVER == AUTO // autodetect
lcd_id = io.GetID() & 0xFFFF;
switch (lcd_id) {
case ST7796: // ST7796S 480x320
DEBUG_ECHO_MSG(" ST7796S");
write_esc_sequence(st7796s_init);
break;
case ST7789: // ST7789V 320x240
DEBUG_ECHO_MSG(" ST7789V");
write_esc_sequence(st7789v_init);
break;
case SSD1963: // SSD1963
DEBUG_ECHO_MSG(" SSD1963");
write_esc_sequence(ssd1963_init);
break;
case ST7735: // ST7735 160x128
DEBUG_ECHO_MSG(" ST7735");
write_esc_sequence(st7735_init);
break;
case R61505: // R61505U 320x240
DEBUG_ECHO_MSG(" R61505U");
write_esc_sequence(r61505_init);
break;
case ILI9328: // ILI9328 320x240
DEBUG_ECHO_MSG(" ILI9328");
write_esc_sequence(ili9328_init);
break;
case ILI9341: // ILI9341 320x240
DEBUG_ECHO_MSG(" ILI9341");
write_esc_sequence(ili9341_init);
break;
case ILI9488: // ILI9488 480x320
case ILI9488_ID1: // 0x8066 ILI9488 480x320
DEBUG_ECHO_MSG(" ILI9488");
write_esc_sequence(ili9488_init);
break;
default:
lcd_id = 0;
}
#else
#error Unsupported TFT driver
#endif
#if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif
}
void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
#ifdef OFFSET_X
Xmin += OFFSET_X; Xmax += OFFSET_X;
#endif
#ifdef OFFSET_Y
Ymin += OFFSET_Y; Ymax += OFFSET_Y;
#endif
switch (lcd_id) {
case ST7735: // ST7735 160x128
case ST7789: // ST7789V 320x240
case ST7796: // ST7796 480x320
case ILI9341: // ILI9341 320x240
case ILI9488: // ILI9488 480x320
case SSD1963: // SSD1963
case ILI9488_ID1: // 0x8066 ILI9488 480x320
io.DataTransferBegin(DATASIZE_8BIT);
// CASET: Column Address Set
io.WriteReg(ILI9341_CASET);
io.WriteData((Xmin >> 8) & 0xFF);
io.WriteData(Xmin & 0xFF);
io.WriteData((Xmax >> 8) & 0xFF);
io.WriteData(Xmax & 0xFF);
// RASET: Row Address Set
io.WriteReg(ILI9341_PASET);
io.WriteData((Ymin >> 8) & 0xFF);
io.WriteData(Ymin & 0xFF);
io.WriteData((Ymax >> 8) & 0xFF);
io.WriteData(Ymax & 0xFF);
// RAMWR: Memory Write
io.WriteReg(ILI9341_RAMWR);
break;
case R61505: // R61505U 320x240
case ILI9328: // ILI9328 320x240
io.DataTransferBegin(DATASIZE_16BIT);
// Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
io.WriteReg(ILI9328_HASTART);
io.WriteData(Ymin);
io.WriteReg(ILI9328_HAEND);
io.WriteData(Ymax);
io.WriteReg(ILI9328_VASTART);
io.WriteData(Xmin);
io.WriteReg(ILI9328_VAEND);
io.WriteData(Xmax);
io.WriteReg(ILI9328_HASET);
io.WriteData(Ymin);
io.WriteReg(ILI9328_VASET);
io.WriteData(Xmin);
io.WriteReg(ILI9328_RAMWR);
break;
default:
break;
}
io.DataTransferEnd();
}
void TFT_IO::write_esc_sequence(const uint16_t *Sequence) {
uint16_t dataWidth, data;
dataWidth = *Sequence++;
io.DataTransferBegin(dataWidth);
for (;;) {
data = *Sequence++;
if (data != 0xFFFF) {
io.WriteData(data);
continue;
}
data = *Sequence++;
if (data == 0x7FFF) return;
if (data == 0xFFFF)
io.WriteData(0xFFFF);
else if (data & 0x8000)
delay(data & 0x7FFF);
else if ((data & 0xFF00) == 0)
io.WriteReg(data);
}
io.DataTransferEnd();
}
#endif // HAS_SPI_TFT || HAS_FSMC_TFT

View File

@ -0,0 +1,124 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../inc/MarlinConfig.h"
#if HAS_SPI_TFT || HAS_FSMC_TFT
#if HAS_SPI_TFT
#include HAL_PATH(../../HAL, tft/tft_spi.h)
#elif HAS_FSMC_TFT
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
#else
#error "TFT IO only supports SPI or FSMC interface"
#endif
#define TFT_EXCHANGE_XY (1UL << 1)
#define TFT_INVERT_X (1UL << 2)
#define TFT_INVERT_Y (1UL << 3)
#define TFT_NO_ROTATION (0x00)
#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
#define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#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_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y)
#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X)
#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
// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
#define TFT_COLOR_RGB (1UL << 3)
#define TFT_COLOR_BGR (1UL << 4)
// Each TFT Driver is responsible for its default color mode.
// #ifndef TFT_COLOR
// #define TFT_COLOR TFT_COLOR_RGB
// #endif
#define SSD1963 0x5761
#define ST7735 0x89F0
#define ST7789 0x8552
#define ST7796 0x7796
#define R61505 0x1505
#define ILI9328 0x9328
#define ILI9341 0x9341
#define ILI9488 0x9488
#define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04
#define LERDGE_ST7796 0xFFFE
#define AUTO 0xFFFF
#ifndef TFT_DRIVER
#define TFT_DRIVER AUTO
#endif
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF
#define ESC_FFFF 0xFFFF, 0xFFFF
class TFT_IO {
public:
static TFT_IO_DRIVER io;
static void InitTFT();
static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
static void write_esc_sequence(const uint16_t *Sequence);
// Deletaged methods
inline static void Init() { io.Init(); };
inline static bool isBusy() { return io.isBusy(); };
inline static void Abort() { io.Abort(); };
inline static uint32_t GetID() { return io.GetID(); };
inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); }
inline static void DataTransferEnd() { io.DataTransferEnd(); };
// inline static void DataTransferAbort() { io.DataTransferAbort(); };
inline static void WriteData(uint16_t Data) { io.WriteData(Data); };
inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); };
inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); };
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); };
protected:
static uint32_t lcd_id;
};
#endif // HAS_SPI_TFT || HAS_FSMC_TFT

View File

@ -82,7 +82,7 @@ uint8_t TouchButtons::read_buttons() {
x = uint16_t((uint32_t(x) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET;
y = uint16_t((uint32_t(y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
#if ENABLED(GRAPHICAL_TFT_ROTATE_180)
#if (TFT_ROTATION & TFT_ROTATE_180)
x = TOUCH_SENSOR_WIDTH - x;
y = TOUCH_SENSOR_HEIGHT - y;
#endif

View File

@ -296,13 +296,17 @@
#ifndef GRAPHICAL_TFT_UPSCALE
#define GRAPHICAL_TFT_UPSCALE 3
#endif
// SPI 1
#define SCK_PIN P0_15
#define MISO_PIN P0_17
#define MOSI_PIN P0_18
// Disable any LCD related PINs config
#define LCD_PINS_ENABLE -1
#define LCD_PINS_RS -1
// Emulated DOGM have xpt calibration values independent of display resolution
#if ENABLED(SPI_GRAPHICAL_TFT)
// XPT2046 Touch Screen calibration
#if ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -11245
#endif
@ -315,6 +319,21 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -285
#endif
#elif ENABLED(TFT_480x320_SPI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17232
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 11196
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 1047
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -358
#endif
#define TFT_BUFFER_SIZE 2400
#endif
#elif IS_TFTGLCD_PANEL

View File

@ -129,8 +129,6 @@
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
#define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13
#define TFT_RESET_PIN PF11
#define TFT_BACKLIGHT_PIN PD13
@ -140,14 +138,9 @@
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
#define TFT_PIXEL_OFFSET_X 48
#define TFT_PIXEL_OFFSET_Y 32
#endif
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI)
// LVGL
#define HAS_SPI_FLASH_FONT 1
#define HAS_GCODE_PREVIEW 1
@ -155,16 +148,17 @@
#define HAS_LANG_SELECT_SCREEN 1
#define HAS_BAK_VIEW_IN_FLASH 0
#define HAS_LOGO_IN_FLASH 0
#elif ENABLED(TFT_480x320)
#elif ENABLED(TFT_COLOR_UI)
// Color UI
#define TFT_DRIVER ILI9488
#define TFT_BUFFER_SIZE 14400
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
// Emulated DOGM
#define GRAPHICAL_TFT_UPSCALE 3
#endif
#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320)
// XPT2046 Touch Screen calibration
#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17181
#endif
@ -177,7 +171,7 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -9
#endif
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -12316
#endif

View File

@ -135,15 +135,15 @@
// TronXY TFT Support
//
// Shared FSMC Configs
#if HAS_FSMC_TFT
// Shared FSMC
#define TOUCH_CS_PIN PB7 // SPI1_NSS
#define TOUCH_SCK_PIN PA5 // SPI1_SCK
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
#define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13
#define TFT_RESET_PIN PF11
#define TFT_BACKLIGHT_PIN PD13
@ -153,14 +153,9 @@
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
#define TFT_PIXEL_OFFSET_X 48
#define TFT_PIXEL_OFFSET_Y 32
#endif
#if HAS_TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI)
// LVGL
#define HAS_SPI_FLASH_FONT 1
#define HAS_GCODE_PREVIEW 1
@ -168,16 +163,17 @@
#define HAS_LANG_SELECT_SCREEN 1
#define HAS_BAK_VIEW_IN_FLASH 0
#define HAS_LOGO_IN_FLASH 0
#elif ENABLED(TFT_480x320)
#elif ENABLED(TFT_COLOR_UI)
// Color UI
#define TFT_DRIVER ILI9488
#define TFT_BUFFER_SIZE 14400
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
// Emulated DOGM
#define GRAPHICAL_TFT_UPSCALE 3
#endif
#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320)
// XPT2046 Touch Screen calibration
#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17181
#endif
@ -190,7 +186,7 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -9
#endif
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -12316
#endif

View File

@ -118,7 +118,6 @@
* because Marlin uses the reset as a failsafe to revive a glitchy LCD.
*/
#define LCD_RESET_PIN PC4 // pin 33
#define TFT_RESET_PIN PC4 // pin 33
#define TFT_BACKLIGHT_PIN PD12 // pin 59
#define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1
@ -131,13 +130,11 @@
#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h
#define DOGLCD_SCK -1
#define GRAPHICAL_TFT_UPSCALE 2
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define TFT_PIXEL_OFFSET_X 32
#define TFT_PIXEL_OFFSET_Y 32
// Longer/Alfawise TFT
#define LONGER_LK_TFT28
//#define TFT_DRIVER ILI9341
// Buffer for Color UI
#define TFT_BUFFER_SIZE 3200
/**
* Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer

View File

@ -290,6 +290,7 @@
#define TFT_BUFFER_SIZE 14400
#endif
// XPT2046 Touch Screen calibration
#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320_SPI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17253

View File

@ -171,6 +171,9 @@
// Shared FSMC Configs
#if HAS_FSMC_TFT
#define DOGLCD_MOSI -1 // prevent redefine Conditionals_post.h
#define DOGLCD_SCK -1
#define FSMC_CS_PIN PD7 // NE4
#define FSMC_RS_PIN PD11 // A0
@ -179,9 +182,6 @@
#define TOUCH_MISO_PIN PB14 // SPI2_MISO
#define TOUCH_MOSI_PIN PB15 // SPI2_MOSI
#define LCD_RESET_PIN PC6 // FSMC_RST
#define LCD_BACKLIGHT_PIN PD13
#define TFT_RESET_PIN PC6 // FSMC_RST
#define TFT_BACKLIGHT_PIN PD13
@ -193,60 +193,11 @@
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 2
#endif
#if ENABLED(FSMC_GRAPHICAL_TFT)
// Emulated DOGM
#define DOGLCD_MOSI -1 // prevent redefine Conditionals_post.h
#define DOGLCD_SCK -1
#ifndef GRAPHICAL_TFT_UPSCALE
#define GRAPHICAL_TFT_UPSCALE 3
#endif
#ifndef TFT_WIDTH
#define TFT_WIDTH 480
#endif
#ifndef TFT_PIXEL_OFFSET_X
#define TFT_PIXEL_OFFSET_X 48
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#ifndef TFT_PIXEL_OFFSET_Y
#define TFT_PIXEL_OFFSET_Y 32
#endif
#elif ENABLED(TFT_320x240) // TFT32/28
#define TFT_RESET_PIN PC6
#define TFT_BACKLIGHT_PIN PD13
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#define TOUCH_CS_PIN PA7 // SPI2_NSS
#define TOUCH_SCK_PIN PB13 // SPI2_SCK
#define TOUCH_MISO_PIN PB14 // SPI2_MISO
#define TOUCH_MOSI_PIN PB15 // SPI2_MOSI
#define TFT_DRIVER ILI9341
#define TFT_BUFFER_SIZE 14400
// YV for normal screen mounting
//#define ILI9341_ORIENTATION ILI9341_MADCTL_MY | ILI9341_MADCTL_MV
// XV for 180° rotated screen mounting
#define ILI9341_ORIENTATION ILI9341_MADCTL_MX | ILI9341_MADCTL_MV
#define ILI9341_COLOR_RGB
#elif ENABLED(TFT_480x320)
#define TFT_DRIVER ILI9488
#define TFT_BUFFER_SIZE 14400
#define ILI9488_ORIENTATION ILI9488_MADCTL_MX | ILI9488_MADCTL_MV
#endif
// XPT2046 Touch Screen calibration
#if EITHER(TFT_LVGL_UI_FSMC, TFT_480x320)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION 17880
@ -260,7 +211,7 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET 349
#endif
#elif ENABLED(FSMC_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION 12149
#endif
@ -273,7 +224,7 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET 256
#endif
#elif ENABLED(TFT_320x240) // TFT32/28
#elif ENABLED(TFT_320x240)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -12246
#endif

View File

@ -269,19 +269,11 @@
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
#ifndef TFT_WIDTH
#define TFT_WIDTH 480
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI
#endif
#if ENABLED(SPI_GRAPHICAL_TFT)
#if ENABLED(TFT_CLASSIC_UI)
// Emulated DOGM SPI
#ifndef GRAPHICAL_TFT_UPSCALE
#define GRAPHICAL_TFT_UPSCALE 3
@ -297,12 +289,12 @@
#define LCD_PINS_ENABLE PD13
#define LCD_PINS_RS PC6
#elif ENABLED(TFT_480x320_SPI)
#define TFT_DRIVER ST7796
#elif ENABLED(TFT_COLOR_UI)
#define TFT_BUFFER_SIZE 14400
#endif
#if EITHER(TFT_LVGL_UI_SPI, TFT_480x320_SPI)
// XPT2046 Touch Screen calibration
#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17253
#endif
@ -315,7 +307,7 @@
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -24
#endif
#elif ENABLED(SPI_GRAPHICAL_TFT)
#elif ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -11386
#endif

View File

@ -120,8 +120,9 @@
* Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu
* because Marlin uses the reset as a failsafe to revive a glitchy LCD.
*/
#define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13
#if HAS_FSMC_TFT
#define TFT_RESET_PIN PF11
#define TFT_BACKLIGHT_PIN PD13
#define FSMC_CS_PIN PD7 // NE4
#define FSMC_RS_PIN PD11 // A0
@ -129,6 +130,41 @@
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#define ANYCUBIC_TFT35
#else
#define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13
#endif
// XPT2046 Touch Screen calibration
#if ENABLED(TFT_COLOR_UI) || ENABLED(TFT_LVGL_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -17181
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 11434
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 501
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -9
#endif
#elif ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -12316
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 8981
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 340
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -20
#endif
#endif
#if NEED_TOUCH_PINS
#define TOUCH_CS_PIN PB7 // SPI2_NSS
#define TOUCH_SCK_PIN PA5 // SPI2_SCK

View File

@ -26,7 +26,7 @@ include_dir = Marlin
#
[common]
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft>
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
-<src/lcd/menu>
-<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
@ -227,7 +227,7 @@ HAS_WIRED_LCD = src_filter=+<src/lcd/lcdprint.cpp>
HAS_MARLINUI_HD44780 = src_filter=+<src/lcd/HD44780>
HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1
src_filter=+<src/lcd/dogm>
HAS_(FSMC|SPI)_TFT = src_filter=+<src/HAL/STM32/tft> +<src/HAL/STM32F1/tft>
HAS_(FSMC|SPI)_TFT = src_filter=+<src/HAL/STM32/tft> +<src/HAL/STM32F1/tft> +<src/lcd/tft_io>
HAS_FSMC_TFT = src_filter=+<src/HAL/STM32/tft/tft_fsmc.cpp> +<src/HAL/STM32F1/tft/tft_fsmc.cpp>
HAS_SPI_TFT = src_filter=+<src/HAL/STM32/tft/tft_spi.cpp> +<src/HAL/STM32F1/tft/tft_spi.cpp>
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
@ -909,8 +909,6 @@ build_flags = ${common_stm32f1.build_flags}
#
# MKS Robin Nano (STM32F103VET6)
# v1.2 - Emulated Graphical 128x64 (DOGM) UI and LVGL UI
# v2.0 - LVGL UI
#
[env:mks_robin_nano35]
platform = ${common_stm32f1.platform}