Skip to content

Commit

Permalink
✨ BigTreeTech TFT35 SPI V1.0 (#22986)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisiskeithb authored and thinkyhead committed Dec 25, 2021
1 parent e44f2b7 commit 5173a31
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 25 deletions.
21 changes: 13 additions & 8 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2636,32 +2636,32 @@
*/

//
// 480x320, 3.5", SPI Display From MKS
// Normally used in MKS Robin Nano V2
// 480x320, 3.5", SPI Display with Rotary Encoder from MKS
// Usually paired with MKS Robin Nano V2 & V3
//
//#define MKS_TS35_V2_0

//
// 320x240, 2.4", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT24

//
// 320x240, 2.8", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT28

//
// 320x240, 3.2", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT32

//
// 480x320, 3.5", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT35

Expand All @@ -2672,7 +2672,7 @@

//
// 320x240, 3.2", FSMC Display From MKS
// Normally used in MKS Robin
// Usually paired with MKS Robin
//
//#define MKS_ROBIN_TFT_V1_1R

Expand Down Expand Up @@ -2702,10 +2702,15 @@
//#define ANET_ET5_TFT35

//
// 1024x600, 7", RGB Stock Display from BIQU-BX
// 1024x600, 7", RGB Stock Display with Rotary Encoder from BIQU-BX
//
//#define BIQU_BX_TFT70

//
// 480x320, 3.5", SPI Stock Display with Rotary Encoder from BIQU B1 SE Series
//
//#define BTT_TFT35_SPI_V1_0

//
// Generic TFT with detailed options
//
Expand Down
32 changes: 31 additions & 1 deletion Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

#endif

// Macros to chain up to 14 conditions
// Macros to chain up to 40 conditions
#define _DO_1(W,C,A) (_##W##_1(A))
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
Expand All @@ -176,6 +176,31 @@
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
Expand Down Expand Up @@ -251,6 +276,11 @@
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
}while(0)

#define CODE_16( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O; P
#define CODE_15( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O
#define CODE_14( A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N
#define CODE_13( A,B,C,D,E,F,G,H,I,J,K,L,M,...) A; B; C; D; E; F; G; H; I; J; K; L; M
#define CODE_12( A,B,C,D,E,F,G,H,I,J,K,L,...) A; B; C; D; E; F; G; H; I; J; K; L
#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1241,20 +1241,20 @@
* - TFT_COLOR
* - GRAPHICAL_TFT_UPSCALE
*/
#if ENABLED(MKS_TS35_V2_0) // ST7796
#if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) // ST7796
#define TFT_DEFAULT_DRIVER ST7796
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_480x320
#define TFT_INTERFACE_SPI
#elif EITHER(LERDGE_TFT35, ANET_ET5_TFT35) // ST7796
#elif EITHER(LERDGE_TFT35, ANET_ET5_TFT35) // ST7796
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_480x320
#define TFT_INTERFACE_FSMC
#elif ANY(ANET_ET4_TFT28, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32) // ST7789
#elif ANY(ANET_ET4_TFT28, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32) // ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ANY(MKS_ROBIN_TFT35, TFT_TRONXY_X5SA, ANYCUBIC_TFT35) // ILI9488
#elif ANY(MKS_ROBIN_TFT35, TFT_TRONXY_X5SA, ANYCUBIC_TFT35) // ILI9488
#define TFT_DRIVER ILI9488
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_RES_480x320
Expand All @@ -1264,11 +1264,11 @@
#define TFT_DEFAULT_ORIENTATION 0
#define TFT_RES_480x272
#define TFT_INTERFACE_FSMC
#elif ANY(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505
#elif ANY(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(BIQU_BX_TFT70) // RGB
#elif ENABLED(BIQU_BX_TFT70) // RGB
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_1024x600
#define TFT_INTERFACE_LTDC
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
+ COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
+ COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \
+ COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, ANET_ET4_TFT28, ANET_ET5_TFT35) \
+ COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70, BTT_TFT35_SPI_V1_0) \
+ COUNT_ENABLED(TFTGLCD_PANEL_SPI, TFTGLCD_PANEL_I2C) \
+ COUNT_ENABLED(VIKI2, miniVIKI) \
+ COUNT_ENABLED(ZONESTAR_12864LCD, ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) \
Expand Down Expand Up @@ -2669,7 +2669,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#undef IS_U8GLIB_SSD1306
#undef IS_EXTUI

#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70)
#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70, BTT_TFT35_SPI_V1_0)
#if NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI)
#error "TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI is required for your TFT. Please enable one."
#elif MANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI)
Expand Down Expand Up @@ -2711,6 +2711,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW."
#endif

#if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD)
#error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader."
#endif

/**
* Ender 3 V2 controller has some limitations
*/
Expand Down
14 changes: 8 additions & 6 deletions Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ TFT_IO tftio;
#include "../marlinui.h"
#endif

#if HAS_TOUCH_BUTTONS
#include "../touch/touch_buttons.h"
#if HAS_TOUCH_SLEEP
#define HAS_TOUCH_BUTTONS_SLEEP 1
#endif
#if HAS_TOUCH_BUTTONS && HAS_TOUCH_SLEEP
#define HAS_TOUCH_BUTTONS_SLEEP 1
#endif

#include "../touch/touch_buttons.h"
#include "../scaled_tft.h"

#define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1)
#define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1)

Expand Down Expand Up @@ -325,6 +325,7 @@ static bool preinit = true;
static uint8_t page;

#if HAS_TOUCH_BUTTONS

static bool redrawTouchButtons = true;
static void drawTouchButtons(u8g_t *u8g, u8g_dev_t *dev) {
if (!redrawTouchButtons) return;
Expand All @@ -343,6 +344,7 @@ static uint8_t page;
setWindow(u8g, dev, BUTTONC_X_LO, BUTTON_Y_LO, BUTTONC_X_HI, BUTTON_Y_HI);
drawImage(buttonC, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTOKMENU_COLOR);
}

#endif // HAS_TOUCH_BUTTONS

static void u8g_upscale_clear_lcd(u8g_t *u8g, u8g_dev_t *dev, uint16_t *buffer) {
Expand Down Expand Up @@ -395,7 +397,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
if (!sleepCleared) {
sleepCleared = true;
u8g_upscale_clear_lcd(u8g, dev, buffer);
IF_ENABLED(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
}
break;
}
Expand Down
28 changes: 28 additions & 0 deletions Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,34 @@
#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V)
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "../../../inc/MarlinConfig.h"
#include "SPIFlashStorage.h"

#if !HAS_SPI_FLASH
#error "HAS_SPI_FLASH is required with TFT_LVGL_UI."
#endif

extern W25QXXFlash W25QXX;

uint8_t SPIFlashStorage::m_pageData[SPI_FLASH_PageSize];
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@

// SPI Flash
#define HAS_SPI_FLASH 1
#define SPI_FLASH_SIZE 0x1000000 // 16MB

#if HAS_SPI_FLASH
// SPI 2
#define SPI_FLASH_CS_PIN PB12 // SPI2_NSS / Flash chip-select
#define SPI_FLASH_MOSI_PIN PB15
#define SPI_FLASH_MISO_PIN PB14
#define SPI_FLASH_SCK_PIN PB13
#define SPI_FLASH_SIZE 0x1000000 // 16MB
#endif

//
Expand Down
21 changes: 21 additions & 0 deletions Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,27 @@
#endif
#endif

#if HAS_SPI_TFT
//
// e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE)
//
#define TFT_CS_PIN EXP2_07_PIN
#define TFT_A0_PIN EXP2_04_PIN
#define TFT_SCK_PIN EXP2_09_PIN
#define TFT_MISO_PIN EXP2_10_PIN
#define TFT_MOSI_PIN EXP2_05_PIN

#define TOUCH_INT_PIN EXP1_04_PIN
#define TOUCH_MISO_PIN EXP1_05_PIN
#define TOUCH_MOSI_PIN EXP1_08_PIN
#define TOUCH_SCK_PIN EXP1_06_PIN
#define TOUCH_CS_PIN EXP1_07_PIN

#define BTN_EN1 EXP2_08_PIN
#define BTN_EN2 EXP2_06_PIN
#define BTN_ENC EXP1_09_PIN
#endif

//
// NeoPixel LED
//
Expand Down

0 comments on commit 5173a31

Please sign in to comment.