Browse Source

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 a071ebbfad.

* 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>
Victor Oliveira 3 years ago
parent
commit
faae900747
56 changed files with 1000 additions and 1476 deletions
  1. 39
    35
      Marlin/Configuration.h
  2. 1
    2
      Marlin/Configuration_adv.h
  3. 0
    7
      Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h
  4. 1
    1
      Marlin/src/HAL/LPC1768/tft/tft_spi.h
  5. 1
    1
      Marlin/src/HAL/STM32/tft/tft_fsmc.h
  6. 1
    1
      Marlin/src/HAL/STM32/tft/tft_spi.h
  7. 0
    7
      Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h
  8. 0
    13
      Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp
  9. 1
    1
      Marlin/src/HAL/STM32F1/tft/tft_fsmc.h
  10. 1
    1
      Marlin/src/HAL/STM32F1/tft/tft_spi.h
  11. 6
    0
      Marlin/src/core/macros.h
  12. 156
    20
      Marlin/src/inc/Conditionals_LCD.h
  13. 2
    2
      Marlin/src/inc/SanityCheck.h
  14. 6
    341
      Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp
  15. 27
    119
      Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp
  16. 5
    13
      Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h
  17. 2
    4
      Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp
  18. 12
    53
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  19. 4
    8
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  20. 0
    60
      Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp
  21. 0
    30
      Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h
  22. 14
    371
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  23. 1
    1
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
  24. 7
    2
      Marlin/src/lcd/scaled_tft.h
  25. 1
    158
      Marlin/src/lcd/tft/tft.cpp
  26. 2
    24
      Marlin/src/lcd/tft/tft.h
  27. 0
    30
      Marlin/src/lcd/tft/tft_io.h
  28. 4
    0
      Marlin/src/lcd/tft/touch.cpp
  29. 25
    4
      Marlin/src/lcd/tft_io/ili9328.h
  30. 11
    7
      Marlin/src/lcd/tft_io/ili9341.h
  31. 11
    7
      Marlin/src/lcd/tft_io/ili9488.h
  32. 24
    5
      Marlin/src/lcd/tft_io/r65105.h
  33. 131
    0
      Marlin/src/lcd/tft_io/ssd1963.h
  34. 12
    4
      Marlin/src/lcd/tft_io/st7735.h
  35. 11
    5
      Marlin/src/lcd/tft_io/st7789v.h
  36. 12
    4
      Marlin/src/lcd/tft_io/st7796s.h
  37. 226
    0
      Marlin/src/lcd/tft_io/tft_io.cpp
  38. 124
    0
      Marlin/src/lcd/tft_io/tft_io.h
  39. 1
    1
      Marlin/src/lcd/touch/touch_buttons.cpp
  40. 25
    6
      Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h
  41. 1
    1
      Marlin/src/pins/lpc1768/pins_MKS_SBASE.h
  42. 1
    1
      Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h
  43. 1
    1
      Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
  44. 2
    2
      Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h
  45. 6
    12
      Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h
  46. 9
    13
      Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h
  47. 1
    1
      Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h
  48. 4
    7
      Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h
  49. 2
    2
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h
  50. 1
    0
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
  51. 6
    55
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
  52. 5
    13
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
  53. 44
    8
      Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h
  54. 3
    3
      Marlin/src/pins/teensy4/pins_T41U5XBB.h
  55. 5
    5
      Marlin/src/pins/teensy4/pins_TEENSY41.h
  56. 2
    4
      platformio.ini

+ 39
- 35
Marlin/Configuration.h View File

@@ -2198,43 +2198,47 @@
2198 2198
 //=============================== Graphical TFTs ==============================
2199 2199
 //=============================================================================
2200 2200
 
2201
-//
2202
-// TFT display with optional touch screen
2203
-// Color Marlin UI with standard menu system
2204
-//
2205
-//#define TFT_320x240
2206
-//#define TFT_320x240_SPI
2207
-//#define TFT_480x320
2208
-//#define TFT_480x320_SPI
2209
-
2210
-//
2211
-// Skip autodetect and force specific TFT driver
2212
-// Mandatory for SPI screens with no MISO line
2213
-// Available drivers are: ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
2214
-//
2215
-//#define TFT_DRIVER AUTO
2216
-
2217
-//
2218
-// SPI display (MKS Robin Nano V2.0, MKS Gen L V2.0)
2219
-// Upscaled 128x64 Marlin UI
2220
-//
2221
-//#define SPI_GRAPHICAL_TFT
2201
+/**
2202
+ * TFT Type - Select your Display type
2203
+ *
2204
+ * Available options are:
2205
+ *   MKS_TS35_V2_0,
2206
+ *   MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35,
2207
+ *   MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R
2208
+ *   TFT_TRONXY_X5SA, ANYCUBIC_TFT35, LONGER_LK_TFT28
2209
+ *   TFT_GENERIC
2210
+ *
2211
+ * For TFT_GENERIC, you need to configure these 3 options:
2212
+ *   Driver:     TFT_DRIVER
2213
+ *               Current Drivers are: AUTO, ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
2214
+ *   Resolution: TFT_WIDTH and TFT_HEIGHT
2215
+ *   Interface:  TFT_INTERFACE_FSMC or TFT_INTERFACE_SPI
2216
+ */
2217
+//#define TFT_GENERIC
2222 2218
 
2223
-//
2224
-// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
2225
-// Upscaled 128x64 Marlin UI
2226
-//
2227
-//#define FSMC_GRAPHICAL_TFT
2219
+/**
2220
+ * TFT UI - User Interface Selection. Enable one of the following options:
2221
+ *
2222
+ *   TFT_CLASSIC_UI - Emulated DOGM - 128x64 Upscaled
2223
+ *   TFT_COLOR_UI   - Marlin Default Menus, Touch Friendly, using full TFT capabilities
2224
+ *   TFT_LVGL_UI    - A Modern UI using LVGL
2225
+ *
2226
+ *   For LVGL_UI also copy the 'assets' folder from the build directory to the
2227
+ *   root of your SD card, together with the compiled firmware.
2228
+ */
2229
+//#define TFT_CLASSIC_UI
2230
+//#define TFT_COLOR_UI
2231
+//#define TFT_LVGL_UI
2228 2232
 
2229
-//
2230
-// TFT LVGL UI
2231
-//
2232
-// Using default MKS icons and fonts from: https://git.io/JJvzK
2233
-// Just copy the 'assets' folder from the build directory to the
2234
-// root of your SD card, together with the compiled firmware.
2235
-//
2236
-//#define TFT_LVGL_UI_FSMC  // Robin nano v1.2 uses FSMC
2237
-//#define TFT_LVGL_UI_SPI   // Robin nano v2.0 uses SPI
2233
+/**
2234
+ * TFT Rotation. Set to one of the following values:
2235
+ *
2236
+ *   TFT_ROTATE_90,  TFT_ROTATE_90_MIRROR_X,  TFT_ROTATE_90_MIRROR_Y,
2237
+ *   TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y,
2238
+ *   TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
2239
+ *   TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
2240
+ */
2241
+//#define TFT_ROTATION TFT_NO_ROTATION
2238 2242
 
2239 2243
 //=============================================================================
2240 2244
 //============================  Other Controllers  ============================

+ 1
- 2
Marlin/Configuration_adv.h View File

@@ -1562,10 +1562,9 @@
1562 1562
 #endif
1563 1563
 
1564 1564
 //
1565
-// FSMC / SPI Graphical TFT
1565
+// Classic UI Options
1566 1566
 //
1567 1567
 #if TFT_SCALED_DOGLCD
1568
-  //#define GRAPHICAL_TFT_ROTATE_180
1569 1568
   //#define TFT_MARLINUI_COLOR 0xFFFF // White
1570 1569
   //#define TFT_MARLINBG_COLOR 0x0000 // Black
1571 1570
   //#define TFT_DISABLED_COLOR 0x0003 // Almost black

+ 0
- 7
Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h View File

@@ -24,10 +24,3 @@
24 24
 #if HAS_FSMC_TFT
25 25
   #error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768."
26 26
 #endif
27
-
28
-// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
29
-#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
30
-  #undef TOUCH_SCREEN
31
-  #undef TOUCH_SCREEN_CALIBRATION
32
-  #define HAS_TOUCH_XPT2046 1
33
-#endif

+ 1
- 1
Marlin/src/HAL/LPC1768/tft/tft_spi.h View File

@@ -36,7 +36,7 @@
36 36
 
37 37
 #define DATASIZE_8BIT    SSP_DATABIT_8
38 38
 #define DATASIZE_16BIT   SSP_DATABIT_16
39
-#define TFT_IO TFT_SPI
39
+#define TFT_IO_DRIVER TFT_SPI
40 40
 
41 41
 #define DMA_MINC_ENABLE 1
42 42
 #define DMA_MINC_DISABLE 0

+ 1
- 1
Marlin/src/HAL/STM32/tft/tft_fsmc.h View File

@@ -38,7 +38,7 @@
38 38
 
39 39
 #define DATASIZE_8BIT    SPI_DATASIZE_8BIT
40 40
 #define DATASIZE_16BIT   SPI_DATASIZE_16BIT
41
-#define TFT_IO TFT_FSMC
41
+#define TFT_IO_DRIVER TFT_FSMC
42 42
 
43 43
 #ifdef STM32F1xx
44 44
   #define __IS_DMA_ENABLED(__HANDLE__)      ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)

+ 1
- 1
Marlin/src/HAL/STM32/tft/tft_spi.h View File

@@ -38,7 +38,7 @@
38 38
 
39 39
 #define DATASIZE_8BIT    SPI_DATASIZE_8BIT
40 40
 #define DATASIZE_16BIT   SPI_DATASIZE_16BIT
41
-#define TFT_IO TFT_SPI
41
+#define TFT_IO_DRIVER TFT_SPI
42 42
 
43 43
 class TFT_SPI {
44 44
 private:

+ 0
- 7
Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h View File

@@ -25,10 +25,3 @@
25 25
   //#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
26 26
   #undef SD_CHECK_AND_RETRY
27 27
 #endif
28
-
29
-// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
30
-#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
31
-  #undef TOUCH_SCREEN
32
-  #undef TOUCH_SCREEN_CALIBRATION
33
-  #define HAS_TOUCH_XPT2046 1
34
-#endif

+ 0
- 13
Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp View File

@@ -89,25 +89,12 @@ void TFT_FSMC::Init() {
89 89
   uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN;
90 90
   uint32_t controllerAddress;
91 91
 
92
-  #if PIN_EXISTS(TFT_BACKLIGHT)
93
-    OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
94
-  #endif
95
-
96 92
   #if ENABLED(LCD_USE_DMA_FSMC)
97 93
     dma_init(FSMC_DMA_DEV);
98 94
     dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
99 95
     dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
100 96
   #endif
101 97
 
102
-  #if PIN_EXISTS(TFT_RESET)
103
-    OUT_WRITE(TFT_RESET_PIN, HIGH);
104
-    delay(100);
105
-  #endif
106
-
107
-  #if PIN_EXISTS(TFT_BACKLIGHT)
108
-    OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
109
-  #endif
110
-
111 98
   struct fsmc_nor_psram_reg_map* fsmcPsramRegion;
112 99
 
113 100
   if (fsmcInit) return;

+ 1
- 1
Marlin/src/HAL/STM32F1/tft/tft_fsmc.h View File

@@ -32,7 +32,7 @@
32 32
 
33 33
 #define DATASIZE_8BIT    DMA_SIZE_8BITS
34 34
 #define DATASIZE_16BIT   DMA_SIZE_16BITS
35
-#define TFT_IO TFT_FSMC
35
+#define TFT_IO_DRIVER TFT_FSMC
36 36
 
37 37
 typedef struct {
38 38
   __IO uint16_t REG;

+ 1
- 1
Marlin/src/HAL/STM32F1/tft/tft_spi.h View File

@@ -34,7 +34,7 @@
34 34
 
35 35
 #define DATASIZE_8BIT    DATA_SIZE_8BIT
36 36
 #define DATASIZE_16BIT   DATA_SIZE_16BIT
37
-#define TFT_IO TFT_SPI
37
+#define TFT_IO_DRIVER TFT_SPI
38 38
 
39 39
 #define DMA_MINC_ENABLE 1
40 40
 #define DMA_MINC_DISABLE 0

+ 6
- 0
Marlin/src/core/macros.h View File

@@ -452,6 +452,12 @@
452 452
 #define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
453 453
 #define _END_OF_ARGUMENTS_() 0
454 454
 
455
+
456
+// Simple Inline IF Macros, friendly to use in other macro definitions
457
+#define IF(O, A, B) ((O) ? (A) : (B))
458
+#define IF_0(O, A) IF(O, A, 0)
459
+#define IF_1(O, A) IF(O, A, 1)
460
+
455 461
 //
456 462
 // REPEAT core macros. Recurse N times with ascending I.
457 463
 //

+ 156
- 20
Marlin/src/inc/Conditionals_LCD.h View File

@@ -311,13 +311,40 @@
311 311
   #define IS_ULTIPANEL
312 312
 #endif
313 313
 
314
+// Compatibility
315
+#if ENABLED(FSMC_GRAPHICAL_TFT)
316
+  #define TFT_CLASSIC_UI
317
+  #define TFT_INTERFACE_FSMC
318
+  #define TFT_GENERIC
319
+#elif ENABLED(SPI_GRAPHICAL_TFT)
320
+  #define TFT_CLASSIC_UI
321
+  #define TFT_INTERFACE_SPI
322
+  #define TFT_GENERIC
323
+#elif EITHER(TFT_320x240, TFT_480x320)
324
+  #define TFT_COLOR_UI
325
+  #define TFT_INTERFACE_FSMC
326
+  #define TFT_GENERIC
327
+#elif EITHER(TFT_320x240_SPI, TFT_480x320_SPI)
328
+  #define TFT_COLOR_UI
329
+  #define TFT_INTERFACE_SPI
330
+  #define TFT_GENERIC
331
+#elif ENABLED(TFT_LVGL_UI_FSMC)
332
+  #define TFT_LVGL_UI
333
+  #define TFT_INTERFACE_FSMC
334
+  #define TFT_GENERIC
335
+#elif ENABLED(TFT_LVGL_UI_SPI)
336
+  #define TFT_LVGL_UI
337
+  #define TFT_INTERFACE_SPI
338
+  #define TFT_GENERIC
339
+#endif
340
+
314 341
 // FSMC/SPI TFT Panels (LVGL)
315
-#if EITHER(TFT_LVGL_UI_SPI, TFT_LVGL_UI_FSMC)
342
+#if ENABLED(TFT_LVGL_UI)
316 343
   #define HAS_TFT_LVGL_UI 1
317 344
 #endif
318 345
 
319 346
 // FSMC/SPI TFT Panels
320
-#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT)
347
+#if ENABLED(TFT_CLASSIC_UI)
321 348
   #define TFT_SCALED_DOGLCD 1
322 349
 #endif
323 350
 
@@ -325,32 +352,16 @@
325 352
   #define DOGLCD
326 353
   #define IS_ULTIPANEL
327 354
   #define DELAYED_BACKLIGHT_INIT
328
-#elif ENABLED(TFT_LVGL_UI_SPI)
355
+#elif ENABLED(TFT_LVGL_UI)
329 356
   #define DELAYED_BACKLIGHT_INIT
330 357
 #endif
331 358
 
332
-// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h
333
-#if ANY(TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC, FSMC_GRAPHICAL_TFT)
334
-  #define HAS_FSMC_TFT 1
335
-#elif ANY(TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI, SPI_GRAPHICAL_TFT)
336
-  #define HAS_SPI_TFT 1
337
-#endif
338
-
339 359
 // Color UI
340
-#if ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI)
360
+#if ENABLED(TFT_COLOR_UI)
341 361
   #define HAS_GRAPHICAL_TFT 1
342 362
   #define IS_ULTIPANEL
343 363
 #endif
344 364
 
345
-// Fewer lines with touch buttons on-screen
346
-#if EITHER(TFT_320x240, TFT_320x240_SPI)
347
-  #define HAS_UI_320x240 1
348
-  #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
349
-#elif EITHER(TFT_480x320, TFT_480x320_SPI)
350
-  #define HAS_UI_480x320 1
351
-  #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
352
-#endif
353
-
354 365
 /**
355 366
  * I2C Panels
356 367
  */
@@ -810,3 +821,128 @@
810 821
 #ifndef EXTRUDE_MINTEMP
811 822
   #define EXTRUDE_MINTEMP 170
812 823
 #endif
824
+
825
+/**
826
+ * TFT Displays
827
+ *
828
+ * Configure parameters for TFT displays:
829
+ *  - TFT_DEFAULT_ORIENTATION
830
+ *  - TFT_DRIVER
831
+ *  - TFT_WIDTH
832
+ *  - TFT_HEIGHT
833
+ *  - TFT_INTERFACE_(SPI|FSMC)
834
+ *  - TFT_COLOR
835
+ *  - GRAPHICAL_TFT_UPSCALE
836
+ */
837
+#if ENABLED(MKS_TS35_V2_0)
838
+  // Most common: ST7796
839
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
840
+  #define TFT_WIDTH  480
841
+  #define TFT_HEIGHT 320
842
+  #define TFT_INTERFACE_SPI
843
+  #define GRAPHICAL_TFT_UPSCALE 3
844
+#elif ENABLED(MKS_ROBIN_TFT24)
845
+  // Most common: ST7789
846
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
847
+  #define TFT_WIDTH  320
848
+  #define TFT_HEIGHT 240
849
+  #define TFT_INTERFACE_FSMC
850
+  #define GRAPHICAL_TFT_UPSCALE 2
851
+#elif ENABLED(MKS_ROBIN_TFT28)
852
+  // Most common: ST7789
853
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
854
+  #define TFT_WIDTH  320
855
+  #define TFT_HEIGHT 240
856
+  #define TFT_INTERFACE_FSMC
857
+  #define GRAPHICAL_TFT_UPSCALE 2
858
+#elif ENABLED(MKS_ROBIN_TFT32)
859
+  // Most common: ST7789
860
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
861
+  #define TFT_WIDTH  320
862
+  #define TFT_HEIGHT 240
863
+  #define TFT_INTERFACE_FSMC
864
+  #define GRAPHICAL_TFT_UPSCALE 2
865
+#elif ENABLED(MKS_ROBIN_TFT35)
866
+  // Most common: ILI9488
867
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
868
+  #define TFT_WIDTH  480
869
+  #define TFT_HEIGHT 320
870
+  #define TFT_INTERFACE_FSMC
871
+  #define GRAPHICAL_TFT_UPSCALE 3
872
+#elif ENABLED(MKS_ROBIN_TFT43)
873
+  #define TFT_DEFAULT_ORIENTATION 0
874
+  #define TFT_DRIVER SSD1963
875
+  #define TFT_WIDTH  480
876
+  #define TFT_HEIGHT 272
877
+  #define TFT_INTERFACE_FSMC
878
+  #define GRAPHICAL_TFT_UPSCALE 2
879
+#elif ENABLED(MKS_ROBIN_TFT_V1_1R)
880
+  // ILI9328 or R61505
881
+  #define TFT_DEFAULT_ORIENTATION (TFT_INVERT_X | TFT_INVERT_Y | TFT_EXCHANGE_XY)
882
+  #define TFT_WIDTH  320
883
+  #define TFT_HEIGHT 240
884
+  #define TFT_INTERFACE_FSMC
885
+  #define GRAPHICAL_TFT_UPSCALE 2
886
+#elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35)
887
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
888
+  #define TFT_DRIVER ILI9488
889
+  #define TFT_WIDTH  480
890
+  #define TFT_HEIGHT 320
891
+  #define TFT_INTERFACE_FSMC
892
+  #define GRAPHICAL_TFT_UPSCALE 3
893
+#elif ENABLED(LONGER_LK_TFT28)
894
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
895
+  #define TFT_WIDTH  320
896
+  #define TFT_HEIGHT 240
897
+  #define TFT_INTERFACE_FSMC
898
+  #define GRAPHICAL_TFT_UPSCALE 2
899
+#elif ENABLED(TFT_GENERIC)
900
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
901
+#endif
902
+
903
+// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h
904
+#if ENABLED(TFT_INTERFACE_FSMC)
905
+  #define HAS_FSMC_TFT 1
906
+  #if ENABLED(TFT_CLASSIC_UI)
907
+    #define FSMC_GRAPHICAL_TFT
908
+  #elif ENABLED(TFT_LVGL_UI)
909
+    #define TFT_LVGL_UI_FSMC
910
+  #endif
911
+#elif ENABLED(TFT_INTERFACE_SPI)
912
+  #define HAS_SPI_TFT 1
913
+  #if ENABLED(TFT_CLASSIC_UI)
914
+    #define SPI_GRAPHICAL_TFT
915
+  #elif ENABLED(TFT_LVGL_UI)
916
+    #define TFT_LVGL_UI_SPI
917
+  #endif
918
+#endif
919
+
920
+#if ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 240
921
+  #if ENABLED(TFT_INTERFACE_SPI)
922
+    #define TFT_320x240_SPI
923
+  #elif ENABLED(TFT_INTERFACE_FSMC)
924
+    #define TFT_320x240
925
+  #endif
926
+#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 320
927
+  #if ENABLED(TFT_INTERFACE_SPI)
928
+    #define TFT_480x320_SPI
929
+  #elif ENABLED(TFT_INTERFACE_FSMC)
930
+    #define TFT_480x320
931
+  #endif
932
+#endif
933
+
934
+// Fewer lines with touch buttons on-screen
935
+#if EITHER(TFT_320x240, TFT_320x240_SPI)
936
+  #define HAS_UI_320x240 1
937
+  #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
938
+#elif EITHER(TFT_480x320, TFT_480x320_SPI)
939
+  #define HAS_UI_480x320 1
940
+  #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
941
+#endif
942
+
943
+// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
944
+#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
945
+  #undef TOUCH_SCREEN
946
+  #undef TOUCH_SCREEN_CALIBRATION
947
+  #define HAS_TOUCH_XPT2046 1
948
+#endif

+ 2
- 2
Marlin/src/inc/SanityCheck.h View File

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

Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp → Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp View File

@@ -66,12 +66,7 @@
66 66
   #define HAS_LCD_IO 1
67 67
 #endif
68 68
 
69
-#if ENABLED(SPI_GRAPHICAL_TFT)
70
-  #include HAL_PATH(../../HAL, tft/tft_spi.h)
71
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
72
-  #include HAL_PATH(../../HAL, tft/tft_fsmc.h)
73
-#endif
74
-
69
+#include "../tft_io/tft_io.h"
75 70
 TFT_IO tftio;
76 71
 
77 72
 #define WIDTH  LCD_PIXEL_WIDTH
@@ -132,299 +127,10 @@ TFT_IO tftio;
132 127
   #define TFT_BTOKMENU_COLOR COLOR_RED
133 128
 #endif
134 129
 
135
-static uint32_t lcd_id = 0;
136
-
137
-#define ST7789V_CASET       0x2A   /* Column address register */
138
-#define ST7789V_RASET       0x2B   /* Row address register */
139
-#define ST7789V_WRITE_RAM   0x2C   /* Write data to GRAM */
140
-
141
-
142
-/* Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X */
143
-#define ILI9328_HASET       0x20   /* Horizontal GRAM address register (0-255) */
144
-#define ILI9328_VASET       0x21   /* Vertical GRAM address register (0-511)*/
145
-#define ILI9328_WRITE_RAM   0x22   /* Write data to GRAM */
146
-
147
-#define ILI9328_HASTART     0x50   /* Horizontal address start position (0-255) */
148
-#define ILI9328_HAEND       0x51   /* Horizontal address end position (0-255) */
149
-#define ILI9328_VASTART     0x52   /* Vertical address start position (0-511) */
150
-#define ILI9328_VAEND       0x53   /* Vertical address end position (0-511) */
151
-
152
-static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
153
-  #if HAS_LCD_IO
154
-    tftio.DataTransferBegin(DATASIZE_8BIT);
155
-    #define IO_REG_DATA(R,D) do { tftio.WriteReg(R); tftio.WriteData(D); }while(0)
156
-  #else
157
-    #define IO_REG_DATA(R,D) do { u8g_WriteByte(u8g, dev, R); u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&D); }while(0)
158
-  #endif
159
-
160
-  #if NONE(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI)
161
-    u8g_SetAddress(u8g, dev, 0);
162
-  #endif
163
-
164
-  IO_REG_DATA(ILI9328_HASTART, Ymin);
165
-  IO_REG_DATA(ILI9328_HAEND,   Ymax);
166
-  IO_REG_DATA(ILI9328_VASTART, Xmin);
167
-  IO_REG_DATA(ILI9328_VAEND,   Xmax);
168
-
169
-  IO_REG_DATA(ILI9328_HASET,   Ymin);
170
-  IO_REG_DATA(ILI9328_VASET,   Xmin);
171
-
172
-  #if HAS_LCD_IO
173
-    tftio.WriteReg(ILI9328_WRITE_RAM);
174
-    tftio.DataTransferEnd();
175
-  #else
176
-    u8g_WriteByte(u8g, dev, ILI9328_WRITE_RAM);
177
-    u8g_SetAddress(u8g, dev, 1);
178
-  #endif
179
-}
180
-
181
-static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
182
-  #if HAS_LCD_IO
183
-    tftio.DataTransferBegin(DATASIZE_8BIT);
184
-    tftio.WriteReg(ST7789V_CASET);
185
-    tftio.WriteData((Xmin >> 8) & 0xFF);
186
-    tftio.WriteData(Xmin & 0xFF);
187
-    tftio.WriteData((Xmax >> 8) & 0xFF);
188
-    tftio.WriteData(Xmax & 0xFF);
189
-
190
-    tftio.WriteReg(ST7789V_RASET);
191
-    tftio.WriteData((Ymin >> 8) & 0xFF);
192
-    tftio.WriteData(Ymin & 0xFF);
193
-    tftio.WriteData((Ymax >> 8) & 0xFF);
194
-    tftio.WriteData(Ymax & 0xFF);
195
-
196
-    tftio.WriteReg(ST7789V_WRITE_RAM);
197
-    tftio.DataTransferEnd();
198
-  #else
199
-    u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_CASET); u8g_SetAddress(u8g, dev, 1);
200
-    u8g_WriteByte(u8g, dev, (Xmin >> 8) & 0xFF);
201
-    u8g_WriteByte(u8g, dev, Xmin & 0xFF);
202
-    u8g_WriteByte(u8g, dev, (Xmax >> 8) & 0xFF);
203
-    u8g_WriteByte(u8g, dev, Xmax & 0xFF);
204
-
205
-    u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_RASET); u8g_SetAddress(u8g, dev, 1);
206
-    u8g_WriteByte(u8g, dev, (Ymin >> 8) & 0xFF);
207
-    u8g_WriteByte(u8g, dev, Ymin & 0xFF);
208
-    u8g_WriteByte(u8g, dev, (Ymax >> 8) & 0xFF);
209
-    u8g_WriteByte(u8g, dev, Ymax & 0xFF);
210
-
211
-    u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_WRITE_RAM); u8g_SetAddress(u8g, dev, 1);
212
-  #endif
130
+static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
131
+  tftio.set_window(Xmin, Ymin, Xmax, Ymax);
213 132
 }
214 133
 
215
-static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {}
216
-void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none;
217
-
218
-#define ESC_REG(x)      0xFFFF, 0x00FF & (uint16_t)x
219
-#define ESC_DELAY(x)    0xFFFF, 0x8000 | (x & 0x7FFF)
220
-#define ESC_END         0xFFFF, 0x7FFF
221
-#define ESC_FFFF        0xFFFF, 0xFFFF
222
-
223
-#if HAS_LCD_IO
224
-  void writeEscSequence(const uint16_t *sequence) {
225
-    uint16_t data;
226
-    for (;;) {
227
-      data = *sequence++;
228
-      if (data != 0xFFFF) {
229
-        tftio.WriteData(data);
230
-        continue;
231
-      }
232
-      data = *sequence++;
233
-      if (data == 0x7FFF) return;
234
-      if (data == 0xFFFF) {
235
-        tftio.WriteData(data);
236
-      } else if (data & 0x8000) {
237
-        delay(data & 0x7FFF);
238
-      } else if ((data & 0xFF00) == 0) {
239
-        tftio.WriteReg(data);
240
-      }
241
-    }
242
-  }
243
-  #define WRITE_ESC_SEQUENCE(V) writeEscSequence(V)
244
-  #define WRITE_ESC_SEQUENCE16(V) writeEscSequence(V)
245
-#else
246
-  void writeEscSequence8(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) {
247
-    uint16_t data;
248
-    u8g_SetAddress(u8g, dev, 1);
249
-    for (;;) {
250
-      data = *sequence++;
251
-      if (data != 0xFFFF) {
252
-        u8g_WriteByte(u8g, dev, data & 0xFF);
253
-        continue;
254
-      }
255
-      data = *sequence++;
256
-      if (data == 0x7FFF) return;
257
-      if (data == 0xFFFF) {
258
-        u8g_WriteByte(u8g, dev, data & 0xFF);
259
-      } else if (data & 0x8000) {
260
-        delay(data & 0x7FFF);
261
-      } else if ((data & 0xFF00) == 0) {
262
-        u8g_SetAddress(u8g, dev, 0);
263
-        u8g_WriteByte(u8g, dev, data & 0xFF);
264
-        u8g_SetAddress(u8g, dev, 1);
265
-      }
266
-    }
267
-  }
268
-
269
-  #define WRITE_ESC_SEQUENCE(V) writeEscSequence8(u8g, dev, V)
270
-
271
-  void writeEscSequence16(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) {
272
-    uint16_t data;
273
-    u8g_SetAddress(u8g, dev, 0);
274
-    for (;;) {
275
-      data = *sequence++;
276
-      if (data != 0xFFFF) {
277
-        u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data);
278
-        continue;
279
-      }
280
-      data = *sequence++;
281
-      if (data == 0x7FFF) return;
282
-      if (data == 0xFFFF) {
283
-        u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data);
284
-      } else if (data & 0x8000) {
285
-        delay(data & 0x7FFF);
286
-      } else if ((data & 0xFF00) == 0) {
287
-        u8g_WriteByte(u8g, dev, data & 0xFF);
288
-      }
289
-    }
290
-    u8g_SetAddress(u8g, dev, 1);
291
-  }
292
-
293
-  #define WRITE_ESC_SEQUENCE16(V) writeEscSequence16(u8g, dev, V)
294
-#endif
295
-
296
-static const uint16_t st7789v_init[] = {
297
-  ESC_REG(0x0010), ESC_DELAY(10),
298
-  ESC_REG(0x0001), ESC_DELAY(200),
299
-  ESC_REG(0x0011), ESC_DELAY(120),
300
-  ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0060, 0x00A0),
301
-  ESC_REG(0x003A), 0x0055,
302
-  ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F,
303
-  ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF,
304
-  ESC_REG(0x00B2), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033,
305
-  ESC_REG(0x00B7), 0x0035,
306
-  ESC_REG(0x00BB), 0x001F,
307
-  ESC_REG(0x00C0), 0x002C,
308
-  ESC_REG(0x00C2), 0x0001, 0x00C3,
309
-  ESC_REG(0x00C4), 0x0020,
310
-  ESC_REG(0x00C6), 0x000F,
311
-  ESC_REG(0x00D0), 0x00A4, 0x00A1,
312
-  ESC_REG(0x0029),
313
-  ESC_REG(0x0011),
314
-  ESC_END
315
-};
316
-
317
-static const uint16_t ili9328_init[] = {
318
-  ESC_REG(0x0001), 0x0100,
319
-  ESC_REG(0x0002), 0x0400,
320
-  ESC_REG(0x0003), 0x1038,
321
-  ESC_REG(0x0004), 0x0000,
322
-  ESC_REG(0x0008), 0x0202,
323
-  ESC_REG(0x0009), 0x0000,
324
-  ESC_REG(0x000A), 0x0000,
325
-  ESC_REG(0x000C), 0x0000,
326
-  ESC_REG(0x000D), 0x0000,
327
-  ESC_REG(0x000F), 0x0000,
328
-  ESC_REG(0x0010), 0x0000,
329
-  ESC_REG(0x0011), 0x0007,
330
-  ESC_REG(0x0012), 0x0000,
331
-  ESC_REG(0x0013), 0x0000,
332
-  ESC_REG(0x0007), 0x0001,
333
-  ESC_DELAY(200),
334
-  ESC_REG(0x0010), 0x1690,
335
-  ESC_REG(0x0011), 0x0227,
336
-  ESC_DELAY(50),
337
-  ESC_REG(0x0012), 0x008C,
338
-  ESC_DELAY(50),
339
-  ESC_REG(0x0013), 0x1500,
340
-  ESC_REG(0x0029), 0x0004,
341
-  ESC_REG(0x002B), 0x000D,
342
-  ESC_DELAY(50),
343
-  ESC_REG(0x0050), 0x0000,
344
-  ESC_REG(0x0051), 0x00EF,
345
-  ESC_REG(0x0052), 0x0000,
346
-  ESC_REG(0x0053), 0x013F,
347
-  ESC_REG(0x0020), 0x0000,
348
-  ESC_REG(0x0021), 0x0000,
349
-  ESC_REG(0x0060), 0x2700,
350
-  ESC_REG(0x0061), 0x0001,
351
-  ESC_REG(0x006A), 0x0000,
352
-  ESC_REG(0x0080), 0x0000,
353
-  ESC_REG(0x0081), 0x0000,
354
-  ESC_REG(0x0082), 0x0000,
355
-  ESC_REG(0x0083), 0x0000,
356
-  ESC_REG(0x0084), 0x0000,
357
-  ESC_REG(0x0085), 0x0000,
358
-  ESC_REG(0x0090), 0x0010,
359
-  ESC_REG(0x0092), 0x0600,
360
-  ESC_REG(0x0007), 0x0133,
361
-  ESC_REG(0x0022),
362
-  ESC_END
363
-};
364
-
365
-static const uint16_t ili9341_init[] = {
366
-  ESC_REG(0x0010), ESC_DELAY(10),
367
-  ESC_REG(0x0001), ESC_DELAY(200),
368
-  ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0028, 0x00E8),
369
-  ESC_REG(0x003A), 0x0055,
370
-  ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F,
371
-  ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF,
372
-  ESC_REG(0x00C5), 0x003E, 0x0028,
373
-  ESC_REG(0x00C7), 0x0086,
374
-  ESC_REG(0x00B1), 0x0000, 0x0018,
375
-  ESC_REG(0x00C0), 0x0023,
376
-  ESC_REG(0x00C1), 0x0010,
377
-  ESC_REG(0x0029),
378
-  ESC_REG(0x0011),
379
-  ESC_DELAY(100),
380
-  ESC_END
381
-};
382
-
383
-static const uint16_t ili9488_init[] = {
384
-  ESC_REG(0x00E0), 0x0000, 0x0007, 0x000F, 0x000D, 0x001B, 0x000A, 0x003C, 0x0078, 0x004A, 0x0007, 0x000E, 0x0009, 0x001B, 0x001E, 0x000F,
385
-  ESC_REG(0x00E1), 0x0000, 0x0022, 0x0024, 0x0006, 0x0012, 0x0007, 0x0036, 0x0047, 0x0047, 0x0006, 0x000A, 0x0007, 0x0030, 0x0037, 0x000F,
386
-  ESC_REG(0x00C0), 0x0010, 0x0010,
387
-  ESC_REG(0x00C1), 0x0041,
388
-  ESC_REG(0x00C5), 0x0000, 0x0022, 0x0080,
389
-  ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00A8, 0x0068),
390
-  ESC_REG(0x003A), 0x0055,
391
-  ESC_REG(0x00B0), 0x0000,
392
-  ESC_REG(0x00B1), 0x00B0, 0x0011,
393
-  ESC_REG(0x00B4), 0x0002,
394
-  ESC_REG(0x00B6), 0x0002, 0x0042,
395
-  ESC_REG(0x00B7), 0x00C6,
396
-  ESC_REG(0x00E9), 0x0000,
397
-  ESC_REG(0x00F0), 0x00A9, 0x0051, 0x002C, 0x0082,
398
-  ESC_REG(0x0029),
399
-  ESC_REG(0x0011),
400
-  ESC_DELAY(100),
401
-  ESC_END
402
-};
403
-
404
-static const uint16_t st7796_init[] = {
405
-  ESC_REG(0x0010), ESC_DELAY(120),
406
-  ESC_REG(0x0001), ESC_DELAY(120),
407
-  ESC_REG(0x0011), ESC_DELAY(120),
408
-  ESC_REG(0x00F0), 0x00C3,
409
-  ESC_REG(0x00F0), 0x0096,
410
-  ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00E8, 0x0028),
411
-  ESC_REG(0x003A), 0x0055,
412
-  ESC_REG(0x00B4), 0x0001,
413
-  ESC_REG(0x00B7), 0x00C6,
414
-  ESC_REG(0x00E8), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,
415
-  ESC_REG(0x00C1), 0x0006,
416
-  ESC_REG(0x00C2), 0x00A7,
417
-  ESC_REG(0x00C5), 0x0018,
418
-  ESC_REG(0x00E0), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0015, 0x002F, 0x0054, 0x0042, 0x003C, 0x0017, 0x0014, 0x0018, 0x001B,
419
-  ESC_REG(0x00E1), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0003, 0x002D, 0x0043, 0x0042, 0x003B, 0x0016, 0x0014, 0x0017, 0x001B,
420
-  ESC_REG(0x00F0), 0x003C,
421
-  ESC_REG(0x00F0), 0x0069, ESC_DELAY(120),
422
-  ESC_REG(0x0029),
423
-  ESC_REG(0x0011),
424
-  ESC_DELAY(100),
425
-  ESC_END
426
-};
427
-
428 134
 #if HAS_TOUCH_XPT2046
429 135
 
430 136
   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
640 346
 
641 347
   switch (msg) {
642 348
     case U8G_DEV_MSG_INIT:
643
-      dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, &lcd_id);
644
-      tftio.DataTransferBegin(DATASIZE_8BIT);
645
-      switch (lcd_id & 0xFFFF) {
646
-        case 0x8552:   // ST7789V
647
-          WRITE_ESC_SEQUENCE(st7789v_init);
648
-          setWindow = setWindow_st7789v;
649
-          break;
650
-        case 0x9328:  // ILI9328
651
-          WRITE_ESC_SEQUENCE16(ili9328_init);
652
-          setWindow = setWindow_ili9328;
653
-          break;
654
-        case 0x9341:   // ILI9341
655
-          WRITE_ESC_SEQUENCE(ili9341_init);
656
-          setWindow = setWindow_st7789v;
657
-          break;
658
-        case 0x8066:   // Anycubic / TronXY TFTs (480x320)
659
-          WRITE_ESC_SEQUENCE(ili9488_init);
660
-          setWindow = setWindow_st7789v;
661
-          break;
662
-        case 0x7796:
663
-          WRITE_ESC_SEQUENCE(st7796_init);
664
-          setWindow = setWindow_st7789v;
665
-          break;
666
-        case 0x9488:
667
-          WRITE_ESC_SEQUENCE(ili9488_init);
668
-          setWindow = setWindow_st7789v;
669
-        case 0x0404:  // No connected display on FSMC
670
-          lcd_id = 0;
671
-          return 0;
672
-        case 0xFFFF:  // No connected display on SPI
673
-          lcd_id = 0;
674
-          return 0;
675
-        default:
676
-          setWindow = (lcd_id & 0xFF000000) ? setWindow_st7789v : setWindow_ili9328;
677
-          break;
678
-      }
679
-      tftio.DataTransferEnd();
349
+      dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, NULL);
350
+      tftio.Init();
351
+      tftio.InitTFT();
680 352
 
681 353
       if (preinit) {
682 354
         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
771 443
     case U8G_COM_MSG_STOP: break;
772 444
     case U8G_COM_MSG_INIT:
773 445
       u8g_SetPIOutput(u8g, U8G_PI_RESET);
774
-
775 446
       u8g_Delay(50);
776
-
777
-      tftio.Init();
778
-
779
-      if (arg_ptr) {
780
-        *((uint32_t *)arg_ptr) = tftio.GetID();
781
-      }
782 447
       isCommand = 0;
783 448
       break;
784 449
 

+ 27
- 119
Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../../../inc/MarlinConfigPre.h"
24 24
 
25
-#if ENABLED(TFT_LVGL_UI_SPI)
25
+#if HAS_TFT_LVGL_UI
26 26
 
27 27
 #include "SPI_TFT.h"
28 28
 #include "pic_manager.h"
@@ -32,6 +32,8 @@
32 32
 
33 33
 #include <SPI.h>
34 34
 
35
+#include "draw_ui.h"
36
+
35 37
 TFT SPI_TFT;
36 38
 
37 39
 // use SPI1 for the spi tft.
@@ -39,142 +41,48 @@ void TFT::spi_init(uint8_t spiRate) {
39 41
   tftio.Init();
40 42
 }
41 43
 
42
-void TFT::LCD_WR_REG(uint8_t cmd) {
43
-  tftio.WriteReg(cmd);
44
-}
45
-
46
-void TFT::LCD_WR_DATA(uint8_t data) {
47
-  tftio.WriteData(data);
48
-}
49
-
50 44
 void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) {
51 45
   if ((x > 480) || (y > 320)) return;
52 46
 
53
-  SetWindows(x, y, 1, 1);
47
+  setWindow(x, y, 1, 1);
54 48
   tftio.WriteMultiple(point, (uint16_t)1);
55 49
 }
56 50
 
57
-void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
58
-  tftio.DataTransferBegin(DATASIZE_8BIT);
59
-
60
-  LCD_WR_REG(0x2A);
61
-  LCD_WR_DATA(x >> 8);
62
-  LCD_WR_DATA(x);
63
-  LCD_WR_DATA((x + with - 1) >> 8);
64
-  LCD_WR_DATA((x + with - 1));
65
-
66
-  LCD_WR_REG(0x2B);
67
-  LCD_WR_DATA(y >> 8);
68
-  LCD_WR_DATA(y);
69
-  LCD_WR_DATA((y + height - 1) >> 8);
70
-  LCD_WR_DATA(y + height - 1);
71
-
72
-  LCD_WR_REG(0X2C);
73
-
74
-  tftio.DataTransferEnd();
51
+void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
52
+  tftio.set_window(x, y, (x + with - 1), (y + height - 1));
75 53
 }
76 54
 
77 55
 void TFT::LCD_init() {
78
-  TFT_BLK_L;
79
-  TFT_RST_H;
80
-  delay(150);
81
-  TFT_RST_L;
82
-  delay(150);
83
-  TFT_RST_H;
84
-
85
-  tftio.DataTransferBegin(DATASIZE_8BIT);
86
-
87
-  delay(120);
88
-  LCD_WR_REG(0x11);
89
-  delay(120);
90
-
91
-  LCD_WR_REG(0xF0);
92
-  LCD_WR_DATA(0xC3);
93
-  LCD_WR_REG(0xF0);
94
-  LCD_WR_DATA(0x96);
95
-
96
-  LCD_WR_REG(0x36);
97
-  LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80));
98
-  LCD_WR_REG(0x3A);
99
-  LCD_WR_DATA(0x55);
100
-
101
-  LCD_WR_REG(0xB4);
102
-  LCD_WR_DATA(0x01);
103
-  LCD_WR_REG(0xB7);
104
-  LCD_WR_DATA(0xC6);
105
-  LCD_WR_REG(0xE8);
106
-  LCD_WR_DATA(0x40);
107
-  LCD_WR_DATA(0x8A);
108
-  LCD_WR_DATA(0x00);
109
-  LCD_WR_DATA(0x00);
110
-  LCD_WR_DATA(0x29);
111
-  LCD_WR_DATA(0x19);
112
-  LCD_WR_DATA(0xA5);
113
-  LCD_WR_DATA(0x33);
114
-  LCD_WR_REG(0xC1);
115
-  LCD_WR_DATA(0x06);
116
-  LCD_WR_REG(0xC2);
117
-  LCD_WR_DATA(0xA7);
118
-  LCD_WR_REG(0xC5);
119
-  LCD_WR_DATA(0x18);
120
-  LCD_WR_REG(0xE0);     // Positive Voltage Gamma Control
121
-  LCD_WR_DATA(0xF0);
122
-  LCD_WR_DATA(0x09);
123
-  LCD_WR_DATA(0x0B);
124
-  LCD_WR_DATA(0x06);
125
-  LCD_WR_DATA(0x04);
126
-  LCD_WR_DATA(0x15);
127
-  LCD_WR_DATA(0x2F);
128
-  LCD_WR_DATA(0x54);
129
-  LCD_WR_DATA(0x42);
130
-  LCD_WR_DATA(0x3C);
131
-  LCD_WR_DATA(0x17);
132
-  LCD_WR_DATA(0x14);
133
-  LCD_WR_DATA(0x18);
134
-  LCD_WR_DATA(0x1B);
135
-  LCD_WR_REG(0xE1);     // Negative Voltage Gamma Control
136
-  LCD_WR_DATA(0xF0);
137
-  LCD_WR_DATA(0x09);
138
-  LCD_WR_DATA(0x0B);
139
-  LCD_WR_DATA(0x06);
140
-  LCD_WR_DATA(0x04);
141
-  LCD_WR_DATA(0x03);
142
-  LCD_WR_DATA(0x2D);
143
-  LCD_WR_DATA(0x43);
144
-  LCD_WR_DATA(0x42);
145
-  LCD_WR_DATA(0x3B);
146
-  LCD_WR_DATA(0x16);
147
-  LCD_WR_DATA(0x14);
148
-  LCD_WR_DATA(0x17);
149
-  LCD_WR_DATA(0x1B);
150
-  LCD_WR_REG(0xF0);
151
-  LCD_WR_DATA(0x3C);
152
-  LCD_WR_REG(0xF0);
153
-  LCD_WR_DATA(0x69);
154
-  delay(120);     // Delay 120ms
155
-  LCD_WR_REG(0x29);     // Display ON
156
-
157
-  tftio.DataTransferEnd();
158
-
159
-  LCD_clear(0x0000);    //
56
+  tftio.InitTFT();
57
+  #if PIN_EXISTS(TFT_BACKLIGHT)
58
+    OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
59
+  #endif
60
+  delay(100);
61
+  LCD_clear(0x0000);
160 62
   LCD_Draw_Logo();
161
-  TFT_BLK_H;
162
-  delay(2000);
63
+  #if PIN_EXISTS(TFT_BACKLIGHT)
64
+    OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
65
+  #endif
66
+  #if HAS_LOGO_IN_FLASH
67
+    delay(2000);
68
+  #endif
163 69
 }
164 70
 
165 71
 void TFT::LCD_clear(uint16_t color) {
166
-  SetWindows(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
72
+  setWindow(0, 0, (TFT_WIDTH), (TFT_HEIGHT));
167 73
   tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
168 74
 }
169 75
 
170 76
 extern unsigned char bmp_public_buf[17 * 1024];
171 77
 
172 78
 void TFT::LCD_Draw_Logo() {
173
-  SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT);
174
-  for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
175
-    Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
176
-    tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
177
-  }
79
+  #if HAS_LOGO_IN_FLASH
80
+    setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
81
+    for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
82
+      Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
83
+      tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
84
+    }
85
+  #endif
178 86
 }
179 87
 
180
-#endif // HAS_TFT_LVGL_UI_SPI
88
+#endif // HAS_TFT_LVGL_UI

+ 5
- 13
Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h View File

@@ -23,29 +23,21 @@
23 23
 
24 24
 #include "../../inc/MarlinConfigPre.h"
25 25
 
26
-#if ENABLED(TFT_LVGL_UI_SPI)
27
-  #include HAL_PATH(../../HAL, tft/tft_spi.h)
28
-#elif ENABLED(TFT_LVGL_UI_FSMC)
29
-  #include HAL_PATH(../../HAL, tft/tft_fsmc.h)
30
-#endif
26
+#if HAS_TFT_LVGL_UI
31 27
 
32
-#define TFT_RST_H OUT_WRITE(TFT_RESET_PIN, HIGH)
33
-#define TFT_RST_L OUT_WRITE(TFT_RESET_PIN, LOW)
34
-
35
-#define TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH)
36
-#define TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW)
28
+#include "../../../tft_io/tft_io.h"
37 29
 
38 30
 class TFT {
39 31
 public:
40 32
   TFT_IO tftio;
41 33
   void spi_init(uint8_t spiRate);
42
-  void LCD_WR_REG(uint8_t cmd);
43
-  void LCD_WR_DATA(uint8_t data);
44 34
   void SetPoint(uint16_t x, uint16_t y, uint16_t point);
45
-  void SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height);
35
+  void setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height);
46 36
   void LCD_init();
47 37
   void LCD_clear(uint16_t color);
48 38
   void LCD_Draw_Logo();
49 39
 };
50 40
 
51 41
 extern TFT SPI_TFT;
42
+
43
+#endif // HAS_TFT_LVGL_UI

+ 2
- 4
Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp View File

@@ -23,9 +23,7 @@
23 23
 
24 24
 #if HAS_TFT_LVGL_UI
25 25
 
26
-#if ENABLED(TFT_LVGL_UI_SPI)
27
-  #include "SPI_TFT.h"
28
-#endif
26
+#include "SPI_TFT.h"
29 27
 
30 28
 #include "lv_conf.h"
31 29
 #include "draw_ui.h"
@@ -77,7 +75,7 @@ void lv_draw_error_message(PGM_P const msg) {
77 75
     lv_task_handler();
78 76
   #endif
79 77
 
80
-  TERN(TFT_LVGL_UI_SPI, SPI_TFT.LCD_clear, LCD_Clear)(0x0000);
78
+  SPI_TFT.LCD_clear(0x0000);
81 79
   if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000);
82 80
   disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000);
83 81
   disp_string((TFT_WIDTH - strlen("Please Reset") * 16) / 2, 180, "Please Reset", 0xFFFF, 0x0000);

+ 12
- 53
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp View File

@@ -23,9 +23,7 @@
23 23
 
24 24
 #if HAS_TFT_LVGL_UI
25 25
 
26
-#if ENABLED(TFT_LVGL_UI_SPI)
27
-  #include "SPI_TFT.h"
28
-#endif
26
+#include "SPI_TFT.h"
29 27
 
30 28
 #include "tft_lvgl_configuration.h"
31 29
 
@@ -165,7 +163,7 @@ void gCfgItems_init() {
165 163
     W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100);
166 164
   }
167 165
 
168
-  const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE);
166
+  const byte rot = (TFT_ROTATION & TFT_ROTATE_180) ? 0xEE : 0x00;
169 167
   if (gCfgItems.disp_rotation_180 != rot) {
170 168
     gCfgItems.disp_rotation_180 = rot;
171 169
     update_spi_flash();
@@ -655,12 +653,7 @@ char *creat_title_text() {
655 653
         }
656 654
 
657 655
         card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
658
-        #if ENABLED(TFT_LVGL_UI_SPI)
659
-          SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
660
-        #else
661
-          LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
662
-          LCD_WriteRAM_Prepare();
663
-        #endif
656
+        SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
664 657
 
665 658
         j = i = 0;
666 659
 
@@ -673,20 +666,11 @@ char *creat_title_text() {
673 666
           }
674 667
           if (j >= 400) break;
675 668
         }
676
-        #if ENABLED(TFT_LVGL_UI_SPI)
677
-          for (i = 0; i < 400; i += 2) {
678
-            p_index  = (uint16_t *)(&bmp_public_buf[i]);
679
-            if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
680
-          }
681
-          SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
682
-        #else
683
-          for (i = 0; i < 400;) {
684
-            p_index = (uint16_t *)(&bmp_public_buf[i]);
685
-            if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
686
-            LCD_IO_WriteData(*p_index);
687
-            i += 2;
688
-          }
689
-        #endif
669
+        for (i = 0; i < 400; i += 2) {
670
+          p_index  = (uint16_t *)(&bmp_public_buf[i]);
671
+          if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
672
+        }
673
+        SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
690 674
         #if HAS_BAK_VIEW_IN_FLASH
691 675
           W25QXX.init(SPI_QUARTER_SPEED);
692 676
           if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
@@ -768,7 +752,7 @@ char *creat_title_text() {
768 752
 
769 753
         card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
770 754
         #if ENABLED(TFT_LVGL_UI_SPI)
771
-          SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
755
+          SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
772 756
         #else
773 757
           LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
774 758
           LCD_WriteRAM_Prepare();
@@ -901,34 +885,9 @@ char *creat_title_text() {
901 885
         default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
902 886
       #endif
903 887
 
904
-      #if ENABLED(TFT_LVGL_UI_SPI)
905
-        SPI_TFT.SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
906
-        SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20);
907
-      #else
908
-        int x_off = 0;
909
-        uint16_t temp_p;
910
-        int i = 0;
911
-        uint16_t *p_index;
912
-        LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
913
-
914
-        LCD_WriteRAM_Prepare();
915
-
916
-        for (int _y = y_off * 20; _y < (y_off + 1) * 20; _y++) {
917
-          for (x_off = 0; x_off < 200; x_off++) {
918
-            if (sel == 1) {
919
-              temp_p  = (uint16_t)(bmp_public_buf[i] | bmp_public_buf[i + 1] << 8);
920
-              p_index = &temp_p;
921
-            }
922
-            else {
923
-              p_index = (uint16_t *)(&bmp_public_buf[i]);
924
-            }
925
-            if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
926
-            LCD_IO_WriteData(*p_index);
927
-            i += 2;
928
-          }
929
-          if (i >= 8000) break;
930
-        }
931
-      #endif // TFT_LVGL_UI_SPI
888
+      SPI_TFT.setWindow(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
889
+      SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20);
890
+
932 891
       y_off++;
933 892
     }
934 893
     W25QXX.init(SPI_QUARTER_SPEED);

+ 4
- 8
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp View File

@@ -23,9 +23,7 @@
23 23
 
24 24
 #if HAS_TFT_LVGL_UI
25 25
 
26
-#if ENABLED(TFT_LVGL_UI_SPI)
27
-  #include "SPI_TFT.h"
28
-#endif
26
+#include "SPI_TFT.h"
29 27
 
30 28
 #include "tft_lvgl_configuration.h"
31 29
 #include "draw_ready_print.h"
@@ -626,10 +624,8 @@ static const uint16_t ASCII_Table_16x24[] PROGMEM = {
626 624
 void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor) {
627 625
   for (uint16_t i = 0; i < 24; i++) {
628 626
     const uint16_t tmp_char = pgm_read_word(&ASCII_Table_16x24[((c - 0x20) * 24) + i]);
629
-    for (uint16_t j = 0; j < 16; j++) {
630
-      TERN(TFT_LVGL_UI_SPI, SPI_TFT.SetPoint, tft_set_point)
631
-        (x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor);
632
-    }
627
+    for (uint16_t j = 0; j < 16; j++)
628
+      SPI_TFT.SetPoint(x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor);
633 629
   }
634 630
 }
635 631
 
@@ -643,7 +639,7 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor
643 639
 
644 640
 //static lv_obj_t * scr_test;
645 641
 void disp_assets_update() {
646
-  TERN(TFT_LVGL_UI_SPI,, LCD_Clear(0x0000));
642
+  SPI_TFT.LCD_clear(0x0000);
647 643
   disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000);
648 644
 }
649 645
 

+ 0
- 60
Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp View File

@@ -1,60 +0,0 @@
1
-/**
2
- * Marlin 3D Printer Firmware
3
- * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
- *
5
- * Based on Sprinter and grbl.
6
- * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
- *
8
- * This program is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-#include "../../../../inc/MarlinConfig.h"
24
-
25
-#if ENABLED(TFT_LVGL_UI_FSMC)
26
-
27
-#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
28
-TFT_IO tftio;
29
-
30
-void LCD_IO_Init(uint8_t cs, uint8_t rs);
31
-void LCD_IO_WriteData(uint16_t RegValue);
32
-void LCD_IO_WriteReg(uint16_t Reg);
33
-#ifdef LCD_USE_DMA_FSMC
34
-  void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
35
-  void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
36
-#endif
37
-
38
-void LCD_IO_Init(uint8_t cs, uint8_t rs) {
39
-  tftio.Init();
40
-}
41
-
42
-void LCD_IO_WriteData(uint16_t RegValue) {
43
-  tftio.WriteData(RegValue);
44
-}
45
-
46
-void LCD_IO_WriteReg(uint16_t Reg) {
47
-  tftio.WriteReg(Reg);
48
-}
49
-
50
-#ifdef LCD_USE_DMA_FSMC
51
-  void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
52
-    tftio.WriteMultiple(color, count);
53
-  }
54
-
55
-  void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) {
56
-    tftio.WriteSequence(data, length);
57
-  }
58
-#endif // LCD_USE_DMA_FSMC
59
-
60
-#endif // HAS_TFT_LVGL_UI

+ 0
- 30
Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h View File

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

+ 14
- 371
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp View File

@@ -29,9 +29,7 @@
29 29
 
30 30
 #if HAS_TFT_LVGL_UI
31 31
 
32
-#if ENABLED(TFT_LVGL_UI_SPI)
33
-  #include "SPI_TFT.h"
34
-#endif
32
+#include "SPI_TFT.h"
35 33
 
36 34
 #include "tft_lvgl_configuration.h"
37 35
 #include "draw_ready_print.h"
@@ -74,24 +72,6 @@ lv_group_t*  g;
74 72
 uint16_t DeviceCode = 0x9488;
75 73
 extern uint8_t sel_id;
76 74
 
77
-#define SetCs
78
-#define ClrCs
79
-
80
-#define HDP  799 // Horizontal Display Period
81
-#define HT  1000 // Horizontal Total
82
-#define HPS   51 // LLINE Pulse Start Position
83
-#define LPS    3 // Horizontal Display Period Start Position
84
-#define HPW    8 // LLINE Pulse Width
85
-
86
-#define VDP  479 // Vertical Display Period
87
-#define VT   530 // Vertical Total
88
-#define VPS   24 // LFRAME Pulse Start Position
89
-#define FPS   23 // Vertical Display Period Start Positio
90
-#define VPW    3 // LFRAME Pulse Width
91
-
92
-#define MAX_HZ_POSX HDP+1
93
-#define MAX_HZ_POSY VDP+1
94
-
95 75
 extern uint8_t gcode_preview_over, flash_preview_begin, default_preview_flg;
96 76
 
97 77
 uint8_t bmp_public_buf[17 * 1024];
@@ -125,317 +105,7 @@ void SysTick_Callback() {
125 105
   }
126 106
 }
127 107
 
128
-#if DISABLED(TFT_LVGL_UI_SPI)
129
-
130
-  extern void LCD_IO_Init(uint8_t cs, uint8_t rs);
131
-  extern void LCD_IO_WriteData(uint16_t RegValue);
132
-  extern void LCD_IO_WriteReg(uint16_t Reg);
133
-
134
-  extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count);
135
-  void tft_set_cursor(uint16_t x, uint16_t y) {
136
-    LCD_IO_WriteReg(0x002A);
137
-    LCD_IO_WriteData(x >> 8);
138
-    LCD_IO_WriteData(x & 0x00FF);
139
-    LCD_IO_WriteData(x >> 8);
140
-    LCD_IO_WriteData(x & 0x00FF);
141
-    //ILI9488_WriteData(0x01);
142
-    //ILI9488_WriteData(0xDF);
143
-    LCD_IO_WriteReg(0x002B);
144
-    LCD_IO_WriteData(y >> 8);
145
-    LCD_IO_WriteData(y & 0x00FF);
146
-    LCD_IO_WriteData(y >> 8);
147
-    LCD_IO_WriteData(y & 0x00FF);
148
-    //ILI9488_WriteData(0x01);
149
-    //ILI9488_WriteData(0x3F);
150
-  }
151
-
152
-  void LCD_WriteRAM_Prepare(void) {
153
-    #if 0
154
-      switch (DeviceCode) {
155
-        case 0x9325: case 0x9328: case 0x8989: {
156
-          ClrCs
157
-          LCD->LCD_REG = R34;
158
-          SetCs
159
-        } break;
160
-        default: LCD_WrtReg(0x002C);
161
-      }
162
-    #else
163
-      LCD_IO_WriteReg(0x002C);
164
-    #endif
165
-  }
166
-
167
-  void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
168
-    //if (DeviceCode == 0x9488) {
169
-    if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return;
170
-    //}
171
-    tft_set_cursor(x, y);
172
-
173
-    LCD_WriteRAM_Prepare();
174
-    //LCD_WriteRAM(point);
175
-    LCD_IO_WriteData(point);
176
-  }
177
-
178
-  void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue) {
179
-    /* Write 16-bit Index, then Write Reg */
180
-    ClrCs
181
-    LCD_IO_WriteReg(LCD_Reg);
182
-    /* Write 16-bit Reg */
183
-    LCD_IO_WriteData(LCD_RegValue);
184
-    SetCs
185
-  }
186
-
187
-  void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh) {
188
-    uint16_t s_h, s_l, e_h, e_l;
189
-    uint16_t xEnd, yEnd;
190
-    xEnd = StartX + width;
191
-    yEnd = StartY + heigh - 1;
192
-    if (DeviceCode == 0x8989) {
193
-      /*LCD_WriteReg(0x0044, (StartX & 0xFF) | (xEnd << 8));
194
-      LCD_WriteReg(0x0045, StartY);
195
-      LCD_WriteReg(0x0046, yEnd);*/
196
-      LCD_WriteReg(0x0044, (StartY & 0xFF) | (yEnd << 8));
197
-      LCD_WriteReg(0x0045, StartX);
198
-      LCD_WriteReg(0x0046, xEnd);
199
-    }
200
-    else if (DeviceCode == 0x9488) {
201
-      s_h = (StartX >> 8) & 0x00FF;
202
-      s_l = StartX & 0x00FF;
203
-      e_h = ((StartX + width - 1) >> 8) & 0x00FF;
204
-      e_l = (StartX + width - 1) & 0x00FF;
205
-
206
-      LCD_IO_WriteReg(0x002A);
207
-      LCD_IO_WriteData(s_h);
208
-      LCD_IO_WriteData(s_l);
209
-      LCD_IO_WriteData(e_h);
210
-      LCD_IO_WriteData(e_l);
211
-
212
-      s_h = (StartY >> 8) & 0x00FF;
213
-      s_l = StartY & 0x00FF;
214
-      e_h = ((StartY + heigh - 1) >> 8) & 0x00FF;
215
-      e_l = (StartY + heigh - 1) & 0x00FF;
216
-
217
-      LCD_IO_WriteReg(0x002B);
218
-      LCD_IO_WriteData(s_h);
219
-      LCD_IO_WriteData(s_l);
220
-      LCD_IO_WriteData(e_h);
221
-      LCD_IO_WriteData(e_l);
222
-    }
223
-    else if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x1505)) {
224
-      /* LCD_WriteReg(0x0050, StartX);
225
-       LCD_WriteReg(0x0052, StartY);
226
-       LCD_WriteReg(0x0051, xEnd);
227
-       LCD_WriteReg(0x0053, yEnd);*/
228
-      LCD_WriteReg(0x0050, StartY);   // Specify the start/end positions of the window address in the horizontal direction by an address unit
229
-      LCD_WriteReg(0x0051, yEnd);     // Specify the start positions of the window address in the vertical direction by an address unit
230
-      LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd);
231
-      LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit
232
-
233
-    }
234
-    else {
235
-      s_h = (StartX >> 8) & 0xFF;
236
-      s_l = StartX & 0xFF;
237
-      e_h = ((StartX + width - 1) >> 8) & 0xFF;
238
-      e_l = (StartX + width - 1) & 0xFF;
239
-
240
-      LCD_IO_WriteReg(0x2A);
241
-      LCD_IO_WriteData(s_h);
242
-      LCD_IO_WriteData(s_l);
243
-      LCD_IO_WriteData(e_h);
244
-      LCD_IO_WriteData(e_l);
245
-
246
-      s_h = (StartY >> 8) & 0xFF;
247
-      s_l = StartY & 0xFF;
248
-      e_h = ((StartY + heigh - 1) >> 8) & 0xFF;
249
-      e_l = (StartY + heigh - 1) & 0xFF;
250
-
251
-      LCD_IO_WriteReg(0x2B);
252
-      LCD_IO_WriteData(s_h);
253
-      LCD_IO_WriteData(s_l);
254
-      LCD_IO_WriteData(e_h);
255
-      LCD_IO_WriteData(e_l);
256
-    }
257
-  }
258
-
259
-  void LCD_Clear(uint16_t Color) {
260
-    uint32_t index = 0;
261
-    unsigned int count;
262
-
263
-    if (DeviceCode == 0x9488) {
264
-      tft_set_cursor(0, 0);
265
-      LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
266
-      LCD_WriteRAM_Prepare();
267
-      #ifdef LCD_USE_DMA_FSMC
268
-        LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
269
-      #else
270
-        //index = (TFT_HEIGHT) / 2 * (TFT_WIDTH);
271
-        for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++)
272
-          LCD_IO_WriteData(Color);
273
-      #endif
274
-      //LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
275
-      //while(index --) LCD_IO_WriteData(Color);
276
-    }
277
-    else if (DeviceCode == 0x5761) {
278
-      LCD_IO_WriteReg(0x002A);
279
-      LCD_IO_WriteData(0);
280
-      LCD_IO_WriteData(0);
281
-      LCD_IO_WriteData(HDP >> 8);
282
-      LCD_IO_WriteData(HDP & 0x00FF);
283
-      LCD_IO_WriteReg(0x002B);
284
-      LCD_IO_WriteData(0);
285
-      LCD_IO_WriteData(0);
286
-      LCD_IO_WriteData(VDP >> 8);
287
-      LCD_IO_WriteData(VDP & 0x00FF);
288
-      LCD_IO_WriteReg(0x002C);
289
-      LCD_IO_WriteReg(0x002C);
290
-      for (count = 0; count < (HDP + 1) * (VDP + 1); count++)
291
-        LCD_IO_WriteData(Color);
292
-    }
293
-    else {
294
-      tft_set_cursor(0, 0);
295
-      LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
296
-      for (index = 0; index < 76800; index++)
297
-        LCD_IO_WriteData(Color);
298
-    }
299
-  }
300
-
301
-  #include HAL_PATH(../../HAL, tft/tft_fsmc.h)
302
-  extern TFT_IO tftio;
303
-  void fsmc_tft_init() {
304
-    uint16_t i;
305
-
306
-    TERN_(HAS_LCD_CONTRAST, refresh_contrast());
307
-
308
-    #ifdef LCD_USE_DMA_FSMC
309
-      dma_init(FSMC_DMA_DEV);
310
-      dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
311
-      dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
312
-    #endif
313
-
314
-    LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN);
315
-
316
-    _delay_ms(5);
317
-
318
-    DeviceCode = tftio.GetID() & 0xFFFF;
319
-    // Chitu and others
320
-    if (DeviceCode == 0x8066) DeviceCode = 0x9488;
321
-
322
-    if (DeviceCode == 0x9488) {
323
-      LCD_IO_WriteReg(0x00E0);
324
-      LCD_IO_WriteData(0x0000);
325
-      LCD_IO_WriteData(0x0007);
326
-      LCD_IO_WriteData(0x000F);
327
-      LCD_IO_WriteData(0x000D);
328
-      LCD_IO_WriteData(0x001B);
329
-      LCD_IO_WriteData(0x000A);
330
-      LCD_IO_WriteData(0x003C);
331
-      LCD_IO_WriteData(0x0078);
332
-      LCD_IO_WriteData(0x004A);
333
-      LCD_IO_WriteData(0x0007);
334
-      LCD_IO_WriteData(0x000E);
335
-      LCD_IO_WriteData(0x0009);
336
-      LCD_IO_WriteData(0x001B);
337
-      LCD_IO_WriteData(0x001E);
338
-      LCD_IO_WriteData(0x000F);
339
-
340
-      LCD_IO_WriteReg(0x00E1);
341
-      LCD_IO_WriteData(0x0000);
342
-      LCD_IO_WriteData(0x0022);
343
-      LCD_IO_WriteData(0x0024);
344
-      LCD_IO_WriteData(0x0006);
345
-      LCD_IO_WriteData(0x0012);
346
-      LCD_IO_WriteData(0x0007);
347
-      LCD_IO_WriteData(0x0036);
348
-      LCD_IO_WriteData(0x0047);
349
-      LCD_IO_WriteData(0x0047);
350
-      LCD_IO_WriteData(0x0006);
351
-      LCD_IO_WriteData(0x000A);
352
-      LCD_IO_WriteData(0x0007);
353
-      LCD_IO_WriteData(0x0030);
354
-      LCD_IO_WriteData(0x0037);
355
-      LCD_IO_WriteData(0x000F);
356
-
357
-      LCD_IO_WriteReg(0x00C0);
358
-      LCD_IO_WriteData(0x0010);
359
-      LCD_IO_WriteData(0x0010);
360
-
361
-      LCD_IO_WriteReg(0x00C1);
362
-      LCD_IO_WriteData(0x0041);
363
-
364
-      LCD_IO_WriteReg(0x00C5);
365
-      LCD_IO_WriteData(0x0000);
366
-      LCD_IO_WriteData(0x0022);
367
-      LCD_IO_WriteData(0x0080);
368
-
369
-      LCD_IO_WriteReg(0x0036);
370
-      LCD_IO_WriteData(TERN(GRAPHICAL_TFT_ROTATE_180, 0xE8, 0x0068));
371
-
372
-      LCD_IO_WriteReg(0x003A); //Interface Mode Control
373
-      LCD_IO_WriteData(0x0055);
374
-
375
-      LCD_IO_WriteReg(0x00B0);  //Interface Mode Control
376
-      LCD_IO_WriteData(0x0000);
377
-      LCD_IO_WriteReg(0x00B1);   //Frame rate 70HZ
378
-      LCD_IO_WriteData(0x00B0);
379
-      LCD_IO_WriteData(0x0011);
380
-      LCD_IO_WriteReg(0x00B4);
381
-      LCD_IO_WriteData(0x0002);
382
-      LCD_IO_WriteReg(0x00B6); //RGB/MCU Interface Control
383
-      LCD_IO_WriteData(0x0002);
384
-      LCD_IO_WriteData(0x0042);
385
-
386
-      LCD_IO_WriteReg(0x00B7);
387
-      LCD_IO_WriteData(0x00C6);
388
-
389
-      //WriteComm(0xBE);
390
-      //WriteData(0x00);
391
-      //WriteData(0x04);
392
-
393
-      LCD_IO_WriteReg(0x00E9);
394
-      LCD_IO_WriteData(0x0000);
395
-
396
-      LCD_IO_WriteReg(0x00F7);
397
-      LCD_IO_WriteData(0x00A9);
398
-      LCD_IO_WriteData(0x0051);
399
-      LCD_IO_WriteData(0x002C);
400
-      LCD_IO_WriteData(0x0082);
401
-
402
-      LCD_IO_WriteReg(0x0011);
403
-      for (i = 0; i < 65535; i++) { /* do nothing */ }
404
-      LCD_IO_WriteReg(0x0029);
405
-
406
-      LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
407
-
408
-      OUT_WRITE(LCD_BACKLIGHT_PIN, LOW);
409
-      LCD_Clear(0x0000);
410
-
411
-      TERN_(HAS_LOGO_IN_FLASH, lcd_draw_logo());
412
-
413
-      OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
414
-      delay(2000);
415
-    }
416
-  }
417
-
418
-  extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
419
-
420
-  void lcd_draw_logo() {
421
-    LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT);
422
-    LCD_WriteRAM_Prepare();
423
-
424
-    for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
425
-      Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
426
-      #ifdef LCD_USE_DMA_FSMC
427
-        LCD_IO_WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
428
-      #else
429
-        int index = 0;,x_off = 0;
430
-        for (x_off = 0; x_off < TFT_WIDTH; x_off++) {
431
-          LCD_IO_WriteData((uint16_t)bmp_public_buf[index]);
432
-          index += 2;
433
-        }
434
-      #endif
435
-    }
436
-  }
437
-
438
-#endif // !TFT_LVGL_UI_SPI
108
+extern uint8_t bmp_public_buf[17 * 1024];
439 109
 
440 110
 void tft_lvgl_init() {
441 111
 
@@ -448,12 +118,8 @@ void tft_lvgl_init() {
448 118
   disp_language_init();
449 119
 
450 120
   //init tft first!
451
-  #if ENABLED(TFT_LVGL_UI_SPI)
452
-    SPI_TFT.spi_init(SPI_FULL_SPEED);
453
-    SPI_TFT.LCD_init();
454
-  #else
455
-    fsmc_tft_init();
456
-  #endif
121
+  SPI_TFT.spi_init(SPI_FULL_SPEED);
122
+  SPI_TFT.LCD_init();
457 123
 
458 124
   //spi_flash_read_test();
459 125
   #if ENABLED(SDSUPPORT)
@@ -548,41 +214,18 @@ void tft_lvgl_init() {
548 214
 }
549 215
 
550 216
 void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
551
-  #if ENABLED(TFT_LVGL_UI_SPI)
552
-    uint16_t i, width, height;
217
+  uint16_t i, width, height;
553 218
 
554
-    width = area->x2 - area->x1 + 1;
555
-    height = area->y2 - area->y1 + 1;
219
+  width = area->x2 - area->x1 + 1;
220
+  height = area->y2 - area->y1 + 1;
556 221
 
557
-    SPI_TFT.SetWindows((uint16_t)area->x1, (uint16_t)area->y1, width, height);
558
-    for (i = 0; i < height; i++) {
559
-      SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
560
-    }
561
-    lv_disp_flush_ready(disp);       /* Indicate you are ready with the flushing*/
562
-
563
-    W25QXX.init(SPI_QUARTER_SPEED);
564
-
565
-  #else // !TFT_LVGL_UI_SPI
566
-
567
-    #if 1
568
-      uint16_t i, width, height;
569
-      //uint16_t clr_temp;
570
-      width = area->x2 - area->x1 + 1;
571
-      height = area->y2 - area->y1 + 1;
572
-      LCD_setWindowArea((uint16_t)area->x1, (uint16_t)area->y1, width, height);
573
-      LCD_WriteRAM_Prepare();
574
-      for (i = 0; i < width * height - 2; i++) {
575
-        //clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11)
576
-                              //| ((uint16_t)color_p->ch.green << 5)
577
-                              //| ((uint16_t)color_p->ch.blue));
578
-        LCD_IO_WriteData(color_p->full);
579
-        color_p++;
580
-      }
581
-
582
-      lv_disp_flush_ready(disp);       /* Indicate you are ready with the flushing*/
583
-    #endif
222
+  SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
223
+  for (i = 0; i < height; i++) {
224
+    SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
225
+  }
226
+  lv_disp_flush_ready(disp);       /* Indicate you are ready with the flushing*/
584 227
 
585
-  #endif // !TFT_LVGL_UI_SPI
228
+  W25QXX.init(SPI_QUARTER_SPEED);
586 229
 }
587 230
 
588 231
 #define TICK_CYCLE 1
@@ -599,7 +242,7 @@ static bool get_point(int16_t *x, int16_t *y) {
599 242
     *y = int16_t((int32_t(*y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
600 243
   }
601 244
 
602
-  #if ENABLED(GRAPHICAL_TFT_ROTATE_180)
245
+  #if (TFT_ROTATION & TFT_ROTATE_180)
603 246
     *x = int16_t((TFT_WIDTH) - (int)(*x));
604 247
     *y = int16_t((TFT_HEIGHT) - (int)(*y));
605 248
   #endif

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h View File

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

+ 7
- 2
Marlin/src/lcd/scaled_tft.h View File

@@ -43,8 +43,13 @@
43 43
 #endif
44 44
 
45 45
 #ifndef TFT_PIXEL_OFFSET_X
46
-  #define TFT_PIXEL_OFFSET_X 48
46
+  #if GRAPHICAL_TFT_UPSCALE == 2
47
+    #define TFT_PIXEL_OFFSET_X 32
48
+  #else
49
+    #define TFT_PIXEL_OFFSET_X 48
50
+  #endif
47 51
 #endif
48 52
 #ifndef TFT_PIXEL_OFFSET_Y
49
-  #define TFT_PIXEL_OFFSET_Y 48
53
+  // 32 is better for both 320x240 and 480x320
54
+  #define TFT_PIXEL_OFFSET_Y 32
50 55
 #endif

+ 1
- 158
Marlin/src/lcd/tft/tft.cpp View File

@@ -25,173 +25,16 @@
25 25
 #if HAS_GRAPHICAL_TFT
26 26
 
27 27
 #include "tft.h"
28
-#include "st7735.h"
29
-#include "st7789v.h"
30
-#include "st7796s.h"
31
-#include "r65105.h"
32
-#include "ili9328.h"
33
-#include "ili9341.h"
34
-#include "ili9488.h"
35 28
 
36 29
 //#define DEBUG_GRAPHICAL_TFT
37 30
 #define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
38 31
 #include "../../core/debug_out.h"
39 32
 
40 33
 uint16_t TFT::buffer[];
41
-uint32_t TFT::lcd_id = 0xFFFFFFFF;
42 34
 
43 35
 void TFT::init() {
44
-  if (lcd_id != 0xFFFFFFFF) return;
45
-
46 36
   io.Init();
47
-
48
-  #if TFT_DRIVER != AUTO
49
-    lcd_id = TFT_DRIVER;
50
-  #endif
51
-
52
-  #if TFT_DRIVER == ST7735
53
-    write_esc_sequence(st7735_init);
54
-  #elif TFT_DRIVER == ST7789
55
-    write_esc_sequence(st7789v_init);
56
-  #elif TFT_DRIVER == ST7796
57
-    write_esc_sequence(st7796s_init);
58
-  #elif TFT_DRIVER == R61505
59
-    write_esc_sequence(r61505_init);
60
-  #elif TFT_DRIVER == ILI9328
61
-    write_esc_sequence(ili9328_init);
62
-  #elif TFT_DRIVER == ILI9341
63
-    write_esc_sequence(ili9341_init);
64
-  #elif TFT_DRIVER == ILI9488
65
-    write_esc_sequence(ili9488_init);
66
-  #elif TFT_DRIVER == LERDGE_ST7796
67
-    lcd_id = ST7796;
68
-    write_esc_sequence(lerdge_st7796s_init);
69
-
70
-  #elif TFT_DRIVER == AUTO // autodetect
71
-
72
-    lcd_id = io.GetID() & 0xFFFF;
73
-
74
-    switch (lcd_id) {
75
-      case ST7796:    // ST7796S    480x320
76
-        DEBUG_ECHO_MSG(" ST7796S");
77
-        write_esc_sequence(st7796s_init);
78
-        break;
79
-      case ST7789:    // ST7789V    320x240
80
-        DEBUG_ECHO_MSG(" ST7789V");
81
-        write_esc_sequence(st7789v_init);
82
-        break;
83
-      case ST7735:    // ST7735     160x128
84
-        DEBUG_ECHO_MSG(" ST7735");
85
-        write_esc_sequence(st7735_init);
86
-        break;
87
-      case R61505:    // R61505U    320x240
88
-        DEBUG_ECHO_MSG(" R61505U");
89
-        write_esc_sequence(r61505_init);
90
-        break;
91
-      case ILI9328:   // ILI9328    320x240
92
-        DEBUG_ECHO_MSG(" ILI9328");
93
-        write_esc_sequence(ili9328_init);
94
-        break;
95
-      case ILI9341:   // ILI9341    320x240
96
-        DEBUG_ECHO_MSG(" ILI9341");
97
-        write_esc_sequence(ili9341_init);
98
-        break;
99
-      case ILI9488:   // ILI9488    480x320
100
-        DEBUG_ECHO_MSG(" ILI9488");
101
-        write_esc_sequence(ili9488_init);
102
-        break;
103
-      default:
104
-        lcd_id = 0;
105
-    }
106
-  #else
107
-    #error Unsupported TFT driver
108
-  #endif
109
-}
110
-
111
-void TFT::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
112
-  #ifdef OFFSET_X
113
-    Xmin += OFFSET_X; Xmax += OFFSET_X;
114
-  #endif
115
-  #ifdef OFFSET_Y
116
-    Ymin += OFFSET_Y; Ymax += OFFSET_Y;
117
-  #endif
118
-
119
-  switch (lcd_id) {
120
-    case ST7735:    // ST7735     160x128
121
-    case ST7789:    // ST7789V    320x240
122
-    case ST7796:    // ST7796     480x320
123
-    case ILI9341:   // ILI9341    320x240
124
-    case ILI9488:   // ILI9488    480x320
125
-      io.DataTransferBegin(DATASIZE_8BIT);
126
-
127
-      // CASET: Column Address Set
128
-      io.WriteReg(ILI9341_CASET);
129
-      io.WriteData((Xmin >> 8) & 0xFF);
130
-      io.WriteData(Xmin & 0xFF);
131
-      io.WriteData((Xmax >> 8) & 0xFF);
132
-      io.WriteData(Xmax & 0xFF);
133
-
134
-      // RASET: Row Address Set
135
-      io.WriteReg(ILI9341_PASET);
136
-      io.WriteData((Ymin >> 8) & 0xFF);
137
-      io.WriteData(Ymin & 0xFF);
138
-      io.WriteData((Ymax >> 8) & 0xFF);
139
-      io.WriteData(Ymax & 0xFF);
140
-
141
-      // RAMWR: Memory Write
142
-      io.WriteReg(ILI9341_RAMWR);
143
-      break;
144
-    case R61505:    // R61505U    320x240
145
-    case ILI9328:   // ILI9328    320x240
146
-      io.DataTransferBegin(DATASIZE_16BIT);
147
-
148
-      // Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
149
-      io.WriteReg(ILI9328_HASTART);
150
-      io.WriteData(Ymin);
151
-      io.WriteReg(ILI9328_HAEND);
152
-      io.WriteData(Ymax);
153
-      io.WriteReg(ILI9328_VASTART);
154
-      io.WriteData(Xmin);
155
-      io.WriteReg(ILI9328_VAEND);
156
-      io.WriteData(Xmax);
157
-
158
-      io.WriteReg(ILI9328_HASET);
159
-      io.WriteData(Ymin);
160
-      io.WriteReg(ILI9328_VASET);
161
-      io.WriteData(Xmin);
162
-
163
-      io.WriteReg(ILI9328_RAMWR);
164
-      break;
165
-    default:
166
-      break;
167
-  }
168
-
169
-  io.DataTransferEnd();
170
-}
171
-
172
-void TFT::write_esc_sequence(const uint16_t *Sequence) {
173
-  uint16_t dataWidth, data;
174
-
175
-  dataWidth = *Sequence++;
176
-  io.DataTransferBegin(dataWidth);
177
-
178
-  for (;;) {
179
-    data = *Sequence++;
180
-    if (data != 0xFFFF) {
181
-      io.WriteData(data);
182
-      continue;
183
-    }
184
-    data = *Sequence++;
185
-    if (data == 0x7FFF) return;
186
-    if (data == 0xFFFF)
187
-      io.WriteData(0xFFFF);
188
-    else if (data & 0x8000)
189
-      delay(data & 0x7FFF);
190
-    else if ((data & 0xFF00) == 0)
191
-      io.WriteReg(data);
192
-  }
193
-
194
-  io.DataTransferEnd();
37
+  io.InitTFT();
195 38
 }
196 39
 
197 40
 TFT tft;

+ 2
- 24
Marlin/src/lcd/tft/tft.h View File

@@ -26,7 +26,7 @@
26 26
 #include "tft_color.h"
27 27
 #include "tft_string.h"
28 28
 #include "tft_image.h"
29
-#include "tft_io.h"
29
+#include "../tft_io/tft_io.h"
30 30
 
31 31
 #include "../../inc/MarlinConfig.h"
32 32
 
@@ -40,20 +40,6 @@
40 40
   #error "Unsupported display resolution!"
41 41
 #endif
42 42
 
43
-#define ST7735          0x89F0
44
-#define ST7789          0x8552
45
-#define ST7796          0x7796
46
-#define R61505          0x1505
47
-#define ILI9328         0x9328
48
-#define ILI9341         0x9341
49
-#define ILI9488         0x9488
50
-#define LERDGE_ST7796   0xFFFE
51
-#define AUTO            0xFFFF
52
-
53
-#ifndef TFT_DRIVER
54
-  #define TFT_DRIVER    AUTO
55
-#endif
56
-
57 43
 #ifndef TFT_BUFFER_SIZE
58 44
   #ifdef STM32F103xB
59 45
     #define TFT_BUFFER_SIZE       1024
@@ -71,14 +57,8 @@
71 57
   #error "TFT_BUFFER_SIZE can not exceed 65535"
72 58
 #endif
73 59
 
74
-#define ESC_REG(x)        0xFFFF, 0x00FF & (uint16_t)x
75
-#define ESC_DELAY(x)      0xFFFF, 0x8000 | (x & 0x7FFF)
76
-#define ESC_END           0xFFFF, 0x7FFF
77
-#define ESC_FFFF          0xFFFF, 0xFFFF
78
-
79 60
 class TFT {
80 61
   private:
81
-    static uint32_t lcd_id;
82 62
     static TFT_String string;
83 63
     static TFT_IO io;
84 64
 
@@ -91,13 +71,11 @@ class TFT {
91 71
     static inline void set_font(const uint8_t *Font) { string.set_font(Font); }
92 72
     static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); }
93 73
 
94
-    static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
95
-    static void write_esc_sequence(const uint16_t *Sequence);
96
-
97 74
     static inline bool is_busy() { return io.isBusy(); }
98 75
     static inline void abort() { io.Abort(); }
99 76
     static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); }
100 77
     static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }
78
+    static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); }
101 79
 
102 80
     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); }
103 81
     static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }

+ 0
- 30
Marlin/src/lcd/tft/tft_io.h View File

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

+ 4
- 0
Marlin/src/lcd/tft/touch.cpp View File

@@ -283,6 +283,10 @@ bool Touch::get_point(int16_t *x, int16_t *y) {
283 283
   if (is_touched && calibration.orientation != TOUCH_ORIENTATION_NONE) {
284 284
     *x = int16_t((int32_t(*x) * calibration.x) >> 16) + calibration.offset_x;
285 285
     *y = int16_t((int32_t(*y) * calibration.y) >> 16) + calibration.offset_y;
286
+    #if (TFT_ROTATION & TFT_ROTATE_180)
287
+      *x = TFT_WIDTH - *x;
288
+      *y = TFT_HEIGHT - *y;
289
+    #endif
286 290
   }
287 291
   return is_touched;
288 292
 }

Marlin/src/lcd/tft/ili9328.h → Marlin/src/lcd/tft_io/ili9328.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -40,8 +40,29 @@
40 40
 #define ILI9328_ETMOD_AM          0x0008 // 0 - Horizontal / 1 - Vertical
41 41
 
42 42
 // MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
43
-#define ILI9328_DRVCTL_DATA       ILI9328_DRVCTL_SS
44
-#define ILI9328_ETMOD_DATA        ILI9328_ETMOD_BGR | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0 | ILI9328_ETMOD_AM
43
+
44
+#if TFT_ROTATION == TFT_ROTATE_180
45
+  #define ILI9328_DRVCTL_DATA        0x0000
46
+  #define ILI9328_GATE_SCANCTL1_DATA 0xA700
47
+#else
48
+  #define ILI9328_DRVCTL_DATA        ILI9328_DRVCTL_SS
49
+  #define ILI9328_GATE_SCANCTL1_DATA 0x2700
50
+#endif
51
+
52
+// #define ILI9328_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9328_ETMOD_AM) | \
53
+//                                   IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ILI9328_ETMOD_ID1) | \
54
+//                                   IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ILI9328_ETMOD_ID0)
55
+
56
+#define ILI9328_ETMOD_ORIENTATION (ILI9328_ETMOD_AM | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0)
57
+
58
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
59
+  #define ILI9328_ETMOD_COLOR ILI9328_ETMOD_BGR
60
+#elif TFT_COLOR == TFT_COLOR_RGB
61
+  #define ILI9328_ETMOD_COLOR ILI9328_ETMOD_RGB
62
+#endif
63
+
64
+#define ILI9328_ETMOD_DATA       (ILI9328_ETMOD_ORIENTATION) | (ILI9328_ETMOD_COLOR)
65
+
45 66
 
46 67
 #define ILI9328_RDDID             0x00 // ID code - 0x9328
47 68
 #define ILI9328_DRVCTL            0x01 // Driver Output Control
@@ -134,7 +155,7 @@ static const uint16_t ili9328_init[] = {
134 155
   ESC_REG(ILI9328_PWCTRL7), 0x0004,
135 156
   ESC_REG(ILI9328_FRMCTR), 0x000D,
136 157
   ESC_DELAY(50),
137
-  ESC_REG(ILI9328_GATE_SCANCTL1), 0x2700,
158
+  ESC_REG(ILI9328_GATE_SCANCTL1), ILI9328_GATE_SCANCTL1_DATA,
138 159
   ESC_REG(ILI9328_GATE_SCANCTL2), 0x0001,
139 160
   ESC_REG(ILI9328_GATE_SCANCTL3), 0x0000,
140 161
   ESC_REG(ILI9328_PLTPOS1), 0x0000,

Marlin/src/lcd/tft/ili9341.h → Marlin/src/lcd/tft_io/ili9341.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -38,13 +38,17 @@
38 38
 #define ILI9341_ORIENTATION_LEFT  ILI9341_MADCTL_MY | ILI9341_MADCTL_MX | ILI9341_MADCTL_MV // 320x240 ; Cable on the left side
39 39
 #define ILI9341_ORIENTATION_DOWN  ILI9341_MADCTL_MX                                         // 240x320 ; Cable on the upper side
40 40
 
41
-#ifndef ILI9341_COLOR_RGB
42
-  #define ILI9341_COLOR_BGR
43
-#endif
44
-#ifndef ILI9341_ORIENTATION
45
-  #define ILI9341_ORIENTATION     ILI9341_ORIENTATION_LEFT
41
+#define ILI9341_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9341_MADCTL_MV) | \
42
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ILI9341_MADCTL_MX) | \
43
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ILI9341_MADCTL_MY)
44
+
45
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
46
+  #define ILI9341_COLOR ILI9341_MADCTL_BGR
47
+#elif TFT_COLOR == TFT_COLOR_RGB
48
+  #define ILI9341_COLOR ILI9341_MADCTL_RGB
46 49
 #endif
47
-#define ILI9341_MADCTL_DATA      (ILI9341_ORIENTATION | TERN(ILI9341_COLOR_BGR, ILI9341_MADCTL_BGR, ILI9341_MADCTL_RGB))
50
+
51
+#define ILI9341_MADCTL_DATA       (ILI9341_ORIENTATION) | (ILI9341_COLOR)
48 52
 
49 53
 #define ILI9341_NOP               0x00 // No Operation
50 54
 #define ILI9341_SWRESET           0x01 // Software Reset

Marlin/src/lcd/tft/ili9488.h → Marlin/src/lcd/tft_io/ili9488.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -38,13 +38,17 @@
38 38
 #define ILI9488_ORIENTATION_LEFT  ILI9488_MADCTL_MY | ILI9488_MADCTL_MX | ILI9488_MADCTL_MV // 480x320 ; Cable on the left side
39 39
 #define ILI9488_ORIENTATION_DOWN  ILI9488_MADCTL_MX                                         // 320x480 ; Cable on the upper side
40 40
 
41
-#ifndef ILI9488_COLOR_RGB
42
-  #define ILI9488_COLOR_BGR
43
-#endif
44
-#ifndef ILI9488_ORIENTATION
45
-  #define ILI9488_ORIENTATION     ILI9488_ORIENTATION_LEFT
41
+#define ILI9488_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9488_MADCTL_MV) | \
42
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ILI9488_MADCTL_MX) | \
43
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ILI9488_MADCTL_MY)
44
+
45
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
46
+  #define ILI9488_COLOR ILI9488_MADCTL_BGR
47
+#elif TFT_COLOR == TFT_COLOR_RGB
48
+  #define ILI9488_COLOR ILI9488_MADCTL_RGB
46 49
 #endif
47
-#define ILI9488_MADCTL_DATA       (ILI9488_ORIENTATION | TERN(ILI9488_COLOR_BGR, ILI9488_MADCTL_BGR, ILI9488_MADCTL_RGB))
50
+
51
+#define ILI9488_MADCTL_DATA       (ILI9488_ORIENTATION) | (ILI9488_COLOR)
48 52
 
49 53
 #define ILI9488_NOP               0x00 // No Operation
50 54
 #define ILI9488_SWRESET           0x01 // Software Reset

Marlin/src/lcd/tft/r65105.h → Marlin/src/lcd/tft_io/r65105.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -42,9 +42,28 @@
42 42
 #define R61505_DRVCTRL_GS         0x8000 // Gate Scan direction
43 43
 
44 44
 // MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
45
-#define R61505_DRVCTL_DATA        R61505_DRVCTL_SS
46
-#define R61505_ETMOD_DATA         R61505_ETMOD_BGR | R61505_ETMOD_ID1 | R61505_ETMOD_ID0 | R61505_ETMOD_AM
47
-#define R61505_DRVCTRL_GSDIR      R61505_DRVCTRL_GS
45
+
46
+#if TFT_ROTATION == TFT_ROTATE_180
47
+  #define R61505_DRVCTL_DATA      0x0000
48
+  #define R61505_DRVCTRL_DATA     (0x2700 | R61505_DRVCTRL_GS)
49
+#else
50
+  #define R61505_DRVCTL_DATA      R61505_DRVCTL_SS
51
+  #define R61505_DRVCTRL_DATA     0x2700
52
+#endif
53
+
54
+// #define R61505_ETMOD_ORIENTATION  IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, R61505_ETMOD_AM) | \
55
+//                                   IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    R61505_ETMOD_ID0) | \
56
+//                                   IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    R61505_ETMOD_ID1)
57
+
58
+#define R61505_ETMOD_ORIENTATION (R61505_ETMOD_AM | R61505_ETMOD_ID0 | R61505_ETMOD_ID1)
59
+
60
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
61
+  #define R61505_ETMOD_COLOR R61505_ETMOD_BGR
62
+#elif TFT_COLOR == TFT_COLOR_RGB
63
+  #define R61505_ETMOD_COLOR R61505_ETMOD_RGB
64
+#endif
65
+
66
+#define R61505_ETMOD_DATA       (R61505_ETMOD_ORIENTATION) | (R61505_ETMOD_COLOR)
48 67
 
49 68
 
50 69
 #define R61505_RDDID              0x00 // ID code - 0x1505
@@ -141,7 +160,7 @@ static const uint16_t r61505_init[] = {
141 160
   ESC_REG(R61505_GAMCTRL9), 0x0700,
142 161
   ESC_REG(R61505_GAMCTRLA), 0x0A1F,
143 162
 
144
-  ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_GSDIR | 0x2700,
163
+  ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_DATA,
145 164
   ESC_REG(R61505_BASE_IMAGE_CTRL), 0x0001,
146 165
   ESC_REG(R61505_VSCROLL_CTRL), 0x0000,
147 166
 

+ 131
- 0
Marlin/src/lcd/tft_io/ssd1963.h View File

@@ -0,0 +1,131 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "tft_io.h"
25
+
26
+#include "../../inc/MarlinConfig.h"
27
+
28
+#define SSD1963_MADCTL_MY         0x80 // Row Address Order
29
+#define SSD1963_MADCTL_MX         0x40 // Column Address Order
30
+#define SSD1963_MADCTL_MV         0x20 // Row/Column Exchange
31
+#define SSD1963_MADCTL_MH         0x10 // Horizontal Refresh Order
32
+#define SSD1963_MADCTL_BGR        0x08 // RGB-BGR ORDER
33
+#define SSD1963_MADCTL_RGB        0x00
34
+#define SSD1963_MADCTL_ML         0x04 // Vertical Refresh Order
35
+#define SSD1963_MADCTL_FH         0x02 // Flip Horizontal
36
+#define SSD1963_MADCTL_FV         0x01 // Flip Vertical
37
+
38
+#define SSD1963_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, SSD1963_MADCTL_MV) | \
39
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    SSD1963_MADCTL_FH) | \
40
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    SSD1963_MADCTL_FV)
41
+
42
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
43
+  #define SSD1963_COLOR SSD1963_MADCTL_BGR
44
+#elif TFT_COLOR == TFT_COLOR_RGB
45
+  #define SSD1963_COLOR SSD1963_MADCTL_RGB
46
+#endif
47
+
48
+#define SSD1963_MADCTL_DATA       (SSD1963_ORIENTATION) | (SSD1963_COLOR)
49
+
50
+#define SSD1963_NOP               0x00 // No Operation
51
+#define SSD1963_SWRESET           0x01 // Software reset
52
+#define SSD1963_RDDPM             0x0A // Read Display Power Mode
53
+#define SSD1963_RDDMADCTL         0x0B // Read Display MADCTL
54
+#define SSD1963_RDDCOLMOD         0x0C // Read Display Pixel Format
55
+#define SSD1963_RDDIM             0x0D // Read Display Image Mode
56
+#define SSD1963_RDDSM             0x0E // Read Display Signal Mode
57
+#define SSD1963_SLPIN             0x10 // Sleep In
58
+#define SSD1963_SLPOUT            0x11 // Sleep Out
59
+#define SSD1963_PTLON             0x12 // Partial Display Mode On
60
+#define SSD1963_NORON             0x13 // Normal Display Mode On
61
+#define SSD1963_INVOFF            0x20 // Display Inversion Off
62
+#define SSD1963_INVON             0x21 // Display Inversion On
63
+#define SSD1963_GAMSET            0x26 // Gamma Set
64
+#define SSD1963_DISPOFF           0x28 // Display Off
65
+#define SSD1963_DISPON            0x29 // Display On
66
+#define SSD1963_CASET             0x2A // Column Address Set
67
+#define SSD1963_RASET             0x2B // Row Address Set
68
+#define SSD1963_RAMWR             0x2C // Memory Write
69
+#define SSD1963_RAMRD             0x2E // Memory Read
70
+#define SSD1963_PTLAR             0x30 // Partial Area
71
+#define SSD1963_VSCRDEF           0x33 // Vertical Scrolling Definition
72
+#define SSD1963_TEOFF             0x34 // Tearing Effect Line OFF
73
+#define SSD1963_TEON              0x35 // Tearing Effect Line ON
74
+#define SSD1963_MADCTL            0x36 // Memory Data Access Control
75
+#define SSD1963_VSCSAD            0x37 // Vertical Scroll Start Address of RAM
76
+#define SSD1963_IDMOFF            0x38 // Idle Mode Off
77
+#define SSD1963_IDMON             0x39 // Idle Mode On
78
+#define SSD1963_WRMEMC            0x3C // Write Memory Continue
79
+#define SSD1963_RDMEMC            0x3E // Read Memory Continue
80
+#define SSD1963_STE               0x44 // Set Tear Scanline
81
+#define SSD1963_GSCAN             0x45 // Get Scanline
82
+#define SSD1963_WRDISBV           0x51 // Write Display Brightness
83
+#define SSD1963_RDDISBV           0x52 // Read Display Brightness
84
+#define SSD1963_WRCTRLD           0x53 // Write CTRL Display
85
+#define SSD1963_RDCTRLD           0x54 // Read CTRL Value Display
86
+#define SSD1963_WRCACE            0x55 // Write Content Adaptive Brightness Control and Color Enhancement
87
+#define SSD1963_RDCABC            0x56 // Read Content Adaptive Brightness Control
88
+#define SSD1963_WRCABCMB          0x5E // Write CABC Minimum Brightness
89
+#define SSD1963_RDCABCMB          0x5F // Read CABC Minimum Brightness
90
+#define SSD1963_RDABCSDR          0x68 // Read Automatic Brightness Control Self-Diagnostic Result
91
+#define SSD1963_RDDDB             0xA1 // Read Device Descriptor Block
92
+#define SSD1963_SLCDMODE          0xB0 // Set the LCD panel mode and resolution
93
+#define SSD1963_SHSYNC            0xB4 // Set HSYNC
94
+#define SSD1963_GHSYNC            0xB5 // Get HSYNC
95
+#define SSD1963_SVSYNC            0xB6 // Set VSYNC
96
+#define SSD1963_GVSYNC            0xB7 // Get VSYNC
97
+#define SSD1963_SGPIOCFG          0xB8 // Set GPIO Conf
98
+#define SSD1963_SGPIOV            0xBA // Set GPIO Value
99
+#define SSD1963_SPWMCFG           0xBE // Set PWM Conf
100
+#define SSD1963_GPWMCFG           0xBF // Get PWM Conf
101
+#define SSD1963_SDBCCFG           0xD0 // Set Dynamic Back Light Config
102
+#define SSD1963_GDBCCFG           0xD1 // Get Dynamic Back Light Config
103
+#define SSD1963_PLLON             0xE0 // PLL Enable
104
+#define SSD1963_PLLMN             0xE2 // Set PLL Multiplier
105
+#define SSD1963_SLSHIFT           0xE6 // Set the LSHIFT (pixel clock) frequency
106
+#define SSD1963_COLMOD            0xF0 // Interface Pixel Format
107
+
108
+static const uint16_t ssd1963_init[] = {
109
+  DATASIZE_8BIT,
110
+  ESC_REG(SSD1963_PLLMN), 0x0023, 0x0002, 0x0054,
111
+  ESC_REG(SSD1963_PLLON), 0x0001, ESC_DELAY(10),
112
+  ESC_REG(SSD1963_PLLON), 0x0003, ESC_DELAY(10),
113
+  ESC_REG(SSD1963_SWRESET), ESC_DELAY(100),
114
+
115
+  ESC_REG(SSD1963_SLSHIFT), 0x0001, 0x001F, 0x00FF,
116
+  ESC_REG(SSD1963_SLCDMODE), 0x0020, 0x0000, 0x0001, 0x00DF, 0x0001, 0x000F, 0x0000,
117
+  ESC_REG(SSD1963_SHSYNC), 0x0002, 0x0013, 0x0000, 0x0008, 0x002B, 0x0000, 0x0002, 0x0000,
118
+  ESC_REG(SSD1963_SVSYNC), 0x0001, 0x0020, 0x0000, 0x0004, 0x000C, 0x0000, 0x0002,
119
+  ESC_REG(SSD1963_SGPIOV), 0x000F,
120
+  ESC_REG(SSD1963_SGPIOCFG), 0x0007, 0x0001,
121
+
122
+  ESC_REG(SSD1963_MADCTL), SSD1963_MADCTL_DATA,
123
+  ESC_REG(SSD1963_COLMOD), 0x0003, ESC_DELAY(1),//RBG 565
124
+
125
+  ESC_REG(SSD1963_NORON),
126
+  ESC_REG(SSD1963_DISPON),
127
+
128
+  ESC_REG(SSD1963_SPWMCFG), 0x0006, 0x00f0, 0x0001, 0x00f0, 0x0000, 0x0000,
129
+  ESC_REG(SSD1963_SDBCCFG), 0x000D,
130
+  ESC_END
131
+};

Marlin/src/lcd/tft/st7735.h → Marlin/src/lcd/tft_io/st7735.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -38,9 +38,17 @@
38 38
 #define ST7735_ORIENTATION_LEFT   ST7735_MADCTL_MV | ST7735_MADCTL_MX // 160x128 ; Cable on the left side
39 39
 #define ST7735_ORIENTATION_DOWN   ST7735_MADCTL_MX | ST7735_MADCTL_MY // 128x160 ; Cable on the lower side
40 40
 
41
-//#define ST7735_COLOR_BGR
42
-#define ST7735_ORIENTATION        ST7735_ORIENTATION_DOWN
43
-#define ST7735_MADCTL_DATA       (ST7735_ORIENTATION | TERN(ST7735_COLOR_BGR, ST7735_MADCTL_BGR, ST7735_MADCTL_RGB))
41
+#define ST7735_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7735_MADCTL_MV) | \
42
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ST7735_MADCTL_MX) | \
43
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ST7735_MADCTL_MY)
44
+
45
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
46
+  #define ST7735_COLOR ST7735_MADCTL_RGB
47
+#elif TFT_COLOR == TFT_COLOR_BGR
48
+  #define ST7735_COLOR ST7735_MADCTL_BGR
49
+#endif
50
+
51
+#define ST7735_MADCTL_DATA       (ST7735_ORIENTATION) | (ST7735_COLOR)
44 52
 
45 53
 #define ST7735_NOP                0x00 // No Operation
46 54
 #define ST7735_SWRESET            0x01 // Software reset

Marlin/src/lcd/tft/st7789v.h → Marlin/src/lcd/tft_io/st7789v.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -38,11 +38,17 @@
38 38
 #define ST7789V_ORIENTATION_LEFT  ST7789V_MADCTL_MY | ST7789V_MADCTL_MV // 320x240 ; Cable on the left side
39 39
 #define ST7789V_ORIENTATION_DOWN  0                                     // 240x320 ; Cable on the lower side
40 40
 
41
-//#define ST7789V_COLOR_BGR
42
-#ifndef ST7789V_ORIENTATION
43
-  #define ST7789V_ORIENTATION     ST7789V_ORIENTATION_LEFT
41
+#define ST7789V_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7789V_MADCTL_MV) | \
42
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ST7789V_MADCTL_MX) | \
43
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ST7789V_MADCTL_MY)
44
+
45
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
46
+  #define ST7789V_COLOR ST7789V_MADCTL_RGB
47
+#elif TFT_COLOR == TFT_COLOR_BGR
48
+  #define ST7789V_COLOR ST7789V_MADCTL_BGR
44 49
 #endif
45
-#define ST7789V_MADCTL_DATA       (ST7789V_ORIENTATION | TERN(ST7789V_COLOR_BGR, ST7789V_MADCTL_BGR, ST7789V_MADCTL_RGB))
50
+
51
+#define ST7789V_MADCTL_DATA       (ST7789V_ORIENTATION) | (ST7789V_COLOR)
46 52
 
47 53
 #define ST7789V_NOP               0x00 // No Operation
48 54
 #define ST7789V_SWRESET           0x01 // Software reset

Marlin/src/lcd/tft/st7796s.h → Marlin/src/lcd/tft_io/st7796s.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "tft.h"
24
+#include "tft_io.h"
25 25
 
26 26
 #include "../../inc/MarlinConfig.h"
27 27
 
@@ -33,9 +33,17 @@
33 33
 #define ST7796S_MADCTL_RGB 0x00
34 34
 #define ST7796S_MADCTL_MH  0x04 // Horizontal Refresh Order
35 35
 
36
-#define ST7796S_COLOR_BGR
37
-#define ST7796S_ORIENTATION  ST7796S_MADCTL_MV
38
-#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB))
36
+#define ST7796S_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7796S_MADCTL_MV) | \
37
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    ST7796S_MADCTL_MX) | \
38
+                            IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    ST7796S_MADCTL_MY)
39
+
40
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
41
+  #define ST7796S_COLOR ST7796S_MADCTL_BGR
42
+#elif TFT_COLOR == TFT_COLOR_RGB
43
+  #define ST7796S_COLOR ST7796S_MADCTL_RGB
44
+#endif
45
+
46
+#define ST7796S_MADCTL_DATA       (ST7796S_ORIENTATION) | (ST7796S_COLOR)
39 47
 
40 48
 #define ST7796S_NOP        0x00 // No Operation
41 49
 #define ST7796S_SWRESET    0x01 // Software reset

+ 226
- 0
Marlin/src/lcd/tft_io/tft_io.cpp View File

@@ -0,0 +1,226 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "tft_io.h"
24
+
25
+#if HAS_SPI_TFT || HAS_FSMC_TFT
26
+
27
+#include "st7735.h"
28
+#include "st7789v.h"
29
+#include "st7796s.h"
30
+#include "r65105.h"
31
+#include "ili9328.h"
32
+#include "ili9341.h"
33
+#include "ili9488.h"
34
+#include "ssd1963.h"
35
+
36
+#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
37
+#include "../../core/debug_out.h"
38
+
39
+TFT_IO_DRIVER TFT_IO::io;
40
+uint32_t TFT_IO::lcd_id = 0xFFFFFFFF;
41
+
42
+void TFT_IO::InitTFT() {
43
+if (lcd_id != 0xFFFFFFFF) return;
44
+
45
+  #if PIN_EXISTS(TFT_BACKLIGHT)
46
+    OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
47
+  #endif
48
+
49
+  #if PIN_EXISTS(TFT_RESET)
50
+    OUT_WRITE(TFT_RESET_PIN, HIGH);
51
+    delay(10);
52
+    OUT_WRITE(TFT_RESET_PIN, LOW);
53
+    delay(10);
54
+    OUT_WRITE(TFT_RESET_PIN, HIGH);
55
+  #endif
56
+
57
+  #if PIN_EXISTS(TFT_BACKLIGHT)
58
+    OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
59
+  #endif
60
+
61
+  // io.Init();
62
+  delay(100);
63
+
64
+  #if TFT_DRIVER != AUTO
65
+    lcd_id = TFT_DRIVER;
66
+  #endif
67
+
68
+  #if TFT_DRIVER == ST7735
69
+    write_esc_sequence(st7735_init);
70
+  #elif TFT_DRIVER == SSD1963
71
+    write_esc_sequence(ssd1963_init);
72
+  #elif TFT_DRIVER == ST7789
73
+    write_esc_sequence(st7789v_init);
74
+  #elif TFT_DRIVER == ST7796
75
+    write_esc_sequence(st7796s_init);
76
+  #elif TFT_DRIVER == R61505
77
+    write_esc_sequence(r61505_init);
78
+  #elif TFT_DRIVER == ILI9328
79
+    write_esc_sequence(ili9328_init);
80
+  #elif TFT_DRIVER == ILI9341
81
+    write_esc_sequence(ili9341_init);
82
+  #elif TFT_DRIVER == ILI9488
83
+    write_esc_sequence(ili9488_init);
84
+  #elif TFT_DRIVER == LERDGE_ST7796
85
+    lcd_id = ST7796;
86
+    write_esc_sequence(lerdge_st7796s_init);
87
+
88
+  #elif TFT_DRIVER == AUTO // autodetect
89
+
90
+    lcd_id = io.GetID() & 0xFFFF;
91
+
92
+    switch (lcd_id) {
93
+      case ST7796:    // ST7796S    480x320
94
+        DEBUG_ECHO_MSG(" ST7796S");
95
+        write_esc_sequence(st7796s_init);
96
+        break;
97
+      case ST7789:    // ST7789V    320x240
98
+        DEBUG_ECHO_MSG(" ST7789V");
99
+        write_esc_sequence(st7789v_init);
100
+        break;
101
+      case SSD1963:    // SSD1963
102
+        DEBUG_ECHO_MSG(" SSD1963");
103
+        write_esc_sequence(ssd1963_init);
104
+        break;
105
+      case ST7735:    // ST7735     160x128
106
+        DEBUG_ECHO_MSG(" ST7735");
107
+        write_esc_sequence(st7735_init);
108
+        break;
109
+      case R61505:    // R61505U    320x240
110
+        DEBUG_ECHO_MSG(" R61505U");
111
+        write_esc_sequence(r61505_init);
112
+        break;
113
+      case ILI9328:   // ILI9328    320x240
114
+        DEBUG_ECHO_MSG(" ILI9328");
115
+        write_esc_sequence(ili9328_init);
116
+        break;
117
+      case ILI9341:   // ILI9341    320x240
118
+        DEBUG_ECHO_MSG(" ILI9341");
119
+        write_esc_sequence(ili9341_init);
120
+        break;
121
+      case ILI9488:   // ILI9488    480x320
122
+      case ILI9488_ID1: // 0x8066 ILI9488    480x320
123
+        DEBUG_ECHO_MSG(" ILI9488");
124
+        write_esc_sequence(ili9488_init);
125
+        break;
126
+      default:
127
+        lcd_id = 0;
128
+    }
129
+  #else
130
+    #error Unsupported TFT driver
131
+  #endif
132
+
133
+  #if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
134
+    OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
135
+  #endif
136
+}
137
+
138
+void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
139
+  #ifdef OFFSET_X
140
+    Xmin += OFFSET_X; Xmax += OFFSET_X;
141
+  #endif
142
+  #ifdef OFFSET_Y
143
+    Ymin += OFFSET_Y; Ymax += OFFSET_Y;
144
+  #endif
145
+
146
+  switch (lcd_id) {
147
+    case ST7735:    // ST7735     160x128
148
+    case ST7789:    // ST7789V    320x240
149
+    case ST7796:    // ST7796     480x320
150
+    case ILI9341:   // ILI9341    320x240
151
+    case ILI9488:   // ILI9488    480x320
152
+    case SSD1963:   // SSD1963
153
+    case ILI9488_ID1: // 0x8066 ILI9488    480x320
154
+      io.DataTransferBegin(DATASIZE_8BIT);
155
+
156
+      // CASET: Column Address Set
157
+      io.WriteReg(ILI9341_CASET);
158
+      io.WriteData((Xmin >> 8) & 0xFF);
159
+      io.WriteData(Xmin & 0xFF);
160
+      io.WriteData((Xmax >> 8) & 0xFF);
161
+      io.WriteData(Xmax & 0xFF);
162
+
163
+      // RASET: Row Address Set
164
+      io.WriteReg(ILI9341_PASET);
165
+      io.WriteData((Ymin >> 8) & 0xFF);
166
+      io.WriteData(Ymin & 0xFF);
167
+      io.WriteData((Ymax >> 8) & 0xFF);
168
+      io.WriteData(Ymax & 0xFF);
169
+
170
+      // RAMWR: Memory Write
171
+      io.WriteReg(ILI9341_RAMWR);
172
+      break;
173
+    case R61505:    // R61505U    320x240
174
+    case ILI9328:   // ILI9328    320x240
175
+      io.DataTransferBegin(DATASIZE_16BIT);
176
+
177
+      // Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
178
+      io.WriteReg(ILI9328_HASTART);
179
+      io.WriteData(Ymin);
180
+      io.WriteReg(ILI9328_HAEND);
181
+      io.WriteData(Ymax);
182
+      io.WriteReg(ILI9328_VASTART);
183
+      io.WriteData(Xmin);
184
+      io.WriteReg(ILI9328_VAEND);
185
+      io.WriteData(Xmax);
186
+
187
+      io.WriteReg(ILI9328_HASET);
188
+      io.WriteData(Ymin);
189
+      io.WriteReg(ILI9328_VASET);
190
+      io.WriteData(Xmin);
191
+
192
+      io.WriteReg(ILI9328_RAMWR);
193
+      break;
194
+    default:
195
+      break;
196
+  }
197
+
198
+  io.DataTransferEnd();
199
+}
200
+
201
+void TFT_IO::write_esc_sequence(const uint16_t *Sequence) {
202
+  uint16_t dataWidth, data;
203
+
204
+  dataWidth = *Sequence++;
205
+  io.DataTransferBegin(dataWidth);
206
+
207
+  for (;;) {
208
+    data = *Sequence++;
209
+    if (data != 0xFFFF) {
210
+      io.WriteData(data);
211
+      continue;
212
+    }
213
+    data = *Sequence++;
214
+    if (data == 0x7FFF) return;
215
+    if (data == 0xFFFF)
216
+      io.WriteData(0xFFFF);
217
+    else if (data & 0x8000)
218
+      delay(data & 0x7FFF);
219
+    else if ((data & 0xFF00) == 0)
220
+      io.WriteReg(data);
221
+  }
222
+
223
+  io.DataTransferEnd();
224
+}
225
+
226
+#endif // HAS_SPI_TFT || HAS_FSMC_TFT

+ 124
- 0
Marlin/src/lcd/tft_io/tft_io.h View File

@@ -0,0 +1,124 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../../inc/MarlinConfig.h"
25
+
26
+#if HAS_SPI_TFT || HAS_FSMC_TFT
27
+
28
+#if HAS_SPI_TFT
29
+  #include HAL_PATH(../../HAL, tft/tft_spi.h)
30
+#elif HAS_FSMC_TFT
31
+  #include HAL_PATH(../../HAL, tft/tft_fsmc.h)
32
+#else
33
+  #error "TFT IO only supports SPI or FSMC interface"
34
+#endif
35
+
36
+#define TFT_EXCHANGE_XY (1UL << 1)
37
+#define TFT_INVERT_X    (1UL << 2)
38
+#define TFT_INVERT_Y    (1UL << 3)
39
+
40
+#define TFT_NO_ROTATION           (0x00)
41
+#define TFT_ROTATE_90             (TFT_EXCHANGE_XY | TFT_INVERT_X)
42
+#define TFT_ROTATE_180            (TFT_INVERT_X    | TFT_INVERT_Y)
43
+#define TFT_ROTATE_270            (TFT_EXCHANGE_XY | TFT_INVERT_Y)
44
+
45
+#define TFT_MIRROR_X              (TFT_INVERT_Y)
46
+#define TFT_MIRROR_Y              (TFT_INVERT_X)
47
+
48
+#define TFT_ROTATE_90_MIRROR_X    (TFT_ROTATE_90 ^ TFT_INVERT_Y)
49
+#define TFT_ROTATE_90_MIRROR_Y    (TFT_ROTATE_90 ^ TFT_INVERT_X)
50
+
51
+#define TFT_ROTATE_180_MIRROR_X   (TFT_ROTATE_180 ^ TFT_INVERT_Y)
52
+#define TFT_ROTATE_180_MIRROR_Y   (TFT_ROTATE_180 ^ TFT_INVERT_X)
53
+
54
+#define TFT_ROTATE_270_MIRROR_X   (TFT_ROTATE_270 ^ TFT_INVERT_Y)
55
+#define TFT_ROTATE_270_MIRROR_Y   (TFT_ROTATE_270 ^ TFT_INVERT_X)
56
+
57
+// TFT_ROTATION is user configurable
58
+#ifndef TFT_ROTATION
59
+  #define TFT_ROTATION TFT_NO_ROTATION
60
+#endif
61
+
62
+
63
+// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
64
+#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
65
+
66
+#define TFT_COLOR_RGB   (1UL << 3)
67
+#define TFT_COLOR_BGR   (1UL << 4)
68
+
69
+// Each TFT Driver is responsible for its default color mode.
70
+// #ifndef TFT_COLOR
71
+//   #define TFT_COLOR   TFT_COLOR_RGB
72
+// #endif
73
+
74
+#define SSD1963         0x5761
75
+#define ST7735          0x89F0
76
+#define ST7789          0x8552
77
+#define ST7796          0x7796
78
+#define R61505          0x1505
79
+#define ILI9328         0x9328
80
+#define ILI9341         0x9341
81
+#define ILI9488         0x9488
82
+#define ILI9488_ID1     0x8066 //Some ILI9488 have 0x8066 in the 0x04
83
+#define LERDGE_ST7796   0xFFFE
84
+#define AUTO            0xFFFF
85
+
86
+#ifndef TFT_DRIVER
87
+  #define TFT_DRIVER    AUTO
88
+#endif
89
+
90
+#define ESC_REG(x)        0xFFFF, 0x00FF & (uint16_t)x
91
+#define ESC_DELAY(x)      0xFFFF, 0x8000 | (x & 0x7FFF)
92
+#define ESC_END           0xFFFF, 0x7FFF
93
+#define ESC_FFFF          0xFFFF, 0xFFFF
94
+
95
+class TFT_IO {
96
+public:
97
+  static TFT_IO_DRIVER io;
98
+
99
+  static void InitTFT();
100
+  static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
101
+  static void write_esc_sequence(const uint16_t *Sequence);
102
+
103
+  // Deletaged methods
104
+  inline static void Init() { io.Init(); };
105
+  inline static bool isBusy() { return io.isBusy(); };
106
+  inline static void Abort() { io.Abort(); };
107
+  inline static uint32_t GetID() { return io.GetID(); };
108
+
109
+  inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); }
110
+  inline static void DataTransferEnd() { io.DataTransferEnd(); };
111
+  // inline static void DataTransferAbort() { io.DataTransferAbort(); };
112
+
113
+  inline static void WriteData(uint16_t Data) { io.WriteData(Data); };
114
+  inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); };
115
+
116
+  inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); };
117
+  // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
118
+  inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); };
119
+
120
+protected:
121
+  static uint32_t lcd_id;
122
+};
123
+
124
+#endif // HAS_SPI_TFT || HAS_FSMC_TFT

+ 1
- 1
Marlin/src/lcd/touch/touch_buttons.cpp View File

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

+ 25
- 6
Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h View File

@@ -296,25 +296,44 @@
296 296
     #ifndef GRAPHICAL_TFT_UPSCALE
297 297
       #define GRAPHICAL_TFT_UPSCALE            3
298 298
     #endif
299
+    // SPI 1
300
+    #define SCK_PIN                        P0_15
301
+    #define MISO_PIN                       P0_17
302
+    #define MOSI_PIN                       P0_18
299 303
 
300 304
     // Disable any LCD related PINs config
301 305
     #define LCD_PINS_ENABLE                -1
302 306
     #define LCD_PINS_RS                    -1
303 307
 
304
-    // Emulated DOGM have xpt calibration values independent of display resolution
305
-    #if ENABLED(SPI_GRAPHICAL_TFT)
308
+    // XPT2046 Touch Screen calibration
309
+    #if ENABLED(TFT_CLASSIC_UI)
306 310
       #ifndef XPT2046_X_CALIBRATION
307
-        #define XPT2046_X_CALIBRATION    -11245
311
+        #define XPT2046_X_CALIBRATION     -11245
308 312
       #endif
309 313
       #ifndef XPT2046_Y_CALIBRATION
310
-        #define XPT2046_Y_CALIBRATION      8629
314
+        #define XPT2046_Y_CALIBRATION       8629
311 315
       #endif
312 316
       #ifndef XPT2046_X_OFFSET
313
-        #define XPT2046_X_OFFSET            685
317
+        #define XPT2046_X_OFFSET             685
314 318
       #endif
315 319
       #ifndef XPT2046_Y_OFFSET
316
-        #define XPT2046_Y_OFFSET           -285
320
+        #define XPT2046_Y_OFFSET            -285
317 321
       #endif
322
+    #elif ENABLED(TFT_480x320_SPI)
323
+      #ifndef XPT2046_X_CALIBRATION
324
+        #define XPT2046_X_CALIBRATION     -17232
325
+      #endif
326
+      #ifndef XPT2046_Y_CALIBRATION
327
+        #define XPT2046_Y_CALIBRATION      11196
328
+      #endif
329
+      #ifndef XPT2046_X_OFFSET
330
+        #define XPT2046_X_OFFSET            1047
331
+      #endif
332
+      #ifndef XPT2046_Y_OFFSET
333
+        #define XPT2046_Y_OFFSET            -358
334
+      #endif
335
+
336
+      #define TFT_BUFFER_SIZE               2400
318 337
     #endif
319 338
 
320 339
   #elif IS_TFTGLCD_PANEL

+ 1
- 1
Marlin/src/pins/lpc1768/pins_MKS_SBASE.h View File

@@ -220,7 +220,7 @@
220 220
 #if IS_TFTGLCD_PANEL
221 221
 
222 222
   #if ENABLED(TFTGLCD_PANEL_SPI)
223
-    #define   TFTGLCD_CS                   P3_25  // EXP2.3
223
+    #define TFTGLCD_CS                     P3_25  // EXP2.3
224 224
   #endif
225 225
 
226 226
   #if SD_CONNECTION_IS(LCD)

+ 1
- 1
Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h View File

@@ -371,7 +371,7 @@
371 371
   #endif
372 372
 
373 373
   #if ANY(VIKI2, miniVIKI)
374
-    // #define LCD_SCREEN_ROT_180
374
+    //#define LCD_SCREEN_ROT_180
375 375
 
376 376
     #define DOGLCD_CS                      P0_16  // (16)
377 377
     #define DOGLCD_A0                      P2_06  // (59) J3-8 & AUX-2

+ 1
- 1
Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h View File

@@ -161,7 +161,7 @@
161 161
 //
162 162
 #define TEMP_0_PIN                         P0_24
163 163
 #define TEMP_1_PIN                         P0_23
164
-//#define TEMP_2_PIN                       P1_30   // Onboard thermistor
164
+//#define TEMP_2_PIN                       P1_30  // Onboard thermistor
165 165
 #define TEMP_BED_PIN                       P0_25
166 166
 
167 167
 //

+ 2
- 2
Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h View File

@@ -39,7 +39,7 @@
39 39
   //#define SDCARD_EEPROM_EMULATION
40 40
   //#define I2C_EEPROM                            // AT24C32
41 41
   #define FLASH_EEPROM_EMULATION
42
-  #define MARLIN_EEPROM_SIZE 0x1000               // 4KB
42
+  #define MARLIN_EEPROM_SIZE              0x1000  // 4KB
43 43
 #endif
44 44
 
45 45
 //
@@ -190,7 +190,7 @@
190 190
   #define E1_SERIAL_RX_PIN                 P1_17
191 191
 
192 192
   // Reduce baud rate to improve software serial reliability
193
-  #define TMC_BAUD_RATE 19200
193
+  #define TMC_BAUD_RATE                    19200
194 194
 #endif // HAS_TMC_UART
195 195
 
196 196
 //

+ 6
- 12
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h View File

@@ -129,8 +129,6 @@
129 129
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
130 130
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
131 131
 
132
-  #define LCD_RESET_PIN                     PF11
133
-  #define LCD_BACKLIGHT_PIN                 PD13
134 132
   #define TFT_RESET_PIN                     PF11
135 133
   #define TFT_BACKLIGHT_PIN                 PD13
136 134
 
@@ -140,14 +138,9 @@
140 138
   #define FSMC_DMA_DEV                      DMA2
141 139
   #define FSMC_DMA_CHANNEL               DMA_CH5
142 140
 
143
-  #define TFT_WIDTH                          480
144
-  #define TFT_HEIGHT                         320
145
-  #define TFT_PIXEL_OFFSET_X                  48
146
-  #define TFT_PIXEL_OFFSET_Y                  32
147
-
148 141
 #endif
149 142
 
150
-#if HAS_TFT_LVGL_UI
143
+#if ENABLED(TFT_LVGL_UI)
151 144
   // LVGL
152 145
   #define HAS_SPI_FLASH_FONT                   1
153 146
   #define HAS_GCODE_PREVIEW                    1
@@ -155,16 +148,17 @@
155 148
   #define HAS_LANG_SELECT_SCREEN               1
156 149
   #define HAS_BAK_VIEW_IN_FLASH                0
157 150
   #define HAS_LOGO_IN_FLASH                    0
158
-#elif ENABLED(TFT_480x320)
151
+#elif ENABLED(TFT_COLOR_UI)
159 152
   // Color UI
160 153
   #define TFT_DRIVER                     ILI9488
161 154
   #define TFT_BUFFER_SIZE                  14400
162
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
155
+#elif ENABLED(TFT_CLASSIC_UI)
163 156
   // Emulated DOGM
164 157
   #define GRAPHICAL_TFT_UPSCALE                3
165 158
 #endif
166 159
 
167
-#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320)
160
+// XPT2046 Touch Screen calibration
161
+#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
168 162
   #ifndef XPT2046_X_CALIBRATION
169 163
     #define XPT2046_X_CALIBRATION         -17181
170 164
   #endif
@@ -177,7 +171,7 @@
177 171
   #ifndef XPT2046_Y_OFFSET
178 172
     #define XPT2046_Y_OFFSET                  -9
179 173
   #endif
180
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
174
+#elif ENABLED(TFT_CLASSIC_UI)
181 175
   #ifndef XPT2046_X_CALIBRATION
182 176
     #define XPT2046_X_CALIBRATION         -12316
183 177
   #endif

+ 9
- 13
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h View File

@@ -135,15 +135,15 @@
135 135
 // TronXY TFT Support
136 136
 //
137 137
 
138
-// Shared FSMC Configs
139 138
 #if HAS_FSMC_TFT
139
+
140
+  // Shared FSMC
141
+
140 142
   #define TOUCH_CS_PIN                      PB7   // SPI1_NSS
141 143
   #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
142 144
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
143 145
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
144 146
 
145
-  #define LCD_RESET_PIN                     PF11
146
-  #define LCD_BACKLIGHT_PIN                 PD13
147 147
   #define TFT_RESET_PIN                     PF11
148 148
   #define TFT_BACKLIGHT_PIN                 PD13
149 149
 
@@ -153,14 +153,9 @@
153 153
   #define FSMC_DMA_DEV                      DMA2
154 154
   #define FSMC_DMA_CHANNEL               DMA_CH5
155 155
 
156
-  #define TFT_WIDTH                          480
157
-  #define TFT_HEIGHT                         320
158
-  #define TFT_PIXEL_OFFSET_X                  48
159
-  #define TFT_PIXEL_OFFSET_Y                  32
160
-
161 156
 #endif
162 157
 
163
-#if HAS_TFT_LVGL_UI
158
+#if ENABLED(TFT_LVGL_UI)
164 159
   // LVGL
165 160
   #define HAS_SPI_FLASH_FONT                   1
166 161
   #define HAS_GCODE_PREVIEW                    1
@@ -168,16 +163,17 @@
168 163
   #define HAS_LANG_SELECT_SCREEN               1
169 164
   #define HAS_BAK_VIEW_IN_FLASH                0
170 165
   #define HAS_LOGO_IN_FLASH                    0
171
-#elif ENABLED(TFT_480x320)
166
+#elif ENABLED(TFT_COLOR_UI)
172 167
   // Color UI
173 168
   #define TFT_DRIVER                     ILI9488
174 169
   #define TFT_BUFFER_SIZE                  14400
175
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
170
+#elif ENABLED(TFT_CLASSIC_UI)
176 171
   // Emulated DOGM
177 172
   #define GRAPHICAL_TFT_UPSCALE                3
178 173
 #endif
179 174
 
180
-#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320)
175
+// XPT2046 Touch Screen calibration
176
+#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
181 177
   #ifndef XPT2046_X_CALIBRATION
182 178
     #define XPT2046_X_CALIBRATION         -17181
183 179
   #endif
@@ -190,7 +186,7 @@
190 186
   #ifndef XPT2046_Y_OFFSET
191 187
     #define XPT2046_Y_OFFSET                  -9
192 188
   #endif
193
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
189
+#elif ENABLED(TFT_CLASSIC_UI)
194 190
   #ifndef XPT2046_X_CALIBRATION
195 191
     #define XPT2046_X_CALIBRATION         -12316
196 192
   #endif

+ 1
- 1
Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h View File

@@ -39,7 +39,7 @@
39 39
   #define STM32_XL_DENSITY
40 40
 #endif
41 41
 
42
-// #define MCU_STM32F103ZE // not yet required
42
+//#define MCU_STM32F103ZE // not yet required
43 43
 // Enable EEPROM Emulation for this board, so that we don't overwrite factory data
44 44
 
45 45
 //#define I2C_EEPROM                              // AT24C64

+ 4
- 7
Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h View File

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

+ 2
- 2
Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h View File

@@ -143,8 +143,8 @@
143 143
   #define LCD_BACKLIGHT_PIN                 PG11
144 144
   #define FSMC_CS_PIN                       PG12  // NE4
145 145
   #define FSMC_RS_PIN                       PF0   // A0
146
-  #define TFT_CS_PIN                        FSMC_CS_PIN
147
-  #define TFT_RS_PIN                        FSMC_RS_PIN
146
+  #define TFT_CS_PIN                 FSMC_CS_PIN
147
+  #define TFT_RS_PIN                 FSMC_RS_PIN
148 148
 
149 149
   #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
150 150
   #define FSMC_DMA_DEV                      DMA2

+ 1
- 0
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h View File

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

+ 6
- 55
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h View File

@@ -171,6 +171,9 @@
171 171
 
172 172
 // Shared FSMC Configs
173 173
 #if HAS_FSMC_TFT
174
+  #define DOGLCD_MOSI                       -1    // prevent redefine Conditionals_post.h
175
+  #define DOGLCD_SCK                        -1
176
+
174 177
   #define FSMC_CS_PIN                       PD7   // NE4
175 178
   #define FSMC_RS_PIN                       PD11  // A0
176 179
 
@@ -179,9 +182,6 @@
179 182
   #define TOUCH_MISO_PIN                    PB14  // SPI2_MISO
180 183
   #define TOUCH_MOSI_PIN                    PB15  // SPI2_MOSI
181 184
 
182
-  #define LCD_RESET_PIN                     PC6   // FSMC_RST
183
-  #define LCD_BACKLIGHT_PIN                 PD13
184
-
185 185
   #define TFT_RESET_PIN                     PC6   // FSMC_RST
186 186
   #define TFT_BACKLIGHT_PIN                 PD13
187 187
 
@@ -193,60 +193,11 @@
193 193
 
194 194
   #define TOUCH_BUTTONS_HW_SPI
195 195
   #define TOUCH_BUTTONS_HW_SPI_DEVICE          2
196
-#endif
197
-
198
-#if ENABLED(FSMC_GRAPHICAL_TFT)
199
-  // Emulated DOGM
200
-  #define DOGLCD_MOSI                       -1    // prevent redefine Conditionals_post.h
201
-  #define DOGLCD_SCK                        -1
202
-
203
-  #ifndef GRAPHICAL_TFT_UPSCALE
204
-    #define GRAPHICAL_TFT_UPSCALE              3
205
-  #endif
206
-  #ifndef TFT_WIDTH
207
-    #define TFT_WIDTH                        480
208
-  #endif
209
-  #ifndef TFT_PIXEL_OFFSET_X
210
-    #define TFT_PIXEL_OFFSET_X                48
211
-  #endif
212
-  #ifndef TFT_HEIGHT
213
-    #define TFT_HEIGHT                       320
214
-  #endif
215
-  #ifndef TFT_PIXEL_OFFSET_Y
216
-    #define TFT_PIXEL_OFFSET_Y                32
217
-  #endif
218
-
219
-#elif ENABLED(TFT_320x240)                        // TFT32/28
220
-  #define TFT_RESET_PIN                     PC6
221
-  #define TFT_BACKLIGHT_PIN                 PD13
222
-
223
-  #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
224
-  #define FSMC_CS_PIN                       PD7
225
-  #define FSMC_RS_PIN                       PD11
226
-  #define FSMC_DMA_DEV                      DMA2
227
-  #define FSMC_DMA_CHANNEL               DMA_CH5
228
-
229
-  #define TOUCH_CS_PIN                      PA7   // SPI2_NSS
230
-  #define TOUCH_SCK_PIN                     PB13  // SPI2_SCK
231
-  #define TOUCH_MISO_PIN                    PB14  // SPI2_MISO
232
-  #define TOUCH_MOSI_PIN                    PB15  // SPI2_MOSI
233
-
234
-  #define TFT_DRIVER                     ILI9341
235
-  #define TFT_BUFFER_SIZE                  14400
236
-
237
-  // YV for normal screen mounting
238
-  //#define ILI9341_ORIENTATION  ILI9341_MADCTL_MY | ILI9341_MADCTL_MV
239
-  // XV for 180° rotated screen mounting
240
-  #define ILI9341_ORIENTATION  ILI9341_MADCTL_MX | ILI9341_MADCTL_MV
241
-
242
-  #define ILI9341_COLOR_RGB
243 196
 
244
-#elif ENABLED(TFT_480x320)
245
-  #define TFT_DRIVER                     ILI9488
246 197
   #define TFT_BUFFER_SIZE                  14400
247
-  #define ILI9488_ORIENTATION               ILI9488_MADCTL_MX | ILI9488_MADCTL_MV
248 198
 #endif
249 199
 
200
+// XPT2046 Touch Screen calibration
250 201
 #if EITHER(TFT_LVGL_UI_FSMC, TFT_480x320)
251 202
   #ifndef XPT2046_X_CALIBRATION
252 203
     #define XPT2046_X_CALIBRATION          17880
@@ -260,7 +211,7 @@
260 211
   #ifndef XPT2046_Y_OFFSET
261 212
    #define XPT2046_Y_OFFSET                  349
262 213
   #endif
263
-#elif ENABLED(FSMC_GRAPHICAL_TFT)
214
+#elif ENABLED(TFT_CLASSIC_UI)
264 215
   #ifndef XPT2046_X_CALIBRATION
265 216
     #define XPT2046_X_CALIBRATION          12149
266 217
   #endif
@@ -273,7 +224,7 @@
273 224
   #ifndef XPT2046_Y_OFFSET
274 225
     #define XPT2046_Y_OFFSET                 256
275 226
   #endif
276
-#elif ENABLED(TFT_320x240)                        // TFT32/28
227
+#elif ENABLED(TFT_320x240)
277 228
   #ifndef XPT2046_X_CALIBRATION
278 229
     #define XPT2046_X_CALIBRATION         -12246
279 230
   #endif

+ 5
- 13
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h View File

@@ -269,19 +269,11 @@
269 269
   #define TOUCH_BUTTONS_HW_SPI
270 270
   #define TOUCH_BUTTONS_HW_SPI_DEVICE          1
271 271
 
272
-  #ifndef TFT_WIDTH
273
-    #define TFT_WIDTH                        480
274
-  #endif
275
-  #ifndef TFT_HEIGHT
276
-    #define TFT_HEIGHT                       320
277
-  #endif
278
-
279
-  #define LCD_READ_ID                       0xD3
280 272
   #define LCD_USE_DMA_SPI
281 273
 
282 274
 #endif
283 275
 
284
-#if ENABLED(SPI_GRAPHICAL_TFT)
276
+#if ENABLED(TFT_CLASSIC_UI)
285 277
   // Emulated DOGM SPI
286 278
   #ifndef GRAPHICAL_TFT_UPSCALE
287 279
     #define GRAPHICAL_TFT_UPSCALE              3
@@ -297,12 +289,12 @@
297 289
   #define LCD_PINS_ENABLE                   PD13
298 290
   #define LCD_PINS_RS                       PC6
299 291
 
300
-#elif ENABLED(TFT_480x320_SPI)
301
-  #define TFT_DRIVER                      ST7796
292
+#elif ENABLED(TFT_COLOR_UI)
302 293
   #define TFT_BUFFER_SIZE                  14400
303 294
 #endif
304 295
 
305
-#if EITHER(TFT_LVGL_UI_SPI, TFT_480x320_SPI)
296
+// XPT2046 Touch Screen calibration
297
+#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI)
306 298
   #ifndef XPT2046_X_CALIBRATION
307 299
     #define XPT2046_X_CALIBRATION         -17253
308 300
   #endif
@@ -315,7 +307,7 @@
315 307
   #ifndef XPT2046_Y_OFFSET
316 308
     #define XPT2046_Y_OFFSET                 -24
317 309
   #endif
318
-#elif ENABLED(SPI_GRAPHICAL_TFT)
310
+#elif ENABLED(TFT_CLASSIC_UI)
319 311
   #ifndef XPT2046_X_CALIBRATION
320 312
     #define XPT2046_X_CALIBRATION         -11386
321 313
   #endif

+ 44
- 8
Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h View File

@@ -120,14 +120,50 @@
120 120
  * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu
121 121
  * because Marlin uses the reset as a failsafe to revive a glitchy LCD.
122 122
  */
123
-#define LCD_RESET_PIN                       PF11
124
-#define LCD_BACKLIGHT_PIN                   PD13
125
-#define FSMC_CS_PIN                         PD7   // NE4
126
-#define FSMC_RS_PIN                         PD11  // A0
127
-
128
-#define LCD_USE_DMA_FSMC                          // Use DMA transfers to send data to the TFT
129
-#define FSMC_DMA_DEV                        DMA2
130
-#define FSMC_DMA_CHANNEL                 DMA_CH5
123
+#if HAS_FSMC_TFT
124
+  #define TFT_RESET_PIN                     PF11
125
+  #define TFT_BACKLIGHT_PIN                 PD13
126
+  #define FSMC_CS_PIN                       PD7   // NE4
127
+  #define FSMC_RS_PIN                       PD11  // A0
128
+
129
+  #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
130
+  #define FSMC_DMA_DEV                      DMA2
131
+  #define FSMC_DMA_CHANNEL               DMA_CH5
132
+
133
+  #define ANYCUBIC_TFT35
134
+#else
135
+  #define LCD_RESET_PIN                     PF11
136
+  #define LCD_BACKLIGHT_PIN                 PD13
137
+#endif
138
+
139
+// XPT2046 Touch Screen calibration
140
+#if ENABLED(TFT_COLOR_UI) || ENABLED(TFT_LVGL_UI)
141
+  #ifndef XPT2046_X_CALIBRATION
142
+    #define XPT2046_X_CALIBRATION         -17181
143
+  #endif
144
+  #ifndef XPT2046_Y_CALIBRATION
145
+    #define XPT2046_Y_CALIBRATION          11434
146
+  #endif
147
+  #ifndef XPT2046_X_OFFSET
148
+    #define XPT2046_X_OFFSET                 501
149
+  #endif
150
+  #ifndef XPT2046_Y_OFFSET
151
+    #define XPT2046_Y_OFFSET                  -9
152
+  #endif
153
+#elif ENABLED(TFT_CLASSIC_UI)
154
+  #ifndef XPT2046_X_CALIBRATION
155
+    #define XPT2046_X_CALIBRATION         -12316
156
+  #endif
157
+  #ifndef XPT2046_Y_CALIBRATION
158
+    #define XPT2046_Y_CALIBRATION           8981
159
+  #endif
160
+  #ifndef XPT2046_X_OFFSET
161
+    #define XPT2046_X_OFFSET                 340
162
+  #endif
163
+  #ifndef XPT2046_Y_OFFSET
164
+    #define XPT2046_Y_OFFSET                 -20
165
+  #endif
166
+#endif
131 167
 
132 168
 #if NEED_TOUCH_PINS
133 169
   #define TOUCH_CS_PIN                      PB7   // SPI2_NSS

+ 3
- 3
Marlin/src/pins/teensy4/pins_T41U5XBB.h View File

@@ -85,17 +85,17 @@
85 85
 #define X_STEP_PIN                             2
86 86
 #define X_DIR_PIN                              3
87 87
 #define X_ENABLE_PIN                          10
88
-//#define X_CS_PIN                              30
88
+//#define X_CS_PIN                            30
89 89
 
90 90
 #define Y_STEP_PIN                             4
91 91
 #define Y_DIR_PIN                              5
92 92
 #define Y_ENABLE_PIN                          40
93
-//#define Y_CS_PIN                              31
93
+//#define Y_CS_PIN                            31
94 94
 
95 95
 #define Z_STEP_PIN                             6
96 96
 #define Z_DIR_PIN                              7
97 97
 #define Z_ENABLE_PIN                          39
98
-//#define Z_CS_PIN                              32
98
+//#define Z_CS_PIN                            32
99 99
 
100 100
 #define E0_STEP_PIN                            8
101 101
 #define E0_DIR_PIN                             9

+ 5
- 5
Marlin/src/pins/teensy4/pins_TEENSY41.h View File

@@ -81,17 +81,17 @@
81 81
 #define X_STEP_PIN                             0
82 82
 #define X_DIR_PIN                              1
83 83
 #define X_ENABLE_PIN                           6
84
-//#define X_CS_PIN                              30
84
+//#define X_CS_PIN                            30
85 85
 
86 86
 #define Y_STEP_PIN                             2
87 87
 #define Y_DIR_PIN                              3
88 88
 #define Y_ENABLE_PIN                           7
89
-//#define Y_CS_PIN                              31
89
+//#define Y_CS_PIN                            31
90 90
 
91 91
 #define Z_STEP_PIN                             4
92 92
 #define Z_DIR_PIN                              5
93 93
 #define Z_ENABLE_PIN                           8
94
-//#define Z_CS_PIN                              32
94
+//#define Z_CS_PIN                            32
95 95
 
96 96
 #define E0_STEP_PIN                            9
97 97
 #define E0_DIR_PIN                            10
@@ -123,8 +123,8 @@
123 123
 //
124 124
 #define LED_PIN                               13
125 125
 #define SOL0_PIN                              28
126
-//#define PS_ON_PIN                              1
127
-//#define FILWIDTH_PIN                           6  // A6
126
+//#define PS_ON_PIN                            1
127
+//#define FILWIDTH_PIN                         6  // A6
128 128
 
129 129
 #ifndef SDCARD_CONNECTION
130 130
   #define SDCARD_CONNECTION              ONBOARD

+ 2
- 4
platformio.ini View File

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

Loading…
Cancel
Save