Skip to content

Commit

Permalink
🩹 Fallback ID for MKS TS35 V2.0 (#22031)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellensp authored Jun 6, 2021
1 parent 0e40d47 commit 3c522ff
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 55 deletions.
12 changes: 10 additions & 2 deletions Marlin/src/HAL/STM32/tft/tft_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
WRITE(TFT_CS_PIN, LOW);
}

#ifdef TFT_DEFAULT_DRIVER
#include "../../../lcd/tft_io/tft_ids.h"
#endif

uint32_t TFT_SPI::GetID() {
uint32_t id;
id = ReadID(LCD_READ_ID);

if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) {
id = ReadID(LCD_READ_ID4);
#ifdef TFT_DEFAULT_DRIVER
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = TFT_DEFAULT_DRIVER;
#endif
}
return id;
}

Expand Down
12 changes: 10 additions & 2 deletions Marlin/src/HAL/STM32F1/tft/tft_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
TFT_CS_L;
}

#ifdef TFT_DEFAULT_DRIVER
#include "../../../lcd/tft_io/tft_ids.h"
#endif

uint32_t TFT_SPI::GetID() {
uint32_t id;
id = ReadID(LCD_READ_ID);

if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) {
id = ReadID(LCD_READ_ID4);
#ifdef TFT_DEFAULT_DRIVER
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = TFT_DEFAULT_DRIVER;
#endif
}
return id;
}

Expand Down
31 changes: 16 additions & 15 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1166,52 +1166,53 @@
* - TFT_COLOR
* - GRAPHICAL_TFT_UPSCALE
*/
#if ENABLED(MKS_TS35_V2_0) // Most common: ST7796
#if ENABLED(MKS_TS35_V2_0) // ST7796
#define TFT_DEFAULT_DRIVER ST7796
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_RES_480x320
#define TFT_INTERFACE_SPI
#elif ENABLED(MKS_ROBIN_TFT24) // Most common: ST7789
#elif ENABLED(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
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_TFT28) // Most common: ST7789
#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_TFT32) // Most common: ST7789
#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_TFT35) // Most common: ILI9488
#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
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_RES_480x320
#define TFT_INTERFACE_FSMC
#elif ENABLED(MKS_ROBIN_TFT43)
#define TFT_DEFAULT_ORIENTATION 0
#define TFT_DRIVER SSD1963
#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_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#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)
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(ANET_ET4_TFT28) // ST7789
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
#define TFT_RES_320x240
#define TFT_INTERFACE_FSMC
#elif ENABLED(ANET_ET5_TFT35) // ST7796
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_RES_480x320
#define TFT_INTERFACE_FSMC
#elif ENABLED(BIQU_BX_TFT70) // RGB
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
#define TFT_RES_1024x600
Expand Down
35 changes: 35 additions & 0 deletions Marlin/src/lcd/tft_io/tft_ids.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#define LTDC_RGB 0xABAB
#define SSD1963 0x5761
#define ST7735 0x89F0
#define ST7789 0x8552
#define ST7796 0x7796
#define R61505 0x1505
#define ILI9328 0x9328
#define ILI9341 0x9341
#define ILI9488 0x9488
#define ILI9488_ID1 0x8066 // Some ILI9488 have 0x8066 in the 0x04
#define LERDGE_ST7796 0xFFFE
#define AUTO 0xFFFF
39 changes: 29 additions & 10 deletions Marlin/src/lcd/tft_io/tft_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,37 @@
*
*/

#include "tft_io.h"
#include "../../inc/MarlinConfigPre.h"

#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT

#include "st7735.h"
#include "st7789v.h"
#include "st7796s.h"
#include "r65105.h"
#include "ili9328.h"
#include "ili9341.h"
#include "ili9488.h"
#include "ssd1963.h"
#include "tft_io.h"
#include "tft_ids.h"

#if TFT_DRIVER == ST7735 || TFT_DRIVER == AUTO
#include "st7735.h"
#endif
#if TFT_DRIVER == ST7789 || TFT_DRIVER == AUTO
#include "st7789v.h"
#endif
#if TFT_DRIVER == ST7796 || TFT_DRIVER == AUTO
#include "st7796s.h"
#endif
#if TFT_DRIVER == R61505 || TFT_DRIVER == AUTO
#include "r65105.h"
#endif
#if TFT_DRIVER == ILI9328 || TFT_DRIVER == AUTO
#include "ili9328.h"
#endif
#if TFT_DRIVER == ILI9341 || TFT_DRIVER == AUTO
#include "ili9341.h"
#endif
#if TFT_DRIVER == ILI9488 || TFT_DRIVER == ILI9488_ID1 || TFT_DRIVER == AUTO
#include "ili9488.h"
#endif
#if TFT_DRIVER == SSD1963 || TFT_DRIVER == AUTO
#include "ssd1963.h"
#endif

#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
#include "../../core/debug_out.h"
Expand Down Expand Up @@ -236,4 +255,4 @@ void TFT_IO::write_esc_sequence(const uint16_t *Sequence) {
io.DataTransferEnd();
}

#endif // HAS_SPI_TFT || HAS_FSMC_TFT
#endif // HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT
35 changes: 9 additions & 26 deletions Marlin/src/lcd/tft_io/tft_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "../../inc/MarlinConfig.h"

#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT

#if HAS_SPI_TFT
#include HAL_PATH(../../HAL, tft/tft_spi.h)
#elif HAS_FSMC_TFT
Expand All @@ -35,9 +33,9 @@
#error "TFT IO only supports SPI, FSMC or LTDC interface"
#endif

#define TFT_EXCHANGE_XY (1UL << 1)
#define TFT_INVERT_X (1UL << 2)
#define TFT_INVERT_Y (1UL << 3)
#define TFT_EXCHANGE_XY _BV32(1)
#define TFT_INVERT_X _BV32(2)
#define TFT_INVERT_Y _BV32(3)

#define TFT_NO_ROTATION (0x00)
#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
Expand Down Expand Up @@ -65,8 +63,8 @@
// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))

#define TFT_COLOR_RGB (1UL << 3)
#define TFT_COLOR_BGR (1UL << 4)
#define TFT_COLOR_RGB _BV32(3)
#define TFT_COLOR_BGR _BV32(4)

// Each TFT Driver is responsible for its default color mode.
// #ifndef TFT_COLOR
Expand All @@ -93,27 +91,14 @@
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif

#define LTDC_RGB 0xABAB
#define SSD1963 0x5761
#define ST7735 0x89F0
#define ST7789 0x8552
#define ST7796 0x7796
#define R61505 0x1505
#define ILI9328 0x9328
#define ILI9341 0x9341
#define ILI9488 0x9488
#define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04
#define LERDGE_ST7796 0xFFFE
#define AUTO 0xFFFF

#ifndef TFT_DRIVER
#define TFT_DRIVER AUTO
#endif

#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF
#define ESC_FFFF 0xFFFF, 0xFFFF
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF
#define ESC_FFFF 0xFFFF, 0xFFFF

class TFT_IO {
public:
Expand Down Expand Up @@ -143,5 +128,3 @@ class TFT_IO {
protected:
static uint32_t lcd_id;
};

#endif // HAS_SPI_TFT || HAS_FSMC_TFT

0 comments on commit 3c522ff

Please sign in to comment.