Skip to content

Commit

Permalink
🔧 Rework MKS Monster8 pins (#26988)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisiskeithb authored Apr 28, 2024
1 parent e1d65cc commit a2f024f
Showing 1 changed file with 189 additions and 100 deletions.
289 changes: 189 additions & 100 deletions Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,43 +245,120 @@
#define EXP2_07_PIN PB11
#define EXP2_08_PIN -1 // RESET

#if HAS_MEDIA
#ifndef SDCARD_CONNECTION
//
// SD Support
//
#ifndef SDCARD_CONNECTION
#if HAS_WIRED_LCD && DISABLED(NO_LCD_SDCARD)
#define SDCARD_CONNECTION LCD
#else
#define SDCARD_CONNECTION ONBOARD
#endif
#if SD_CONNECTION_IS(ONBOARD)
#define ENABLE_SPI3
#define SD_SS_PIN -1
#define SDSS PC9
#define SD_SCK_PIN PC10
#define SD_MISO_PIN PC11
#define SD_MOSI_PIN PC12
#define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled
#elif SD_CONNECTION_IS(LCD)
#define ENABLE_SPI1
#define SDSS EXP2_04_PIN
#define SD_SCK_PIN EXP2_02_PIN
#define SD_MISO_PIN EXP2_01_PIN
#define SD_MOSI_PIN EXP2_06_PIN
#define SD_DETECT_PIN EXP2_07_PIN
#endif
#endif

#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI)
#define TFT_CS_PIN EXP1_07_PIN
//
// Onboard SD card
// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
//
#if SD_CONNECTION_IS(ONBOARD)
#define ENABLE_SPI3
#define SD_SS_PIN -1
#define SDSS PC9
#define SD_SCK_PIN PC10
#define SD_MISO_PIN PC11
#define SD_MOSI_PIN PC12
#define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled
#elif SD_CONNECTION_IS(LCD)
#define ENABLE_SPI1
#define SDSS EXP2_04_PIN
#define SD_SCK_PIN EXP2_02_PIN
#define SD_MISO_PIN EXP2_01_PIN
#define SD_MOSI_PIN EXP2_06_PIN
#define SD_DETECT_PIN EXP2_07_PIN
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
#error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for BOARD_MKS_MONSTER8_V1/V2."
#endif

#if HAS_WIRED_LCD

#define BEEPER_PIN EXP1_01_PIN
#define BTN_ENC EXP1_02_PIN

#if ENABLED(CR10_STOCKDISPLAY)
#define LCD_PINS_RS EXP1_07_PIN

#define BTN_EN1 EXP1_03_PIN
#define BTN_EN2 EXP1_05_PIN

#define LCD_PINS_EN EXP1_08_PIN
#define LCD_PINS_D4 EXP1_06_PIN

#else

#define LCD_PINS_EN EXP1_03_PIN
#define LCD_PINS_RS EXP1_04_PIN

#define BTN_EN1 EXP2_03_PIN
#define BTN_EN2 EXP2_05_PIN

// MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
#if ENABLED(MKS_MINI_12864)

#define ENABLE_SPI1
#define FORCE_SOFT_SPI
#define DOGLCD_A0 EXP1_07_PIN
#define DOGLCD_CS EXP1_06_PIN
#define DOGLCD_SCK EXP2_02_PIN
#define DOGLCD_MOSI EXP2_06_PIN
//#define LCD_BACKLIGHT_PIN -1
//#define LCD_RESET_PIN -1

#elif ENABLED(FYSETC_MINI_12864_2_1)

#define LCD_PINS_DC EXP1_04_PIN
#define DOGLCD_CS EXP1_03_PIN
#define DOGLCD_A0 LCD_PINS_DC
#define LCD_BACKLIGHT_PIN -1
#define LCD_RESET_PIN EXP1_05_PIN
#define NEOPIXEL_PIN EXP1_06_PIN
#define DOGLCD_MOSI EXP2_06_PIN
#define DOGLCD_SCK EXP2_02_PIN
#if SD_CONNECTION_IS(ONBOARD)
#define FORCE_SOFT_SPI
#endif
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270

#else

#define LCD_PINS_D4 EXP1_05_PIN
#if IS_ULTIPANEL
#define LCD_PINS_D5 EXP1_06_PIN
#define LCD_PINS_D6 EXP1_07_PIN
#define LCD_PINS_D7 EXP1_08_PIN
#endif

#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 96
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 48
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 600
#endif

#endif
#endif
#endif // HAS_WIRED_LCD

#if HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI

#define TFT_SCK_PIN EXP2_02_PIN
#define TFT_MISO_PIN EXP2_01_PIN
#define TFT_MOSI_PIN EXP2_06_PIN
#define TFT_DC_PIN EXP1_08_PIN
#define TFT_A0_PIN TFT_DC_PIN

#define TFT_RESET_PIN EXP1_04_PIN

#define LCD_BACKLIGHT_PIN EXP1_03_PIN
#define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN

#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
#define BTN_EN1 EXP2_03_PIN
#define BTN_EN2 EXP2_05_PIN

#ifndef TFT_WIDTH
#define TFT_WIDTH 480
Expand All @@ -290,85 +367,97 @@
#define TFT_HEIGHT 320
#endif

#define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
#define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
#define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO
#define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI
#if ENABLED(BTT_TFT35_SPI_V1_0)

/**
* ------ ------
* BEEPER | 1 2 | LCD-BTN MISO | 1 2 | CLK
* T_MOSI | 3 4 | T_CS LCD-ENCA | 3 4 | TFTCS
* T_CLK | 5 6 T_MISO LCD-ENCB | 5 6 MOSI
* PENIRQ | 7 8 | F_CS RS | 7 8 | RESET
* GND | 9 10 | VCC GND | 9 10 | NC
* ------ ------
* EXP1 EXP2
*
* 480x320, 3.5", SPI Display with Rotary Encoder.
* Stock Display for the BIQU B1 SE Series.
* Schematic: https://github.com/bigtreetech/TFT35-SPI/blob/master/v1/Hardware/BTT%20TFT35-SPI%20V1-SCH.pdf
*/
#define TFT_CS_PIN EXP2_04_PIN
#define TFT_DC_PIN EXP2_07_PIN
#define TFT_A0_PIN TFT_DC_PIN

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

#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X 17540
#endif
#ifndef TOUCH_CALIBRATION_Y
#define TOUCH_CALIBRATION_Y -11388
#endif
#ifndef TOUCH_OFFSET_X
#define TOUCH_OFFSET_X -21
#endif
#ifndef TOUCH_OFFSET_Y
#define TOUCH_OFFSET_Y 337
#endif
#ifndef TOUCH_ORIENTATION
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif

#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI
#elif ENABLED(MKS_TS35_V2_0)

#define TFT_BUFFER_WORDS 14400
/** ------ ------
* BEEPER | 1 2 | BTN_ENC SPI1_MISO | 1 2 | SPI1_SCK
* TFT_BKL / LCD_EN | 3 4 | TFT_RESET / LCD_RS BTN_EN1 | 3 4 | SPI1_CS
* TOUCH_CS / LCD_D4 | 5 6 TOUCH_INT / LCD_D5 BTN_EN2 | 5 6 SPI1_MOSI
* SPI1_CS / LCD_D6 | 7 8 | SPI1_RS / LCD_D7 SPI1_RS | 7 8 | RESET
* GND | 9 10 | VCC GND | 9 10 | VCC
* ------ ------
* EXP1 EXP2
*/
#define TFT_CS_PIN EXP1_07_PIN // SPI1_CS
#define TFT_DC_PIN EXP1_08_PIN // SPI1_RS
#define TFT_A0_PIN TFT_DC_PIN

#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X -17253
#endif
#ifndef TOUCH_CALIBRATION_Y
#define TOUCH_CALIBRATION_Y 11579
#endif
#ifndef TOUCH_OFFSET_X
#define TOUCH_OFFSET_X 514
#endif
#ifndef TOUCH_OFFSET_Y
#define TOUCH_OFFSET_Y -24
#endif
#ifndef TOUCH_ORIENTATION
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif
#define TFT_RESET_PIN EXP1_04_PIN

#elif HAS_WIRED_LCD

#define LCD_PINS_EN EXP1_03_PIN
#define LCD_PINS_RS EXP1_04_PIN
#define LCD_BACKLIGHT_PIN -1

// MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
#if ENABLED(MKS_MINI_12864)

#define ENABLE_SPI1
#define FORCE_SOFT_SPI
#define DOGLCD_A0 EXP1_07_PIN
#define DOGLCD_CS EXP1_06_PIN
#define DOGLCD_SCK EXP2_02_PIN
#define DOGLCD_MOSI EXP2_06_PIN
//#define LCD_BACKLIGHT_PIN -1
//#define LCD_RESET_PIN -1

#elif ENABLED(FYSETC_MINI_12864_2_1)

#define LCD_PINS_DC EXP1_04_PIN
#define DOGLCD_CS EXP1_03_PIN
#define DOGLCD_A0 LCD_PINS_DC
#define LCD_BACKLIGHT_PIN -1
#define LCD_RESET_PIN EXP1_05_PIN
#define NEOPIXEL_PIN EXP1_06_PIN
#define DOGLCD_MOSI EXP2_06_PIN
#define DOGLCD_SCK EXP2_02_PIN
#if SD_CONNECTION_IS(ONBOARD)
#define FORCE_SOFT_SPI
#endif
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
#define LCD_BACKLIGHT_PIN EXP1_03_PIN
#define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN

#else
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1

#define LCD_PINS_D4 EXP1_05_PIN
#if IS_ULTIPANEL
#define LCD_PINS_D5 EXP1_06_PIN
#define LCD_PINS_D6 EXP1_07_PIN
#define LCD_PINS_D7 EXP1_08_PIN
#endif
#define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
#define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
#define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO
#define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI

#define BOARD_ST7920_DELAY_1 96
#define BOARD_ST7920_DELAY_2 48
#define BOARD_ST7920_DELAY_3 600
#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI

#endif // !MKS_MINI_12864
#define TFT_BUFFER_WORDS 14400

#endif // HAS_WIRED_LCD
#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X -17253
#endif
#ifndef TOUCH_CALIBRATION_Y
#define TOUCH_CALIBRATION_Y 11579
#endif
#ifndef TOUCH_OFFSET_X
#define TOUCH_OFFSET_X 514
#endif
#ifndef TOUCH_OFFSET_Y
#define TOUCH_OFFSET_Y -24
#endif
#ifndef TOUCH_ORIENTATION
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif

#endif

#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD)
#define BEEPER_PIN EXP1_01_PIN
#define BTN_EN1 EXP2_03_PIN
#define BTN_EN2 EXP2_05_PIN
#define BTN_ENC EXP1_02_PIN
#endif

0 comments on commit a2f024f

Please sign in to comment.