Skip to content

Commit

Permalink
🔨 Enhance Lerdge pins, TFTs, and variants (MarlinFirmware#22658)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot authored and pull[bot] committed Oct 4, 2021
1 parent 8f7a428 commit b1097b7
Show file tree
Hide file tree
Showing 28 changed files with 232 additions and 221 deletions.
1 change: 1 addition & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@
//#define TFT_RES_320x240
//#define TFT_RES_480x272
//#define TFT_RES_480x320
//#define TFT_RES_1024x600
#endif

/**
Expand Down
36 changes: 8 additions & 28 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,30 +1219,19 @@
*/
#if ENABLED(MKS_TS35_V2_0) // ST7796
#define TFT_DEFAULT_DRIVER ST7796
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_480x320
#define TFT_INTERFACE_SPI
#elif ENABLED(ANET_ET5_TFT35) // ST7796
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#elif EITHER(LERDGE_TFT35, ANET_ET5_TFT35) // ST7796
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_480x320
#define TFT_INTERFACE_FSMC
#elif ENABLED(ANET_ET4_TFT28) // 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 ENABLED(MKS_ROBIN_TFT24) // ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_TFT28) // ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_TFT32) // ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_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
#define TFT_INTERFACE_FSMC
Expand All @@ -1251,21 +1240,12 @@
#define TFT_DEFAULT_ORIENTATION 0
#define TFT_RES_480x272
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_TFT_V1_1R) // 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 EITHER(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
#define TFT_INTERFACE_FSMC
#elif ENABLED(LONGER_LK_TFT28)
#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
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_DEFAULT_ORIENTATION TFT_EXCHANGE_XY
#define TFT_RES_1024x600
#define TFT_INTERFACE_LTDC
#if ENABLED(TOUCH_SCREEN)
Expand Down
38 changes: 5 additions & 33 deletions Marlin/src/lcd/tft_io/st7796s.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,39 +144,11 @@ static const uint16_t st7796s_init[] = {
ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D,
ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D,

ESC_REG(ST7796S_NORON),
ESC_REG(ST7796S_WRCTRLD), 0x0024,
ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I
ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II
ESC_REG(ST7796S_DISPON),
ESC_END
};

static const uint16_t lerdge_st7796s_init[] = {
DATASIZE_8BIT,
ESC_REG(ST7796S_SWRESET), ESC_DELAY(100),
ESC_REG(ST7796S_SLPOUT), ESC_DELAY(20),

ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I
ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II

ESC_REG(ST7796S_MADCTL), ST7796S_MADCTL_DATA,
ESC_REG(ST7796S_COLMOD), 0x0055,

ESC_REG(ST7796S_DIC), 0x0001, // 1-dot inversion
ESC_REG(ST7796S_EM), 0x00C6,

ESC_REG(ST7796S_PWR2), 0x0015,
ESC_REG(ST7796S_PWR3), 0x00AF,
ESC_REG(ST7796S_VCMPCTL), 0x0022,
ESC_REG(ST7796S_VCMOST), 0x0000,
ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,

/* Gamma Correction. */
ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D,
ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D,

ESC_REG(ST7796S_INVON), // Display inversion ON
#if ENABLED(ST7796S_INVERTED)
ESC_REG(ST7796S_INVON), // Display inversion ON
#else
ESC_REG(ST7796S_NORON),
#endif
ESC_REG(ST7796S_WRCTRLD), 0x0024,
ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I
ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/tft_io/tft_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
#define ILI9341 0x9341
#define ILI9488 0x9488
#define ILI9488_ID1 0x8066 // Some ILI9488 have 0x8066 in the 0x04
#define LERDGE_ST7796 0xFFFE
#define AUTO 0xFFFF
4 changes: 0 additions & 4 deletions Marlin/src/lcd/tft_io/tft_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ if (lcd_id != 0xFFFFFFFF) return;
write_esc_sequence(ili9341_init);
#elif TFT_DRIVER == ILI9488
write_esc_sequence(ili9488_init);
#elif TFT_DRIVER == LERDGE_ST7796
lcd_id = ST7796;
write_esc_sequence(lerdge_st7796s_init);

#elif TFT_DRIVER == AUTO // autodetect

lcd_id = io.GetID() & 0xFFFF;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/linux/pins_RAMPS_LINUX.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@
#define TFT_DRIVER ST7796
#endif
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION 63934
#define XPT2046_X_CALIBRATION 63934
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 63598
#define XPT2046_Y_CALIBRATION 63598
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET -1
Expand Down
74 changes: 45 additions & 29 deletions Marlin/src/pins/stm32f4/pins_LERDGE_K.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,42 +72,43 @@
#define X_DIR_PIN PB10
#define X_ENABLE_PIN PG0
//#ifndef X_CS_PIN
// #define X_CS_PIN PE0
// #define X_CS_PIN PB2
//#endif

#define Y_STEP_PIN PF14
#define Y_DIR_PIN PF15
#define Y_ENABLE_PIN PF13
//#ifndef Y_CS_PIN
// #define Y_CS_PIN PE1
// #define Y_CS_PIN PE2
//#endif

#define Z_STEP_PIN PF11
#define Z_DIR_PIN PF12
#define Z_ENABLE_PIN PC5
//#ifndef Z_CS_PIN
// #define Z_CS_PIN PE2
// #define Z_CS_PIN PE3
//#endif

#define E0_STEP_PIN PC14
#define E0_DIR_PIN PC13
#define E0_ENABLE_PIN PC15
//#ifndef E0_CS_PIN
// #define E0_CS_PIN PE3
// #define E0_CS_PIN PE4
//#endif

#define E1_STEP_PIN PF1
#define E1_DIR_PIN PF0
#define E1_ENABLE_PIN PF2
//#ifndef E1_CS_PIN
// #define E1_CS_PIN PE4
// #define E1_CS_PIN PE1
//#endif

//#define E2_STEP_PIN PF4 // best guess
//#define E2_DIR_PIN PF3 // best guess
//#define E2_ENABLE_PIN PF5 // best guess
//#ifndef E2_CS_PIN
// #define E2_CS_PIN PB2 // best guess
//#define Z2_STEP_PIN PF4
//#define Z2_DIR_PIN PF3
//#define Z2_ENABLE_PIN PF5
//#define Z2_STOP_PIN PG2
//#ifndef Z2_CS_PIN
// #define Z2_CS_PIN PE0
//#endif

#if HAS_TMC_UART
Expand Down Expand Up @@ -144,12 +145,17 @@
#ifndef E1_SERIAL_RX_PIN
#define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN
#endif
// Ex-motor can be any... X2/Y2/Z2 or E2
#ifndef EX_SERIAL_TX_PIN
#define E2_SERIAL_TX_PIN PE0
#define EX_SERIAL_TX_PIN PE0
#endif
#ifndef EX_SERIAL_RX_PIN
#define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN
#define EX_SERIAL_RX_PIN EX_SERIAL_TX_PIN
#endif
//#define Z2_SERIAL_RX_PIN EX_SERIAL_RX_PIN
//#define Z2_SERIAL_TX_PIN EX_SERIAL_TX_PIN
//#define E2_SERIAL_RX_PIN EX_SERIAL_RX_PIN
//#define E2_SERIAL_TX_PIN EX_SERIAL_TX_PIN
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
#endif
Expand Down Expand Up @@ -193,8 +199,8 @@
//
// LED / Lighting
//
//#define CASE_LIGHT_PIN_CI -1
//#define CASE_LIGHT_PIN_DO -1
#define LED_PIN PA15 // Status LED
//#define CASE_LIGHT_PIN PB6 // LED Ribbon Connector (PWM TIM4_CH1)
//#define NEOPIXEL_PIN -1
#ifndef RGB_LED_R_PIN
#define RGB_LED_R_PIN PB8 // swap R and G pin for compatibility with real wires
Expand All @@ -211,44 +217,54 @@
//
#define SDIO_SUPPORT
#define SDIO_CLOCK 4800000
#define SD_DETECT_PIN PA8
#if DISABLED(SDIO_SUPPORT)
#define SOFTWARE_SPI
#define SD_SCK_PIN PC12
#define SD_MISO_PIN PC8
#define SD_MOSI_PIN PD2
#define SD_SS_PIN PC11
#define SDSS PC11
#endif

//
// Misc. Functions
//
#define SDSS PC11
#define LED_PIN PA15 // Alive
#define PS_ON_PIN PA4
#define KILL_PIN -1
#define POWER_LOSS_PIN PA4 // Power-loss / nAC_FAULT

#define SD_SCK_PIN PC12
#define SD_MISO_PIN PC8
#define SD_MOSI_PIN PD2
#define SD_SS_PIN PC11

#define SD_DETECT_PIN PA8
#define BEEPER_PIN PC7

//
// TFT with FSMC interface
//
#if HAS_FSMC_TFT
//#define TFT_DRIVER LERDGE_ST7796
#ifndef TFT_DRIVER
#define TFT_DRIVER ST7796
#endif
#define ST7796S_INVERTED

#define TFT_RESET_PIN PD6
#define TFT_BACKLIGHT_PIN PD3

#define TFT_CS_PIN PD7
#define TFT_RS_PIN PD11
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11

#define TFT_CS_PIN FSMC_CS_PIN
#define TFT_RS_PIN FSMC_RS_PIN

#define TOUCH_CS_PIN PG15
#define TOUCH_SCK_PIN PB3
#define TOUCH_MOSI_PIN PB5
#define TOUCH_MISO_PIN PB4
#define TOUCH_INT_PIN PG12
#endif

#if IS_NEWPANEL
#define BTN_EN1 PG10
#define BTN_EN2 PG11
#define BEEPER_PIN PC7
#define BTN_EN1 PG11
#define BTN_EN2 PG10
#define BTN_ENC PG9
#ifndef ENCODER_STEPS_PER_MENU_ITEM
#define ENCODER_STEPS_PER_MENU_ITEM 2
#endif
#endif
Loading

0 comments on commit b1097b7

Please sign in to comment.