Browse Source
* split tft folder in two: tft for color ui; tft_io for shared tft code * after the files got moved, now the code was moved to the right place * classic ui using TFT IO init lcd codes * feature to compile tft_io when enabled * compiling fix * lvgl spi tft working with tft io init codes * there is no need for separeted fsmc and spi class in lvgl anymore, as tft io handle everything * remove debug * base for TFT rotation and mirroring API, and ILI9488 support * ST7796S rotate and mirror support * ST7789V rotate and mirror support * ST7735 rotate and mirror support * ILI9341 rotate and mirror support * ILI9328 rotate and mirror support * R61505 rotate and mirror support * MKS TFT definitions * more configs for mks tfts * update config * naming typo * to configure the user interface * ANYCUBIC_TFT35 * tft configs * support for SSD1963 * tft display types * updated conditionals lcd; first board fully working with the new code - all 3 ui! * compatiblity * changed name * move classic ui file name * rename TURN -> ROTATE * GRAPHICAL_TFT_ROTATE_180 deprecated * first fsmc board fully working - chitu v5 * mks robin nano v1.2 + tft 35 ok! * right pin name * anycubic tft tested in a TRIGORILLA_PRO * chitu v6 * nano 32 tft orientation * mks tft43 * mks tft43 rotation * fixed LONGER LK tft setup * GRAPHICAL_TFT_UPSCALE defined by the display type * better offsets defaults * Update Configuration.h * Update tft_fsmc.cpp * Update Conditionals_LCD.h * Tweak comments * update nano tests * Revert "update nano tests" This reverts commit a071ebbfad30e28855a4a5695ec8a726542a1a65. * default tft * outdated comments * to not break non-vscode builds * upscale tft 35 * support tft 180 rotation for color ui * Each TFT Driver is responsible for its default color mode. * use auto detect in mks displays, because some of them could be shipped with diferent drivers * extra s * unused code * wrong -1 * missing mirror options * Smaller regex pattern * Comment updates * Clean up old defines * Apply pins formatting * GRAPHICAL_TFT_ROTATE_180 => TFT_ROTATE_180 * MKS_ROBIN_TFT_V1_1R * merge fix * correct resolution * auto is default, dont need be there, and it will allow the user to configure it even for named displays * to not use rotation with MKS_ROBIN_TFT_V1_1R * i like () in macros * avoid sleepy commits * default for st7789 is rgb * nano follow up * to allow ili9328 rotation * default is rgb * boards merge follow up * to match bootloader orientation * HAS_TOUCH_XPT2046 is not hal specific anymore * lets not forget LPC * 180 rotation for ili9328 and R61505 * Clean up whitespace Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com> Co-authored-by: Scott Lahteine <github@thinkyhead.com>vanilla_fb_2.0.x
Victor Oliveira
4 years ago
committed by
GitHub
56 changed files with 1000 additions and 1476 deletions
@ -1,60 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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/>.
|
|||
* |
|||
*/ |
|||
|
|||
#include "../../../../inc/MarlinConfig.h" |
|||
|
|||
#if ENABLED(TFT_LVGL_UI_FSMC) |
|||
|
|||
#include HAL_PATH(../../HAL, tft/tft_fsmc.h) |
|||
TFT_IO tftio; |
|||
|
|||
void LCD_IO_Init(uint8_t cs, uint8_t rs); |
|||
void LCD_IO_WriteData(uint16_t RegValue); |
|||
void LCD_IO_WriteReg(uint16_t Reg); |
|||
#ifdef LCD_USE_DMA_FSMC |
|||
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count); |
|||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); |
|||
#endif |
|||
|
|||
void LCD_IO_Init(uint8_t cs, uint8_t rs) { |
|||
tftio.Init(); |
|||
} |
|||
|
|||
void LCD_IO_WriteData(uint16_t RegValue) { |
|||
tftio.WriteData(RegValue); |
|||
} |
|||
|
|||
void LCD_IO_WriteReg(uint16_t Reg) { |
|||
tftio.WriteReg(Reg); |
|||
} |
|||
|
|||
#ifdef LCD_USE_DMA_FSMC |
|||
void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) { |
|||
tftio.WriteMultiple(color, count); |
|||
} |
|||
|
|||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) { |
|||
tftio.WriteSequence(data, length); |
|||
} |
|||
#endif // LCD_USE_DMA_FSMC
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -1,30 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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 |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { /* C-declarations for C++ */ |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -1,30 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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 |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_SPI_TFT |
|||
#include HAL_PATH(../../HAL, tft/tft_spi.h) |
|||
#elif HAS_FSMC_TFT |
|||
#include HAL_PATH(../../HAL, tft/tft_fsmc.h) |
|||
#endif |
@ -0,0 +1,131 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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 |
|||
|
|||
#include "tft_io.h" |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#define SSD1963_MADCTL_MY 0x80 // Row Address Order
|
|||
#define SSD1963_MADCTL_MX 0x40 // Column Address Order
|
|||
#define SSD1963_MADCTL_MV 0x20 // Row/Column Exchange
|
|||
#define SSD1963_MADCTL_MH 0x10 // Horizontal Refresh Order
|
|||
#define SSD1963_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
|||
#define SSD1963_MADCTL_RGB 0x00 |
|||
#define SSD1963_MADCTL_ML 0x04 // Vertical Refresh Order
|
|||
#define SSD1963_MADCTL_FH 0x02 // Flip Horizontal
|
|||
#define SSD1963_MADCTL_FV 0x01 // Flip Vertical
|
|||
|
|||
#define SSD1963_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, SSD1963_MADCTL_MV) | \ |
|||
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, SSD1963_MADCTL_FH) | \ |
|||
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, SSD1963_MADCTL_FV) |
|||
|
|||
#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR |
|||
#define SSD1963_COLOR SSD1963_MADCTL_BGR |
|||
#elif TFT_COLOR == TFT_COLOR_RGB |
|||
#define SSD1963_COLOR SSD1963_MADCTL_RGB |
|||
#endif |
|||
|
|||
#define SSD1963_MADCTL_DATA (SSD1963_ORIENTATION) | (SSD1963_COLOR) |
|||
|
|||
#define SSD1963_NOP 0x00 // No Operation
|
|||
#define SSD1963_SWRESET 0x01 // Software reset
|
|||
#define SSD1963_RDDPM 0x0A // Read Display Power Mode
|
|||
#define SSD1963_RDDMADCTL 0x0B // Read Display MADCTL
|
|||
#define SSD1963_RDDCOLMOD 0x0C // Read Display Pixel Format
|
|||
#define SSD1963_RDDIM 0x0D // Read Display Image Mode
|
|||
#define SSD1963_RDDSM 0x0E // Read Display Signal Mode
|
|||
#define SSD1963_SLPIN 0x10 // Sleep In
|
|||
#define SSD1963_SLPOUT 0x11 // Sleep Out
|
|||
#define SSD1963_PTLON 0x12 // Partial Display Mode On
|
|||
#define SSD1963_NORON 0x13 // Normal Display Mode On
|
|||
#define SSD1963_INVOFF 0x20 // Display Inversion Off
|
|||
#define SSD1963_INVON 0x21 // Display Inversion On
|
|||
#define SSD1963_GAMSET 0x26 // Gamma Set
|
|||
#define SSD1963_DISPOFF 0x28 // Display Off
|
|||
#define SSD1963_DISPON 0x29 // Display On
|
|||
#define SSD1963_CASET 0x2A // Column Address Set
|
|||
#define SSD1963_RASET 0x2B // Row Address Set
|
|||
#define SSD1963_RAMWR 0x2C // Memory Write
|
|||
#define SSD1963_RAMRD 0x2E // Memory Read
|
|||
#define SSD1963_PTLAR 0x30 // Partial Area
|
|||
#define SSD1963_VSCRDEF 0x33 // Vertical Scrolling Definition
|
|||
#define SSD1963_TEOFF 0x34 // Tearing Effect Line OFF
|
|||
#define SSD1963_TEON 0x35 // Tearing Effect Line ON
|
|||
#define SSD1963_MADCTL 0x36 // Memory Data Access Control
|
|||
#define SSD1963_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
|
|||
#define SSD1963_IDMOFF 0x38 // Idle Mode Off
|
|||
#define SSD1963_IDMON 0x39 // Idle Mode On
|
|||
#define SSD1963_WRMEMC 0x3C // Write Memory Continue
|
|||
#define SSD1963_RDMEMC 0x3E // Read Memory Continue
|
|||
#define SSD1963_STE 0x44 // Set Tear Scanline
|
|||
#define SSD1963_GSCAN 0x45 // Get Scanline
|
|||
#define SSD1963_WRDISBV 0x51 // Write Display Brightness
|
|||
#define SSD1963_RDDISBV 0x52 // Read Display Brightness
|
|||
#define SSD1963_WRCTRLD 0x53 // Write CTRL Display
|
|||
#define SSD1963_RDCTRLD 0x54 // Read CTRL Value Display
|
|||
#define SSD1963_WRCACE 0x55 // Write Content Adaptive Brightness Control and Color Enhancement
|
|||
#define SSD1963_RDCABC 0x56 // Read Content Adaptive Brightness Control
|
|||
#define SSD1963_WRCABCMB 0x5E // Write CABC Minimum Brightness
|
|||
#define SSD1963_RDCABCMB 0x5F // Read CABC Minimum Brightness
|
|||
#define SSD1963_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result
|
|||
#define SSD1963_RDDDB 0xA1 // Read Device Descriptor Block
|
|||
#define SSD1963_SLCDMODE 0xB0 // Set the LCD panel mode and resolution
|
|||
#define SSD1963_SHSYNC 0xB4 // Set HSYNC
|
|||
#define SSD1963_GHSYNC 0xB5 // Get HSYNC
|
|||
#define SSD1963_SVSYNC 0xB6 // Set VSYNC
|
|||
#define SSD1963_GVSYNC 0xB7 // Get VSYNC
|
|||
#define SSD1963_SGPIOCFG 0xB8 // Set GPIO Conf
|
|||
#define SSD1963_SGPIOV 0xBA // Set GPIO Value
|
|||
#define SSD1963_SPWMCFG 0xBE // Set PWM Conf
|
|||
#define SSD1963_GPWMCFG 0xBF // Get PWM Conf
|
|||
#define SSD1963_SDBCCFG 0xD0 // Set Dynamic Back Light Config
|
|||
#define SSD1963_GDBCCFG 0xD1 // Get Dynamic Back Light Config
|
|||
#define SSD1963_PLLON 0xE0 // PLL Enable
|
|||
#define SSD1963_PLLMN 0xE2 // Set PLL Multiplier
|
|||
#define SSD1963_SLSHIFT 0xE6 // Set the LSHIFT (pixel clock) frequency
|
|||
#define SSD1963_COLMOD 0xF0 // Interface Pixel Format
|
|||
|
|||
static const uint16_t ssd1963_init[] = { |
|||
DATASIZE_8BIT, |
|||
ESC_REG(SSD1963_PLLMN), 0x0023, 0x0002, 0x0054, |
|||
ESC_REG(SSD1963_PLLON), 0x0001, ESC_DELAY(10), |
|||
ESC_REG(SSD1963_PLLON), 0x0003, ESC_DELAY(10), |
|||
ESC_REG(SSD1963_SWRESET), ESC_DELAY(100), |
|||
|
|||
ESC_REG(SSD1963_SLSHIFT), 0x0001, 0x001F, 0x00FF, |
|||
ESC_REG(SSD1963_SLCDMODE), 0x0020, 0x0000, 0x0001, 0x00DF, 0x0001, 0x000F, 0x0000, |
|||
ESC_REG(SSD1963_SHSYNC), 0x0002, 0x0013, 0x0000, 0x0008, 0x002B, 0x0000, 0x0002, 0x0000, |
|||
ESC_REG(SSD1963_SVSYNC), 0x0001, 0x0020, 0x0000, 0x0004, 0x000C, 0x0000, 0x0002, |
|||
ESC_REG(SSD1963_SGPIOV), 0x000F, |
|||
ESC_REG(SSD1963_SGPIOCFG), 0x0007, 0x0001, |
|||
|
|||
ESC_REG(SSD1963_MADCTL), SSD1963_MADCTL_DATA, |
|||
ESC_REG(SSD1963_COLMOD), 0x0003, ESC_DELAY(1),//RBG 565
|
|||
|
|||
ESC_REG(SSD1963_NORON), |
|||
ESC_REG(SSD1963_DISPON), |
|||
|
|||
ESC_REG(SSD1963_SPWMCFG), 0x0006, 0x00f0, 0x0001, 0x00f0, 0x0000, 0x0000, |
|||
ESC_REG(SSD1963_SDBCCFG), 0x000D, |
|||
ESC_END |
|||
}; |
@ -0,0 +1,226 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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/>.
|
|||
* |
|||
*/ |
|||
|
|||
#include "tft_io.h" |
|||
|
|||
#if HAS_SPI_TFT || HAS_FSMC_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" |
|||
|
|||
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT) |
|||
#include "../../core/debug_out.h" |
|||
|
|||
TFT_IO_DRIVER TFT_IO::io; |
|||
uint32_t TFT_IO::lcd_id = 0xFFFFFFFF; |
|||
|
|||
void TFT_IO::InitTFT() { |
|||
if (lcd_id != 0xFFFFFFFF) return; |
|||
|
|||
#if PIN_EXISTS(TFT_BACKLIGHT) |
|||
OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); |
|||
#endif |
|||
|
|||
#if PIN_EXISTS(TFT_RESET) |
|||
OUT_WRITE(TFT_RESET_PIN, HIGH); |
|||
delay(10); |
|||
OUT_WRITE(TFT_RESET_PIN, LOW); |
|||
delay(10); |
|||
OUT_WRITE(TFT_RESET_PIN, HIGH); |
|||
#endif |
|||
|
|||
#if PIN_EXISTS(TFT_BACKLIGHT) |
|||
OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); |
|||
#endif |
|||
|
|||
// io.Init();
|
|||
delay(100); |
|||
|
|||
#if TFT_DRIVER != AUTO |
|||
lcd_id = TFT_DRIVER; |
|||
#endif |
|||
|
|||
#if TFT_DRIVER == ST7735 |
|||
write_esc_sequence(st7735_init); |
|||
#elif TFT_DRIVER == SSD1963 |
|||
write_esc_sequence(ssd1963_init); |
|||
#elif TFT_DRIVER == ST7789 |
|||
write_esc_sequence(st7789v_init); |
|||
#elif TFT_DRIVER == ST7796 |
|||
write_esc_sequence(st7796s_init); |
|||
#elif TFT_DRIVER == R61505 |
|||
write_esc_sequence(r61505_init); |
|||
#elif TFT_DRIVER == ILI9328 |
|||
write_esc_sequence(ili9328_init); |
|||
#elif TFT_DRIVER == ILI9341 |
|||
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; |
|||
|
|||
switch (lcd_id) { |
|||
case ST7796: // ST7796S 480x320
|
|||
DEBUG_ECHO_MSG(" ST7796S"); |
|||
write_esc_sequence(st7796s_init); |
|||
break; |
|||
case ST7789: // ST7789V 320x240
|
|||
DEBUG_ECHO_MSG(" ST7789V"); |
|||
write_esc_sequence(st7789v_init); |
|||
break; |
|||
case SSD1963: // SSD1963
|
|||
DEBUG_ECHO_MSG(" SSD1963"); |
|||
write_esc_sequence(ssd1963_init); |
|||
break; |
|||
case ST7735: // ST7735 160x128
|
|||
DEBUG_ECHO_MSG(" ST7735"); |
|||
write_esc_sequence(st7735_init); |
|||
break; |
|||
case R61505: // R61505U 320x240
|
|||
DEBUG_ECHO_MSG(" R61505U"); |
|||
write_esc_sequence(r61505_init); |
|||
break; |
|||
case ILI9328: // ILI9328 320x240
|
|||
DEBUG_ECHO_MSG(" ILI9328"); |
|||
write_esc_sequence(ili9328_init); |
|||
break; |
|||
case ILI9341: // ILI9341 320x240
|
|||
DEBUG_ECHO_MSG(" ILI9341"); |
|||
write_esc_sequence(ili9341_init); |
|||
break; |
|||
case ILI9488: // ILI9488 480x320
|
|||
case ILI9488_ID1: // 0x8066 ILI9488 480x320
|
|||
DEBUG_ECHO_MSG(" ILI9488"); |
|||
write_esc_sequence(ili9488_init); |
|||
break; |
|||
default: |
|||
lcd_id = 0; |
|||
} |
|||
#else |
|||
#error Unsupported TFT driver |
|||
#endif |
|||
|
|||
#if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT) |
|||
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); |
|||
#endif |
|||
} |
|||
|
|||
void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { |
|||
#ifdef OFFSET_X |
|||
Xmin += OFFSET_X; Xmax += OFFSET_X; |
|||
#endif |
|||
#ifdef OFFSET_Y |
|||
Ymin += OFFSET_Y; Ymax += OFFSET_Y; |
|||
#endif |
|||
|
|||
switch (lcd_id) { |
|||
case ST7735: // ST7735 160x128
|
|||
case ST7789: // ST7789V 320x240
|
|||
case ST7796: // ST7796 480x320
|
|||
case ILI9341: // ILI9341 320x240
|
|||
case ILI9488: // ILI9488 480x320
|
|||
case SSD1963: // SSD1963
|
|||
case ILI9488_ID1: // 0x8066 ILI9488 480x320
|
|||
io.DataTransferBegin(DATASIZE_8BIT); |
|||
|
|||
// CASET: Column Address Set
|
|||
io.WriteReg(ILI9341_CASET); |
|||
io.WriteData((Xmin >> 8) & 0xFF); |
|||
io.WriteData(Xmin & 0xFF); |
|||
io.WriteData((Xmax >> 8) & 0xFF); |
|||
io.WriteData(Xmax & 0xFF); |
|||
|
|||
// RASET: Row Address Set
|
|||
io.WriteReg(ILI9341_PASET); |
|||
io.WriteData((Ymin >> 8) & 0xFF); |
|||
io.WriteData(Ymin & 0xFF); |
|||
io.WriteData((Ymax >> 8) & 0xFF); |
|||
io.WriteData(Ymax & 0xFF); |
|||
|
|||
// RAMWR: Memory Write
|
|||
io.WriteReg(ILI9341_RAMWR); |
|||
break; |
|||
case R61505: // R61505U 320x240
|
|||
case ILI9328: // ILI9328 320x240
|
|||
io.DataTransferBegin(DATASIZE_16BIT); |
|||
|
|||
// Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
|
|||
io.WriteReg(ILI9328_HASTART); |
|||
io.WriteData(Ymin); |
|||
io.WriteReg(ILI9328_HAEND); |
|||
io.WriteData(Ymax); |
|||
io.WriteReg(ILI9328_VASTART); |
|||
io.WriteData(Xmin); |
|||
io.WriteReg(ILI9328_VAEND); |
|||
io.WriteData(Xmax); |
|||
|
|||
io.WriteReg(ILI9328_HASET); |
|||
io.WriteData(Ymin); |
|||
io.WriteReg(ILI9328_VASET); |
|||
io.WriteData(Xmin); |
|||
|
|||
io.WriteReg(ILI9328_RAMWR); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
io.DataTransferEnd(); |
|||
} |
|||
|
|||
void TFT_IO::write_esc_sequence(const uint16_t *Sequence) { |
|||
uint16_t dataWidth, data; |
|||
|
|||
dataWidth = *Sequence++; |
|||
io.DataTransferBegin(dataWidth); |
|||
|
|||
for (;;) { |
|||
data = *Sequence++; |
|||
if (data != 0xFFFF) { |
|||
io.WriteData(data); |
|||
continue; |
|||
} |
|||
data = *Sequence++; |
|||
if (data == 0x7FFF) return; |
|||
if (data == 0xFFFF) |
|||
io.WriteData(0xFFFF); |
|||
else if (data & 0x8000) |
|||
delay(data & 0x7FFF); |
|||
else if ((data & 0xFF00) == 0) |
|||
io.WriteReg(data); |
|||
} |
|||
|
|||
io.DataTransferEnd(); |
|||
} |
|||
|
|||
#endif // HAS_SPI_TFT || HAS_FSMC_TFT
|
@ -0,0 +1,124 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 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 |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_SPI_TFT || HAS_FSMC_TFT |
|||
|
|||
#if HAS_SPI_TFT |
|||
#include HAL_PATH(../../HAL, tft/tft_spi.h) |
|||
#elif HAS_FSMC_TFT |
|||
#include HAL_PATH(../../HAL, tft/tft_fsmc.h) |
|||
#else |
|||
#error "TFT IO only supports SPI or FSMC interface" |
|||
#endif |
|||
|
|||
#define TFT_EXCHANGE_XY (1UL << 1) |
|||
#define TFT_INVERT_X (1UL << 2) |
|||
#define TFT_INVERT_Y (1UL << 3) |
|||
|
|||
#define TFT_NO_ROTATION (0x00) |
|||
#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X) |
|||
#define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y) |
|||
#define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y) |
|||
|
|||
#define TFT_MIRROR_X (TFT_INVERT_Y) |
|||
#define TFT_MIRROR_Y (TFT_INVERT_X) |
|||
|
|||
#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_INVERT_Y) |
|||
#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_INVERT_X) |
|||
|
|||
#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y) |
|||
#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X) |
|||
|
|||
#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_INVERT_Y) |
|||
#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_INVERT_X) |
|||
|
|||
// TFT_ROTATION is user configurable
|
|||
#ifndef TFT_ROTATION |
|||
#define TFT_ROTATION TFT_NO_ROTATION |
|||
#endif |
|||
|
|||
|
|||
// 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) |
|||
|
|||
// Each TFT Driver is responsible for its default color mode.
|
|||
// #ifndef TFT_COLOR
|
|||
// #define TFT_COLOR TFT_COLOR_RGB
|
|||
// #endif
|
|||
|
|||
#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 |
|||
|
|||
class TFT_IO { |
|||
public: |
|||
static TFT_IO_DRIVER io; |
|||
|
|||
static void InitTFT(); |
|||
static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax); |
|||
static void write_esc_sequence(const uint16_t *Sequence); |
|||
|
|||
// Deletaged methods
|
|||
inline static void Init() { io.Init(); }; |
|||
inline static bool isBusy() { return io.isBusy(); }; |
|||
inline static void Abort() { io.Abort(); }; |
|||
inline static uint32_t GetID() { return io.GetID(); }; |
|||
|
|||
inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); } |
|||
inline static void DataTransferEnd() { io.DataTransferEnd(); }; |
|||
// inline static void DataTransferAbort() { io.DataTransferAbort(); };
|
|||
|
|||
inline static void WriteData(uint16_t Data) { io.WriteData(Data); }; |
|||
inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; |
|||
|
|||
inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; |
|||
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
|
|||
inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); }; |
|||
|
|||
protected: |
|||
static uint32_t lcd_id; |
|||
}; |
|||
|
|||
#endif // HAS_SPI_TFT || HAS_FSMC_TFT
|
Loading…
Reference in new issue