From b14f630f26b95cd08ef047ba1a83cfb6dc2a537e Mon Sep 17 00:00:00 2001 From: Anders Sahlman <57940217+AndersSahlman@users.noreply.github.com> Date: Tue, 11 Aug 2020 03:21:48 +0200 Subject: [PATCH] MKS Robin new 320x240 TFT Color UI support (#18985) --- Marlin/src/lcd/tft/ili9341.h | 8 +- Marlin/src/lcd/tft/ili9488.h | 4 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 128 ++++++++++++------ 3 files changed, 96 insertions(+), 44 deletions(-) diff --git a/Marlin/src/lcd/tft/ili9341.h b/Marlin/src/lcd/tft/ili9341.h index 42a36b7e34..22709e4cf7 100644 --- a/Marlin/src/lcd/tft/ili9341.h +++ b/Marlin/src/lcd/tft/ili9341.h @@ -38,8 +38,12 @@ #define ILI9341_ORIENTATION_LEFT ILI9341_MADCTL_MY | ILI9341_MADCTL_MX | ILI9341_MADCTL_MV // 320x240 ; Cable on the left side #define ILI9341_ORIENTATION_DOWN ILI9341_MADCTL_MX // 240x320 ; Cable on the upper side -#define ILI9341_COLOR_BGR -#define ILI9341_ORIENTATION ILI9341_ORIENTATION_LEFT +#ifndef ILI9341_COLOR_RGB + #define ILI9341_COLOR_BGR +#endif +#ifndef ILI9341_ORIENTATION + #define ILI9341_ORIENTATION ILI9341_ORIENTATION_LEFT +#endif #define ILI9341_MADCTL_DATA (ILI9341_ORIENTATION | TERN(ILI9341_COLOR_BGR, ILI9341_MADCTL_BGR, ILI9341_MADCTL_RGB)) #define ILI9341_NOP 0x00 // No Operation diff --git a/Marlin/src/lcd/tft/ili9488.h b/Marlin/src/lcd/tft/ili9488.h index 6aad704865..19fdc78e0a 100644 --- a/Marlin/src/lcd/tft/ili9488.h +++ b/Marlin/src/lcd/tft/ili9488.h @@ -38,7 +38,9 @@ #define ILI9488_ORIENTATION_LEFT ILI9488_MADCTL_MY | ILI9488_MADCTL_MX | ILI9488_MADCTL_MV // 480x320 ; Cable on the left side #define ILI9488_ORIENTATION_DOWN ILI9488_MADCTL_MX // 320x480 ; Cable on the upper side -#define ILI9488_COLOR_BGR +#ifndef ILI9488_COLOR_RGB + #define ILI9488_COLOR_BGR +#endif #ifndef ILI9488_ORIENTATION #define ILI9488_ORIENTATION ILI9488_ORIENTATION_LEFT #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 73e1b12b88..716cb16375 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -22,34 +22,33 @@ #pragma once /** - * MKS Robin MINI (STM32F130VET6) board pin assignments + * MKS Robin mini (STM32F130VET6) board pin assignments */ #ifndef __STM32F1__ #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin mini supports up to 1 hotends / E-steppers. Comment out this line to continue." + #error "MKS Robin mini only supports 1 hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_INFO_NAME "MKS Robin mini" +#define BOARD_INFO_NAME "MKS Robin Mini" // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role // #define DISABLE_DEBUG +// +// EEPROM +// #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - // 2K in a AT24C16N - #define EEPROM_PAGE_SIZE (0x800U) // 2KB - #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif -// -// Note: MKS Robin mini board is using SPI2 interface. -// -#define SPI_MODULE 2 +#define ENABLE_SPI2 // // Limit Switches @@ -82,6 +81,15 @@ #define E0_STEP_PIN PD6 #define E0_DIR_PIN PD3 + +// Motor current PWM pins +#define MOTOR_CURRENT_PWM_XY_PIN PA6 +#define MOTOR_CURRENT_PWM_Z_PIN PA7 +#define MOTOR_CURRENT_PWM_E_PIN PB0 +#define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp +#ifndef DEFAULT_PWM_MOTOR_CURRENT + #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } +#endif // // Temperature Sensors // @@ -91,64 +99,102 @@ // // Heaters / Fans // -#define HEATER_0_PIN PC3 // HEATER1 -#define HEATER_BED_PIN PA0 // HOT BED +#define HEATER_0_PIN PC3 +#define HEATER_BED_PIN PA0 #define FAN_PIN PB1 // FAN -// -// Thermocouples -// -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 - // // Misc. Functions // #define POWER_LOSS_PIN PA2 // PW_DET #define PS_ON_PIN PA3 // PW_OFF -//#define LED_PIN PB2 +#define SERVO0_PIN PA8 // Enable BLTOUCH support on IO0 (WIFI connector) + +#define MT_DET_1_PIN PA4 +#define MT_DET_PIN_INVERTING false + +#define WIFI_IO0_PIN PC13 + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SD_DETECT_PIN PD12 +#define ONBOARD_SD_CS_PIN PC11 // // LCD / Controller // #define BEEPER_PIN PC5 -#define SD_DETECT_PIN PD12 /** * Note: MKS Robin TFT screens use various TFT controllers. * If the screen stays white, disable 'LCD_RESET_PIN' * to let the bootloader init the screen. */ + #define XPT2046_X_CALIBRATION 12033 + #define XPT2046_Y_CALIBRATION -9047 + #define XPT2046_X_OFFSET -30 + #define XPT2046_Y_OFFSET 254 + #if ENABLED(FSMC_GRAPHICAL_TFT) + #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 - #define LCD_RESET_PIN PC6 + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define LCD_RESET_PIN PC6 // FSMC_RST #define LCD_BACKLIGHT_PIN PD13 #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PC2 - #define TOUCH_SCK_PIN PB13 - #define TOUCH_MOSI_PIN PB15 - #define TOUCH_MISO_PIN PB14 + #define TOUCH_CS_PIN PC2 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI #endif + +#elif ENABLED(TFT_320x240) //TFT32/28 + + #define TFT_RESET_PIN PC6 + #define TFT_BACKLIGHT_PIN PD13 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TOUCH_CS_PIN PC2 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + + #define TFT_DRIVER ILI9341 + #define TFT_BUFFER_SIZE 14400 + + // YV for normal screen mounting + #define ILI9341_ORIENTATION ILI9341_MADCTL_MY | ILI9341_MADCTL_MV + // XV for 180° rotated screen mounting + //#define ILI9341_ORIENTATION ILI9341_MADCTL_MX | ILI9341_MADCTL_MV + + #define ILI9341_COLOR_RGB #endif -// Motor current PWM pins -#define MOTOR_CURRENT_PWM_XY_PIN PA6 -#define MOTOR_CURRENT_PWM_Z_PIN PA7 -#define MOTOR_CURRENT_PWM_E_PIN PB0 -#define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp -#define DEFAULT_PWM_MOTOR_CURRENT { 1030, 1030, 1030 } // 1.05Amp per driver, here is XY, Z and E. This values determined empirically. - -// This is a kind of workaround in case native marlin "digipot" interface won't work. -// Required to enable related code in STM32F1/HAL.cpp -//#ifndef MKS_ROBIN_MINI_VREF_PWM -// #define MKS_ROBIN_MINI_VREF_PWM -//#endif - -//#define VREF_XY_PIN PA6 -//#define VREF_Z_PIN PA7 -//#define VREF_E1_PIN PB0 +#define HAS_SPI_FLASH 1 +#define SPI_FLASH_SIZE 0x1000000 // 16MB +#if HAS_SPI_FLASH + #define W25QXX_CS_PIN PB12 // Flash chip-select + #define W25QXX_MOSI_PIN PB15 + #define W25QXX_MISO_PIN PB14 + #define W25QXX_SCK_PIN PB13 +#endif