TFT Refactoring (#19192)
* 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>
This commit is contained in:
@ -1,150 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ILI9328_DRVCTL_SM 0x0400
|
||||
#define ILI9328_DRVCTL_SS 0x0100 // Select the shift direction of outputs from the source driver. 0 - from S1 to S720 / 1 - from S720 to S1
|
||||
|
||||
#define ILI9328_GATE_SCANCTL_GS 0x8000 // Sets the direction of scan by the gate driver in the range determined by SCN[4:0] and NL[4:0].
|
||||
|
||||
#define ILI9328_ETMOD_TRI 0x8000
|
||||
#define ILI9328_ETMOD_DFM 0x4000
|
||||
#define ILI9328_ETMOD_BGR 0x1000 // RGB-BGR ORDER
|
||||
#define ILI9328_ETMOD_RGB 0x0000
|
||||
#define ILI9328_ETMOD_ORG 0x0080
|
||||
#define ILI9328_ETMOD_ID1 0x0020 // 0 - Vertical Decrement / 1 - Vertical Increment
|
||||
#define ILI9328_ETMOD_ID0 0x0010 // 0 - Horizontal Decrement / 1 - Horizontal Increment
|
||||
#define ILI9328_ETMOD_AM 0x0008 // 0 - Horizontal / 1 - Vertical
|
||||
|
||||
// MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
|
||||
#define ILI9328_DRVCTL_DATA ILI9328_DRVCTL_SS
|
||||
#define ILI9328_ETMOD_DATA ILI9328_ETMOD_BGR | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0 | ILI9328_ETMOD_AM
|
||||
|
||||
#define ILI9328_RDDID 0x00 // ID code - 0x9328
|
||||
#define ILI9328_DRVCTL 0x01 // Driver Output Control
|
||||
#define ILI9328_LCDCTL 0x02 // LCD Driving Wave Control
|
||||
#define ILI9328_ETMOD 0x03 // Entry Mode - Control the GRAM update direction
|
||||
#define ILI9328_RESIZECTL 0x04 // Resizing Control Register
|
||||
#define ILI9328_DISCTRL1 0x07 // Display Control 1
|
||||
#define ILI9328_DISCTRL2 0x08 // Display Control 2
|
||||
#define ILI9328_DISCTRL3 0x09 // Display Control 3
|
||||
#define ILI9328_DISCTRL4 0x0A // Display Control 4
|
||||
#define ILI9328_RGBCTRL1 0x0C // RGB Display Interface Control 1
|
||||
#define ILI9328_FMARKERPOS 0x0D // Frame Marker Position
|
||||
#define ILI9328_RGBCTRL2 0x0F // RGB Display Interface Control 2
|
||||
#define ILI9328_PWCTRL1 0x10 // Power Control 1
|
||||
#define ILI9328_PWCTRL2 0x11 // Power Control 2
|
||||
#define ILI9328_PWCTRL3 0x12 // Power Control 3
|
||||
#define ILI9328_PWCTRL4 0x13 // Power Control 4
|
||||
|
||||
// With landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
|
||||
#define ILI9328_HASET 0x20 // GRAM Horizontal Address Set (0-255)
|
||||
#define ILI9328_VASET 0x21 // GRAM Vertical Address Set (0-511)
|
||||
#define ILI9328_RAMWR 0x22 // Write data to GRAM
|
||||
#define ILI9328_RAMRD 0x22 // Read Data from GRAM
|
||||
|
||||
#define ILI9328_PWCTRL7 0x29 // Power Control 7
|
||||
#define ILI9328_FRMCTR 0x2B // Frame Rate and Color Control
|
||||
#define ILI9328_GAMCTRL1 0x30 // Gamma Control
|
||||
#define ILI9328_GAMCTRL2 0x31 // Gamma Control
|
||||
#define ILI9328_GAMCTRL3 0x32 // Gamma Control
|
||||
#define ILI9328_GAMCTRL4 0x35 // Gamma Control
|
||||
#define ILI9328_GAMCTRL5 0x36 // Gamma Control
|
||||
#define ILI9328_GAMCTRL6 0x37 // Gamma Control
|
||||
#define ILI9328_GAMCTRL7 0x38 // Gamma Control
|
||||
#define ILI9328_GAMCTRL8 0x39 // Gamma Control
|
||||
#define ILI9328_GAMCTRL9 0x3C // Gamma Control
|
||||
#define ILI9328_GAMCTRLA 0x3D // Gamma Control
|
||||
|
||||
// With landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
|
||||
#define ILI9328_HASTART 0x50 // Horizontal Address Start Position (0-255)
|
||||
#define ILI9328_HAEND 0x51 // Horizontal Address End Position (0-255)
|
||||
#define ILI9328_VASTART 0x52 // Vertical Address Start Position (0-511)
|
||||
#define ILI9328_VAEND 0x53 // Vertical Address End Position (0-511)
|
||||
|
||||
#define ILI9328_GATE_SCANCTL1 0x60 // Gate Scan Control
|
||||
#define ILI9328_GATE_SCANCTL2 0x61 // Gate Scan Control
|
||||
#define ILI9328_GATE_SCANCTL3 0x6A // Gate Scan Control
|
||||
|
||||
#define ILI9328_PLTPOS1 0x80 // Partial Image 1 Display Position
|
||||
#define ILI9328_PLTSTART1 0x81 // Partial Image 1 RAM Start Address
|
||||
#define ILI9328_PLTEND1 0x82 // Partial Image 1 RAM End Address
|
||||
#define ILI9328_PLTPOS2 0x83 // Partial Image 2 Display Position
|
||||
#define ILI9328_PLTSTART2 0x84 // Partial Image 2 RAM Start Address
|
||||
#define ILI9328_PLTEND2 0x85 // Partial Image 2 RAM End Address
|
||||
|
||||
#define ILI9328_IFCTL1 0x90 // Panel Interface Control 1
|
||||
#define ILI9328_IFCTL2 0x92 // Panel Interface Control 2
|
||||
#define ILI9328_IFCTL4 0x95 // Panel Interface Control 4
|
||||
#define ILI9328_IFCTL5 0x97 // Panel Interface Control 5
|
||||
|
||||
#define ILI9328_OTPWR 0xA1 // OTP VCM Programming Control
|
||||
#define ILI9328_RDOTP 0xA2 // OTP VCM Status and Enable
|
||||
#define ILI9328_OTPPKEY 0xA5 // OTP Programming ID Key
|
||||
|
||||
|
||||
static const uint16_t ili9328_init[] = {
|
||||
DATASIZE_16BIT,
|
||||
ESC_REG(ILI9328_DRVCTL), ILI9328_DRVCTL_DATA,
|
||||
ESC_REG(ILI9328_LCDCTL), 0x0400, // LCD Driving Wave Control
|
||||
ESC_REG(ILI9328_ETMOD), ILI9328_ETMOD_DATA,
|
||||
|
||||
ESC_REG(ILI9328_RESIZECTL), 0x0000,
|
||||
ESC_REG(ILI9328_DISCTRL2), 0x0202,
|
||||
ESC_REG(ILI9328_DISCTRL3), 0x0000,
|
||||
ESC_REG(ILI9328_DISCTRL4), 0x0000,
|
||||
ESC_REG(ILI9328_RGBCTRL1), 0x0000,
|
||||
ESC_REG(ILI9328_FMARKERPOS), 0x0000,
|
||||
ESC_REG(ILI9328_RGBCTRL2), 0x0000,
|
||||
ESC_REG(ILI9328_PWCTRL1), 0x0000,
|
||||
ESC_REG(ILI9328_PWCTRL2), 0x0007,
|
||||
ESC_REG(ILI9328_PWCTRL3), 0x0000,
|
||||
ESC_REG(ILI9328_PWCTRL4), 0x0000,
|
||||
ESC_REG(ILI9328_DISCTRL1), 0x0001,
|
||||
ESC_DELAY(200),
|
||||
ESC_REG(ILI9328_PWCTRL1), 0x1690,
|
||||
ESC_REG(ILI9328_PWCTRL2), 0x0227,
|
||||
ESC_DELAY(50),
|
||||
ESC_REG(ILI9328_PWCTRL3), 0x008C,
|
||||
ESC_DELAY(50),
|
||||
ESC_REG(ILI9328_PWCTRL4), 0x1500,
|
||||
ESC_REG(ILI9328_PWCTRL7), 0x0004,
|
||||
ESC_REG(ILI9328_FRMCTR), 0x000D,
|
||||
ESC_DELAY(50),
|
||||
ESC_REG(ILI9328_GATE_SCANCTL1), 0x2700,
|
||||
ESC_REG(ILI9328_GATE_SCANCTL2), 0x0001,
|
||||
ESC_REG(ILI9328_GATE_SCANCTL3), 0x0000,
|
||||
ESC_REG(ILI9328_PLTPOS1), 0x0000,
|
||||
ESC_REG(ILI9328_PLTSTART1), 0x0000,
|
||||
ESC_REG(ILI9328_PLTEND1), 0x0000,
|
||||
ESC_REG(ILI9328_PLTPOS2), 0x0000,
|
||||
ESC_REG(ILI9328_PLTSTART2), 0x0000,
|
||||
ESC_REG(ILI9328_PLTEND2), 0x0000,
|
||||
ESC_REG(ILI9328_IFCTL1), 0x0010,
|
||||
ESC_REG(ILI9328_IFCTL2), 0x0600,
|
||||
ESC_REG(ILI9328_DISCTRL1), 0x0133,
|
||||
ESC_END
|
||||
};
|
@ -1,166 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ILI9341_MADCTL_MY 0x80 // Row Address Order
|
||||
#define ILI9341_MADCTL_MX 0x40 // Column Address Order
|
||||
#define ILI9341_MADCTL_MV 0x20 // Row/Column Exchange
|
||||
#define ILI9341_MADCTL_ML 0x10 // Vertical Refresh Order
|
||||
#define ILI9341_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
||||
#define ILI9341_MADCTL_RGB 0x00
|
||||
#define ILI9341_MADCTL_MH 0x04 // Horizontal Refresh Order
|
||||
|
||||
#define ILI9341_ORIENTATION_UP ILI9341_MADCTL_MY // 240x320 ; Cable on the upper side
|
||||
#define ILI9341_ORIENTATION_RIGHT ILI9341_MADCTL_MV // 320x240 ; Cable on the right side
|
||||
#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
|
||||
|
||||
#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
|
||||
#define ILI9341_SWRESET 0x01 // Software Reset
|
||||
#define ILI9341_RDDIDIF 0x04 // Read display identification information
|
||||
#define ILI9341_RDDST 0x09 // Read Display Status
|
||||
#define ILI9341_RDDPM 0x0A // Read Display Power Mode
|
||||
#define ILI9341_RDDMADCTL 0x0B // Read Display MADCTL
|
||||
#define ILI9341_RDDCOLMOD 0x0C // Read Display Pixel Format
|
||||
#define ILI9341_RDDIM 0x0D // Read Display Image Format
|
||||
#define ILI9341_RDDSM 0x0E // Read Display Signal Mode
|
||||
#define ILI9341_RDDSDR 0x0F // Read Display Self-Diagnostic Result
|
||||
#define ILI9341_SPLIN 0x10 // Enter Sleep Mode
|
||||
#define ILI9341_SLPOUT 0x11 // Sleep Out
|
||||
#define ILI9341_PTLON 0x12 // Partial Mode ON
|
||||
#define ILI9341_NORON 0x13 // Normal Display Mode ON
|
||||
#define ILI9341_DINVOFF 0x20 // Display Inversion OFF
|
||||
#define ILI9341_DINVON 0x21 // Display Inversion ON
|
||||
#define ILI9341_GAMSET 0x26 // Gamma Set
|
||||
#define ILI9341_DISPOFF 0x28 // Display OFF
|
||||
#define ILI9341_DISPON 0x29 // Display ON
|
||||
#define ILI9341_CASET 0x2A // Column Address Set
|
||||
#define ILI9341_PASET 0x2B // Page Address Set
|
||||
#define ILI9341_RAMWR 0x2C // Memory Write
|
||||
#define ILI9341_RGBSET 0x2D // Color Set
|
||||
#define ILI9341_RAMRD 0x2E // Memory Read
|
||||
#define ILI9341_PLTAR 0x30 // Partial Area
|
||||
#define ILI9341_VSCRDEF 0x33 // Vertical Scrolling Definition
|
||||
#define ILI9341_TEOFF 0x34 // Tearing Effect Line OFF
|
||||
#define ILI9341_TEON 0x35 // Tearing Effect Line ON
|
||||
#define ILI9341_MADCTL 0x36 // Memory Access Control
|
||||
#define ILI9341_VSCRSADD 0x37 // Vertical Scrolling Start Address
|
||||
#define ILI9341_IDMOFF 0x38 // Idle Mode OFF
|
||||
#define ILI9341_IDMON 0x39 // Idle Mode ON
|
||||
#define ILI9341_PIXSET 0x3A // COLMOD: Pixel Format Set
|
||||
#define ILI9341_WRMEMC 0x3C // Write Memory Continue
|
||||
#define ILI9341_RDMEMC 0x3E // Read Memory Continue
|
||||
#define ILI9341_STE 0x44 // Set Tear Scanline
|
||||
#define ILI9341_GSCAN 0x45 // Get Scanline
|
||||
#define ILI9341_WRDISBV 0x51 // Write Display Brightness
|
||||
#define ILI9341_RDDISBV 0x52 // Read Display Brightness
|
||||
#define ILI9341_WRCTRLD 0x53 // Write CTRL Display
|
||||
#define ILI9341_RDCTRLD 0x54 // Read CTRL Display
|
||||
#define ILI9341_WRCABC 0x55 // Write Content Adaptive Brightness Control
|
||||
#define ILI9341_RDCABC 0x56 // Read Content Adaptive Brightness Control
|
||||
#define ILI9341_WRCABCMB 0x5E // Write CABC Minimum Brightness / Backlight Control 1
|
||||
#define ILI9341_RDCABCMB 0x5F // Read CABC Minimum Brightness / Backlight Control 1
|
||||
#define ILI9341_RDID1 0xDA // Read ID1
|
||||
#define ILI9341_RDID2 0xDB // Read ID2
|
||||
#define ILI9341_RDID3 0xDC // Read ID3
|
||||
|
||||
#define ILI9341_IFMODE 0xB0 // RGB Interface Signal Control
|
||||
#define ILI9341_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors)
|
||||
#define ILI9341_FRMCTR2 0xB2 // Frame Rate Control (In Idle Mode/8 colors)
|
||||
#define ILI9341_FRMCTR3 0xB3 // Frame Rate control (In Partial Mode/Full Colors)
|
||||
#define ILI9341_INVTR 0xB4 // Display Inversion Control
|
||||
#define ILI9341_PRCTR 0xB5 // Blanking Porch Control
|
||||
#define ILI9341_DISCTRL 0xB6 // Display Function Control
|
||||
#define ILI9341_ETMOD 0xB7 // Entry Mode Set
|
||||
#define ILI9341_BLCTL1 0xB8 // Backlight Control 1
|
||||
#define ILI9341_BLCTL2 0xB9 // Backlight Control 2
|
||||
#define ILI9341_BLCTL3 0xBA // Backlight Control 3
|
||||
#define ILI9341_BLCTL4 0xBB // Backlight Control 4
|
||||
#define ILI9341_BLCTL5 0xBC // Backlight Control 5
|
||||
#define ILI9341_BLCTL7 0xBE // Backlight Control 7
|
||||
#define ILI9341_BLCTL8 0xBF // Backlight Control 8
|
||||
#define ILI9341_PWCTRL1 0xC0 // Power Control 1
|
||||
#define ILI9341_PWCTRL2 0xC1 // Power Control 2
|
||||
#define ILI9341_VMCTRL1 0xC5 // VCOM Control 1
|
||||
#define ILI9341_VMCTRL2 0xC7 // VCOM Control 2
|
||||
#define ILI9341_PWCTRLA 0xCB // Power control A
|
||||
#define ILI9341_PWCTRLB 0xCF // Power control B
|
||||
#define ILI9341_NVMWR 0xD0 // NV Memory Write
|
||||
#define ILI9341_NVMPKEY 0xD1 // NV Memory Protection Key
|
||||
#define ILI9341_RDNVM 0xD2 // NV Memory Status Read
|
||||
#define ILI9341_RDID4 0xD3 // Read ID4 - 0x009341
|
||||
#define ILI9341_PGAMCTRL 0xE0 // Positive Gamma Correction
|
||||
#define ILI9341_NGAMCTRL 0xE1 // Negative Gamma Correction
|
||||
#define ILI9341_DGAMCTRL1 0xE2 // Digital Gamma Control 1
|
||||
#define ILI9341_DGAMCTRL2 0xE3 // Digital Gamma Control 2
|
||||
#define ILI9341_DRVTCTLA1 0xE8 // Driver timing control A
|
||||
#define ILI9341_DRVTCTLA2 0xE9 // Driver timing control A
|
||||
#define ILI9341_DRVTCTLB 0xEA // Driver timing control B
|
||||
#define ILI9341_PONSEQCTL 0xED // Power on sequence control
|
||||
#define ILI9341_EN3G 0xF2 // Enable 3G - 3 gamma control
|
||||
#define ILI9341_IFCTL 0xF6 // Interface Control
|
||||
#define ILI9341_PUMPRCTL 0xF7 // Pump ratio control
|
||||
|
||||
|
||||
static const uint16_t ili9341_init[] = {
|
||||
DATASIZE_8BIT,
|
||||
ESC_REG(ILI9341_SWRESET), ESC_DELAY(100),
|
||||
ESC_REG(ILI9341_SLPOUT), ESC_DELAY(20),
|
||||
/*
|
||||
ESC_REG(ILI9341_PWCTRLA), 0x0039, 0x002C, 0x0000, 0x0034, 0x0002, // Power control A
|
||||
ESC_REG(ILI9341_PWCTRLB), 0x0000, 0x00C1, 0x0030, // Power control B
|
||||
ESC_REG(ILI9341_DRVTCTLA1), 0x0085, 0x0000, 0x0078, // Driver timing control A
|
||||
ESC_REG(ILI9341_DRVTCTLB), 0x0000, 0x0000, // Driver timing control B
|
||||
ESC_REG(ILI9341_PONSEQCTL), 0x0064, 0x0003, 0x0012, 0x0081, // Power on sequence control
|
||||
ESC_REG(ILI9341_DISCTRL), 0x0008, 0x0082, 0x0027, // Display Function Control
|
||||
ESC_REG(ILI9341_PUMPRCTL), 0x0020, // Pump ratio control
|
||||
ESC_REG(ILI9341_VMCTRL1), 0x003E, 0x0028, // VCOM Control 1
|
||||
ESC_REG(ILI9341_VMCTRL2), 0x0086, // VCOM Control 2
|
||||
ESC_REG(ILI9341_FRMCTR1), 0x0000, 0x0018, // Frame Rate Control (In Normal Mode/Full Colors)
|
||||
ESC_REG(ILI9341_PWCTRL1), 0x0023, // Power Control 1
|
||||
ESC_REG(ILI9341_PWCTRL2), 0x0010, // Power Control 2
|
||||
*/
|
||||
ESC_REG(ILI9341_MADCTL), ILI9341_MADCTL_DATA,
|
||||
ESC_REG(ILI9341_PIXSET), 0x0055,
|
||||
|
||||
/* Gamma Correction */
|
||||
ESC_REG(ILI9341_EN3G), 0x0000, // 3Gamma Function Disable
|
||||
ESC_REG(ILI9341_GAMSET), 0x0001, // Gamma curve selected
|
||||
ESC_REG(ILI9341_PGAMCTRL), 0x000F, 0x0031, 0x002B, 0x000C, 0x000E, 0x0008, 0x004E, 0x00F1, 0x0037, 0x0007, 0x0010, 0x0003, 0x000E, 0x0009, 0x0000,
|
||||
ESC_REG(ILI9341_NGAMCTRL), 0x0000, 0x000E, 0x0014, 0x0003, 0x0011, 0x0007, 0x0031, 0x00C1, 0x0048, 0x0008, 0x000F, 0x000C, 0x0031, 0x0036, 0x000F,
|
||||
|
||||
ESC_REG(ILI9341_NORON),
|
||||
ESC_REG(ILI9341_DISPON),
|
||||
ESC_END
|
||||
};
|
@ -1,160 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ILI9488_MADCTL_MY 0x80 // Row Address Order
|
||||
#define ILI9488_MADCTL_MX 0x40 // Column Address Order
|
||||
#define ILI9488_MADCTL_MV 0x20 // Row/Column Exchange
|
||||
#define ILI9488_MADCTL_ML 0x10 // Vertical Refresh Order
|
||||
#define ILI9488_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
||||
#define ILI9488_MADCTL_RGB 0x00
|
||||
#define ILI9488_MADCTL_MH 0x04 // Horizontal Refresh Order
|
||||
|
||||
#define ILI9488_ORIENTATION_UP ILI9488_MADCTL_MY // 320x480 ; Cable on the upper side
|
||||
#define ILI9488_ORIENTATION_RIGHT ILI9488_MADCTL_MV // 480x320 ; Cable on the right side
|
||||
#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
|
||||
|
||||
#ifndef ILI9488_COLOR_RGB
|
||||
#define ILI9488_COLOR_BGR
|
||||
#endif
|
||||
#ifndef ILI9488_ORIENTATION
|
||||
#define ILI9488_ORIENTATION ILI9488_ORIENTATION_LEFT
|
||||
#endif
|
||||
#define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION | TERN(ILI9488_COLOR_BGR, ILI9488_MADCTL_BGR, ILI9488_MADCTL_RGB))
|
||||
|
||||
#define ILI9488_NOP 0x00 // No Operation
|
||||
#define ILI9488_SWRESET 0x01 // Software Reset
|
||||
#define ILI9488_RDDIDIF 0x04 // Read Display Identification Information
|
||||
#define ILI9488_RDNUMED 0x05 // Read Number of the Errors on DSI
|
||||
#define ILI9488_RDDST 0x09 // Read Display Status
|
||||
#define ILI9488_RDDPM 0x0A // Read Display Power Mode
|
||||
#define ILI9488_RDDMADCTL 0x0B // Read Display MADCTL
|
||||
#define ILI9488_RDDCOLMOD 0x0C // Read Display COLMOD
|
||||
#define ILI9488_RDDIM 0x0D // Read Display Image Mode
|
||||
#define ILI9488_RDDSM 0x0E // Read Display Signal Mode
|
||||
#define ILI9488_RDDSDR 0x0F // Read Display Self-Diagnostic Result
|
||||
#define ILI9488_SLPIN 0x10 // Sleep IN
|
||||
#define ILI9488_SLPOUT 0x11 // Sleep OUT
|
||||
#define ILI9488_PTLON 0x12 // Partial Mode ON
|
||||
#define ILI9488_NORON 0x13 // Normal Display Mode ON
|
||||
#define ILI9488_INVOFF 0x20 // Display Inversion OFF
|
||||
#define ILI9488_INVON 0x21 // Display Inversion ON
|
||||
#define ILI9488_ALLPOFF 0x22 // All Pixels OFF
|
||||
#define ILI9488_ALLPON 0x23 // All Pixels ON
|
||||
#define ILI9488_DISOFF 0x28 // Display OFF
|
||||
#define ILI9488_DISON 0x29 // Display ON
|
||||
#define ILI9488_CASET 0x2A // Column Address Set
|
||||
#define ILI9488_PASET 0x2B // Page Address Set
|
||||
#define ILI9488_RAMWR 0x2C // Memory Write
|
||||
#define ILI9488_RAMRD 0x2E // Memory Read
|
||||
#define ILI9488_PLTAR 0x30 // Partial Area
|
||||
#define ILI9488_VSCRDEF 0x33 // Vertical Scrolling Definition
|
||||
#define ILI9488_TEOFF 0x34 // Tearing Effect Line OFF
|
||||
#define ILI9488_TEON 0x35 // Tearing Effect Line ON
|
||||
#define ILI9488_MADCTL 0x36 // Memory Access Control
|
||||
#define ILI9488_VSCRSADD 0x37 // Vertical Scrolling Start Address
|
||||
#define ILI9488_IDMOFF 0x38 // Idle Mode OFF
|
||||
#define ILI9488_IDMON 0x39 // Idle Mode ON
|
||||
#define ILI9488_COLMOD 0x3A // Interface Pixel Format
|
||||
#define ILI9488_RAMWRC 0x3C // Memory Write Continue
|
||||
#define ILI9488_RAMRDRC 0x3E // Memory Read Continue
|
||||
#define ILI9488_TESLWR 0x44 // Write Tear Scan Line
|
||||
#define ILI9488_TESLRD 0x45 // Read Scan Line
|
||||
#define ILI9488_WRDISBV 0x51 // Write Display Brightness Value
|
||||
#define ILI9488_RDDISBV 0x52 // Read Display Brightness Value
|
||||
#define ILI9488_WRCTRLD 0x53 // Write Control Display Value
|
||||
#define ILI9488_RDCTRLD 0x54 // Read Control Display Value
|
||||
#define ILI9488_WRCABC 0x55 // Write Content Adaptive Brightness Control Value
|
||||
#define ILI9488_RDCABC 0x56 // Read Content Adaptive Brightness Control Value
|
||||
#define ILI9488_WRCABCMB 0x5E // Write CABC Minimum Brightness
|
||||
#define ILI9488_RDCABCMB 0x5F // Read CABC Minimum Brightness
|
||||
#define ILI9488_RDABCSDR 0x68 // Read Automatic Brightness Control Self-diagnostic Result
|
||||
#define ILI9488_RDID1 0xDA // Read ID1
|
||||
#define ILI9488_RDID2 0xDB // Read ID2
|
||||
#define ILI9488_RDID3 0xDC // Read ID3
|
||||
|
||||
#define ILI9488_IFMODE 0xB0 // Interface Mode Control
|
||||
#define ILI9488_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors)
|
||||
#define ILI9488_FRMCTR2 0xB2 // Frame Rate Control (In Idle Mode/8 Colors)
|
||||
#define ILI9488_FRMCTR3 0xB3 // Frame Rate Control (In Partial Mode/Full Colors)
|
||||
#define ILI9488_INVTR 0xB4 // Display Inversion Control
|
||||
#define ILI9488_PRCTR 0xB5 // Blanking Porch Control
|
||||
#define ILI9488_DISCTRL 0xB6 // Display Function Control
|
||||
#define ILI9488_ETMOD 0xB7 // Entry Mode Set
|
||||
#define ILI9488_CECTRL1 0xB9 // Color Enhancement Control 1
|
||||
#define ILI9488_CECTRL2 0xBA // Color Enhancement Control 2
|
||||
#define ILI9488_HSLCTRL 0xBE // HS Lanes Control
|
||||
#define ILI9488_PWCTRL1 0xC0 // Power Control 1
|
||||
#define ILI9488_PWCTRL2 0xC1 // Power Control 2
|
||||
#define ILI9488_PWCTRL3 0xC2 // Power Control 3 (For Normal Mode)
|
||||
#define ILI9488_PWCTRL4 0xC3 // Power Control 4 (For Idle Mode)
|
||||
#define ILI9488_PWCTRL5 0xC4 // Power Control 5 (For Partial Mode)
|
||||
#define ILI9488_VMCTRL 0xC5 // VCOM Control
|
||||
#define ILI9488_CABCCTRL1 0xC6 // CABC Control 1
|
||||
#define ILI9488_CABCCTRL2 0xC8 // CABC Control 2
|
||||
#define ILI9488_CABCCTRL3 0xC9 // CABC Control 3
|
||||
#define ILI9488_CABCCTRL4 0xCA // CABC Control 4
|
||||
#define ILI9488_CABCCTRL5 0xCB // CABC Control 5
|
||||
#define ILI9488_CABCCTRL6 0xCC // CABC Control 6
|
||||
#define ILI9488_CABCCTRL7 0xCD // CABC Control 7
|
||||
#define ILI9488_CABCCTRL8 0xCE // CABC Control 8
|
||||
#define ILI9488_CABCCTRL9 0xCF // CABC Control 9
|
||||
#define ILI9488_NVMWR 0xD0 // NV Memory Write
|
||||
#define ILI9488_NVMPKEY 0xD1 // NV Memory Protection Key
|
||||
#define ILI9488_RDNVM 0xD2 // NV Memory Status Read
|
||||
#define ILI9488_RDID4 0xD3 // Read ID4 - 0x009488
|
||||
#define ILI9488_ADJCTL1 0xD7 // Adjust Control 1
|
||||
#define ILI9488_RDIDV 0xD8 // Read ID Version
|
||||
#define ILI9488_PGAMCTRL 0xE0 // Positive Gamma Control
|
||||
#define ILI9488_NGAMCTRL 0xE1 // Negative Gamma Control
|
||||
#define ILI9488_DGAMCTRL1 0xE2 // Ditigal Gamma Control 1
|
||||
#define ILI9488_DGAMCTRL2 0xE3 // Ditigal Gamma Control 2
|
||||
#define ILI9488_SETIMAGE 0xE9 // Set Image Function
|
||||
#define ILI9488_ADJCTL2 0xF2 // Adjust Control 2
|
||||
#define ILI9488_ADJCTL3 0xF7 // Adjust Control 3
|
||||
#define ILI9488_ADJCTL4 0xF8 // Adjust Control 4
|
||||
#define ILI9488_ADJCTL5 0xF9 // Adjust Control 5
|
||||
#define ILI9488_RDEXTC 0xFB // Read EXTC command is SPI mode
|
||||
#define ILI9488_ADJCTL6 0xFC // Adjust Control 6
|
||||
#define ILI9488_ADJCTL7 0xFF // Adjust Control 7
|
||||
|
||||
static const uint16_t ili9488_init[] = {
|
||||
DATASIZE_8BIT,
|
||||
ESC_REG(ILI9488_SWRESET), ESC_DELAY(120),
|
||||
ESC_REG(ILI9488_SLPOUT), ESC_DELAY(20),
|
||||
|
||||
ESC_REG(ILI9488_MADCTL), ILI9488_MADCTL_DATA,
|
||||
ESC_REG(ILI9488_COLMOD), 0x0055,
|
||||
|
||||
/* Gamma Correction. */
|
||||
ESC_REG(ILI9488_PGAMCTRL), 0x0000, 0x0003, 0x0009, 0x0008, 0x0016, 0x000A, 0x003F, 0x0078, 0x004C, 0x0009, 0x000A, 0x0008, 0x0016, 0x001A, 0x000F,
|
||||
ESC_REG(ILI9488_NGAMCTRL), 0x0000, 0x0016, 0x0019, 0x0003, 0x000F, 0x0005, 0x0032, 0x0045, 0x0046, 0x0004, 0x000E, 0x000D, 0x0035, 0x0037, 0x000F,
|
||||
|
||||
ESC_REG(ILI9488_NORON),
|
||||
ESC_REG(ILI9488_DISON),
|
||||
ESC_END
|
||||
};
|
@ -1,155 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define R61505_DRVCTL_SM 0x0400
|
||||
#define R61505_DRVCTL_SS 0x0100 // Select the shift direction of outputs from the source driver. 0 - from S1 to S720 / 1 - from S720 to S1
|
||||
|
||||
#define R61505_ETMOD_TRIGGER 0x8000 // 18-bit RAM when set; 16-bit RAM when not set
|
||||
#define R61505_ETMOD_DFM 0x4000
|
||||
#define R61505_ETMOD_BGR 0x1000 // RGB-BGR ORDER
|
||||
#define R61505_ETMOD_RGB 0x0000
|
||||
|
||||
#define R61505_ETMOD_HWM 0x0020
|
||||
#define R61505_ETMOD_ORG 0x0080
|
||||
#define R61505_ETMOD_ID1 0x0020 // 0 - Vertical Decrement / 1 - Vertical Increment
|
||||
#define R61505_ETMOD_ID0 0x0010 // 0 - Horizontal Decrement / 1 - Horizontal Increment
|
||||
#define R61505_ETMOD_AM 0x0008 // 0 - Horizontal / 1 - Vertical
|
||||
|
||||
#define R61505_DRVCTRL_GS 0x8000 // Gate Scan direction
|
||||
|
||||
// MKS Robin TFT v1.1 - 320x240 ; Cable on the left side
|
||||
#define R61505_DRVCTL_DATA R61505_DRVCTL_SS
|
||||
#define R61505_ETMOD_DATA R61505_ETMOD_BGR | R61505_ETMOD_ID1 | R61505_ETMOD_ID0 | R61505_ETMOD_AM
|
||||
#define R61505_DRVCTRL_GSDIR R61505_DRVCTRL_GS
|
||||
|
||||
|
||||
#define R61505_RDDID 0x00 // ID code - 0x1505
|
||||
#define R61505_DRVCTL 0x01 // Driver Output Control
|
||||
#define R61505_LCDCTL 0x02 // LCD Driving Wave Control
|
||||
#define R61505_ETMOD 0x03 // Entry Mode - Control the GRAM update direction
|
||||
#define R61505_RESIZECTL 0x04 // Resizing Control Register
|
||||
#define R61505_DISCTRL1 0x07 // Display Control 1
|
||||
#define R61505_DISCTRL2 0x08 // Display Control 2
|
||||
#define R61505_DISCTRL3 0x09 // Display Control 3
|
||||
#define R61505_DISCTRL4 0x0A // Display Control 4
|
||||
#define R61505_RGBCTRL1 0x0C // RGB Display Interface Control 1
|
||||
#define R61505_FMARKERPOS 0x0D // Frame Marker Position
|
||||
#define R61505_RGBCTRL2 0x0F // RGB Display Interface Control 2
|
||||
#define R61505_PWCTRL1 0x10 // Power Control 1
|
||||
#define R61505_PWCTRL2 0x11 // Power Control 2
|
||||
#define R61505_PWCTRL3 0x12 // Power Control 3
|
||||
#define R61505_PWCTRL4 0x13 // Power Control 4
|
||||
|
||||
// With landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
|
||||
#define R61505_HASET 0x20 // GRAM Horizontal Address Set (0-255)
|
||||
#define R61505_VASET 0x21 // GRAM Vertical Address Set (0-511)
|
||||
#define R61505_RAMWR 0x22 // Write data to GRAM
|
||||
#define R61505_RAMRD 0x22 // Read Data from GRAM
|
||||
|
||||
#define R61505_PWCTRL7 0x29 // Power Control 7
|
||||
#define R61505_GAMCTRL1 0x30 // Gamma Control
|
||||
#define R61505_GAMCTRL2 0x31 // Gamma Control
|
||||
#define R61505_GAMCTRL3 0x32 // Gamma Control
|
||||
#define R61505_GAMCTRL4 0x35 // Gamma Control
|
||||
#define R61505_GAMCTRL5 0x36 // Gamma Control
|
||||
#define R61505_GAMCTRL6 0x37 // Gamma Control
|
||||
#define R61505_GAMCTRL7 0x38 // Gamma Control
|
||||
#define R61505_GAMCTRL8 0x39 // Gamma Control
|
||||
#define R61505_GAMCTRL9 0x3C // Gamma Control
|
||||
#define R61505_GAMCTRLA 0x3D // Gamma Control
|
||||
|
||||
// With landscape screen orientation 'Horizontal' is Y and 'Vertical' is X
|
||||
#define R61505_HASTART 0x50 // Horizontal Address Start Position (0-255)
|
||||
#define R61505_HAEND 0x51 // Horizontal Address End Position (0-255)
|
||||
#define R61505_VASTART 0x52 // Vertical Address Start Position (0-511)
|
||||
#define R61505_VAEND 0x53 // Vertical Address End Position (0-511)
|
||||
|
||||
#define R61505_DRVCTRL 0x60 // Driver Output Control
|
||||
#define R61505_BASE_IMAGE_CTRL 0x61 // Base Image Display Control
|
||||
#define R61505_VSCROLL_CTRL 0x6A // Vertical Scroll Control
|
||||
|
||||
#define R61505_PLTPOS1 0x80 // Partial Image 1 Display Position
|
||||
#define R61505_PLTSTART1 0x81 // Partial Image 1 RAM Start Address
|
||||
#define R61505_PLTEND1 0x82 // Partial Image 1 RAM End Address
|
||||
#define R61505_PLTPOS2 0x83 // Partial Image 2 Display Position
|
||||
#define R61505_PLTSTART2 0x84 // Partial Image 2 RAM Start Address
|
||||
#define R61505_PLTEND2 0x85 // Partial Image 2 RAM End Address
|
||||
|
||||
#define R61505_IFCTL1 0x90 // Panel Interface Control 1
|
||||
#define R61505_IFCTL2 0x92 // Panel Interface Control 2
|
||||
#define R61505_IFCTL3 0x93 // Panel Interface Control 3
|
||||
#define R61505_IFCTL4 0x95 // Panel Interface Control 4
|
||||
#define R61505_IFCTL5 0x97 // Panel Interface Control 5
|
||||
#define R61505_IFCTL6 0x98 // Panel Interface Control 6
|
||||
|
||||
#define R61505_OSC_CTRL 0xA4 // Oscillation Control
|
||||
|
||||
|
||||
static const uint16_t r61505_init[] = {
|
||||
DATASIZE_16BIT,
|
||||
ESC_REG(R61505_DRVCTL), R61505_DRVCTL_DATA,
|
||||
ESC_REG(R61505_LCDCTL), 0x0700, // LCD Driving Wave Control
|
||||
ESC_REG(R61505_ETMOD), R61505_ETMOD_DATA,
|
||||
|
||||
ESC_REG(R61505_RESIZECTL), 0x0000,
|
||||
ESC_REG(R61505_DISCTRL1), 0x0173,
|
||||
ESC_REG(R61505_DISCTRL2), 0x0202,
|
||||
ESC_REG(R61505_DISCTRL3), 0x0000,
|
||||
ESC_REG(R61505_DISCTRL4), 0x0000,
|
||||
ESC_REG(R61505_RGBCTRL1), 0x0000,
|
||||
ESC_REG(R61505_FMARKERPOS), 0x0000,
|
||||
ESC_REG(R61505_RGBCTRL2), 0x0000,
|
||||
|
||||
ESC_REG(R61505_PWCTRL1), 0x17B0,
|
||||
ESC_REG(R61505_PWCTRL2), 0x0037,
|
||||
ESC_REG(R61505_PWCTRL3), 0x0138,
|
||||
ESC_REG(R61505_PWCTRL4), 0x1700,
|
||||
ESC_REG(R61505_PWCTRL7), 0x000D,
|
||||
|
||||
ESC_REG(R61505_GAMCTRL1), 0x0001,
|
||||
ESC_REG(R61505_GAMCTRL2), 0x0606,
|
||||
ESC_REG(R61505_GAMCTRL3), 0x0304,
|
||||
ESC_REG(R61505_GAMCTRL4), 0x0103,
|
||||
ESC_REG(R61505_GAMCTRL5), 0x011D,
|
||||
ESC_REG(R61505_GAMCTRL6), 0x0404,
|
||||
ESC_REG(R61505_GAMCTRL7), 0x0404,
|
||||
ESC_REG(R61505_GAMCTRL8), 0x0404,
|
||||
ESC_REG(R61505_GAMCTRL9), 0x0700,
|
||||
ESC_REG(R61505_GAMCTRLA), 0x0A1F,
|
||||
|
||||
ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_GSDIR | 0x2700,
|
||||
ESC_REG(R61505_BASE_IMAGE_CTRL), 0x0001,
|
||||
ESC_REG(R61505_VSCROLL_CTRL), 0x0000,
|
||||
|
||||
ESC_REG(R61505_IFCTL1), 0x0010,
|
||||
ESC_REG(R61505_IFCTL2), 0x0000,
|
||||
ESC_REG(R61505_IFCTL3), 0x0003,
|
||||
ESC_REG(R61505_IFCTL4), 0x0101,
|
||||
ESC_REG(R61505_IFCTL5), 0x0000,
|
||||
ESC_REG(R61505_IFCTL6), 0x0000,
|
||||
ESC_END
|
||||
};
|
@ -1,128 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ST7735_MADCTL_MY 0x80 // Row Address Order
|
||||
#define ST7735_MADCTL_MX 0x40 // Column Address Order
|
||||
#define ST7735_MADCTL_MV 0x20 // Row/Column Exchange
|
||||
#define ST7735_MADCTL_ML 0x10 // Vertical Refresh Order
|
||||
#define ST7735_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
||||
#define ST7735_MADCTL_RGB 0x00
|
||||
#define ST7735_MADCTL_MH 0x04 // Horizontal Refresh Order
|
||||
|
||||
#define ST7735_ORIENTATION_UP 0x00 // 128x160 ; Cable on the upper side
|
||||
#define ST7735_ORIENTATION_RIGHT ST7735_MADCTL_MV | ST7735_MADCTL_MY // 160x128 ; Cable on the right side
|
||||
#define ST7735_ORIENTATION_LEFT ST7735_MADCTL_MV | ST7735_MADCTL_MX // 160x128 ; Cable on the left side
|
||||
#define ST7735_ORIENTATION_DOWN ST7735_MADCTL_MX | ST7735_MADCTL_MY // 128x160 ; Cable on the lower side
|
||||
|
||||
//#define ST7735_COLOR_BGR
|
||||
#define ST7735_ORIENTATION ST7735_ORIENTATION_DOWN
|
||||
#define ST7735_MADCTL_DATA (ST7735_ORIENTATION | TERN(ST7735_COLOR_BGR, ST7735_MADCTL_BGR, ST7735_MADCTL_RGB))
|
||||
|
||||
#define ST7735_NOP 0x00 // No Operation
|
||||
#define ST7735_SWRESET 0x01 // Software reset
|
||||
#define ST7735_RDDID 0x04 // Read Display ID
|
||||
#define ST7735_RDDST 0x09 // Read Display Status
|
||||
#define ST7735_RDDPM 0x0A // Read Display Power Mode
|
||||
#define ST7735_RDDMADCTL 0x0B // Read Display MADCTL
|
||||
#define ST7735_RDDCOLMOD 0x0C // Read Display Pixel Format
|
||||
#define ST7735_RDDIM 0x0D // Read Display Image Mode
|
||||
#define ST7735_RDDSM 0x0E // Read Display Signal Mode
|
||||
#define ST7735_SLPIN 0x10 // Sleep In
|
||||
#define ST7735_SLPOUT 0x11 // Sleep Out
|
||||
#define ST7735_PTLON 0x12 // Partial Display Mode On
|
||||
#define ST7735_NORON 0x13 // Normal Display Mode On
|
||||
#define ST7735_INVOFF 0x20 // Display Inversion Off
|
||||
#define ST7735_INVON 0x21 // Display Inversion On
|
||||
#define ST7735_GAMSET 0x26 // Gamma Set
|
||||
#define ST7735_DISPOFF 0x28 // Display Off // The delay time between DISPON and DISPOFF needs 120ms at least.
|
||||
#define ST7735_DISPON 0x29 // Display On
|
||||
#define ST7735_CASET 0x2A // Column Address Set
|
||||
#define ST7735_RASET 0x2B // Row Address Set
|
||||
#define ST7735_RAMWR 0x2C // Memory Write
|
||||
#define ST7735_RAMRD 0x2E // Memory Read
|
||||
#define ST7735_PTLAR 0x30 // Partial Area
|
||||
#define ST7735_TEOFF 0x34 // Tearing Effect Line OFF
|
||||
#define ST7735_TEON 0x35 // Tearing Effect Line ON
|
||||
#define ST7735_MADCTL 0x36 // Memory Data Access Control
|
||||
#define ST7735_IDMOFF 0x38 // Idle Mode Off
|
||||
#define ST7735_IDMON 0x39 // Idle Mode On
|
||||
#define ST7735_COLMOD 0x3A // Interface Pixel Format
|
||||
#define ST7735_RDID1 0xDA // Read ID1 Value
|
||||
#define ST7735_RDID2 0xDB // Read ID2 Value
|
||||
#define ST7735_RDID3 0xDC // Read ID3 Value
|
||||
|
||||
#define ST7735_FRMCTR1 0xB1 // Frame Rate Control (In normal mode/ Full colors)
|
||||
#define ST7735_FRMCTR2 0xB2 // Frame Rate Control (In Idle mode/ 8-colors)
|
||||
#define ST7735_FRMCTR3 0xB3 // Frame Rate Control (In Partial mode/ full colors)
|
||||
#define ST7735_INVCTR 0xB4 // Display Inversion Control
|
||||
#define ST7735_DISSET5 0xB6 // Display Function set 5
|
||||
#define ST7735_PWCTR1 0xC0 // Power Control 1
|
||||
#define ST7735_PWCTR2 0xC1 // Power Control 2
|
||||
#define ST7735_PWCTR3 0xC2 // Power Control 3 (in Normal mode/ Full colors)
|
||||
#define ST7735_PWCTR4 0xC3 // Power Control 4 (in Idle mode/ 8-colors)
|
||||
#define ST7735_PWCTR5 0xC4 // Power Control 5 (in Partial mode/ full-colors)
|
||||
#define ST7735_VMCTR1 0xC5 // VCOM Control 1
|
||||
#define ST7735_VMOFCTR 0xC7 // VCOM Offset Control
|
||||
#define ST7735_WRID2 0xD1 // Write ID2 Value
|
||||
#define ST7735_WRID3 0xD2 // Write ID3 Value
|
||||
#define ST7735_PWCTR6 0xFC // Power Control 5 (in Partial mode + Idle mode)
|
||||
#define ST7735_NVFCTR1 0xD9 // EEPROM Control Status
|
||||
#define ST7735_NVFCTR2 0xDE // EEPROM Read Command
|
||||
#define ST7735_NVFCTR3 0xDF // EEPROM Write Command
|
||||
#define ST7735_GMCTRP1 0xE0 // Gamma (‘+’polarity) Correction Characteristics Setting
|
||||
#define ST7735_GMCTRN1 0xE1 // GMCTRN1 (E1h): Gamma ‘-’polarity Correction Characteristics Setting
|
||||
#define ST7735_EXTCTRL 0xF0 // Extension Command Control
|
||||
#define ST7735_VCOM4L 0xFF // Vcom 4 Level Control
|
||||
|
||||
static const uint16_t st7735_init[] = {
|
||||
DATASIZE_8BIT,
|
||||
ESC_REG(ST7735_SWRESET), ESC_DELAY(100),
|
||||
ESC_REG(ST7735_SLPOUT), ESC_DELAY(20),
|
||||
/*
|
||||
ESC_REG(ST7735_FRMCTR1), 0x0001, 0x002C, 0x002D,
|
||||
ESC_REG(ST7735_FRMCTR2), 0x0001, 0x002C, 0x002D,
|
||||
ESC_REG(ST7735_FRMCTR3), 0x0001, 0x002C, 0x002D, 0x0001, 0x002C, 0x002D,
|
||||
ESC_REG(ST7735_INVCTR), 0x0007,
|
||||
ESC_REG(ST7735_PWCTR1), 0x00A2, 0x0002, 0x0084,
|
||||
ESC_REG(ST7735_PWCTR2), 0x00C5,
|
||||
ESC_REG(ST7735_PWCTR3), 0x000A, 0x0000,
|
||||
ESC_REG(ST7735_PWCTR4), 0x008A, 0x002A,
|
||||
ESC_REG(ST7735_PWCTR5), 0x008A, 0x00EE,
|
||||
ESC_REG(ST7735_VMCTR1), 0x000E,
|
||||
ESC_REG(ST7735_INVOFF),
|
||||
*/
|
||||
ESC_REG(ST7735_MADCTL), ST7735_MADCTL_DATA,
|
||||
ESC_REG(ST7735_COLMOD), 0x0005,
|
||||
|
||||
/* Gamma Correction. Colors with 'after-reset' settings are bleak */
|
||||
ESC_REG(ST7735_GMCTRP1), 0x0002, 0x001C, 0x0007, 0x0012, 0x0037, 0x0032, 0x0029, 0x002D, 0x0029, 0x0025, 0x002B, 0x0039, 0x0000, 0x0001, 0x0003, 0x0010,
|
||||
ESC_REG(ST7735_GMCTRN1), 0x0003, 0x001D, 0x0007, 0x0006, 0x002E, 0x002C, 0x0029, 0x002D, 0x002E, 0x002E, 0x0037, 0x003F, 0x0000, 0x0000, 0x0002, 0x0010,
|
||||
|
||||
ESC_REG(ST7735_NORON),
|
||||
ESC_REG(ST7735_DISPON),
|
||||
ESC_END
|
||||
};
|
@ -1,150 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ST7789V_MADCTL_MY 0x80 // Row Address Order
|
||||
#define ST7789V_MADCTL_MX 0x40 // Column Address Order
|
||||
#define ST7789V_MADCTL_MV 0x20 // Row/Column Exchange
|
||||
#define ST7789V_MADCTL_ML 0x10 // Vertical Refresh Order
|
||||
#define ST7789V_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
||||
#define ST7789V_MADCTL_RGB 0x00
|
||||
#define ST7789V_MADCTL_MH 0x04 // Horizontal Refresh Order
|
||||
|
||||
#define ST7789V_ORIENTATION_UP ST7789V_MADCTL_MX | ST7789V_MADCTL_MY // 240x320 ; Cable on the upper side
|
||||
#define ST7789V_ORIENTATION_RIGHT ST7789V_MADCTL_MX | ST7789V_MADCTL_MV // 320x240 ; Cable on the right side
|
||||
#define ST7789V_ORIENTATION_LEFT ST7789V_MADCTL_MY | ST7789V_MADCTL_MV // 320x240 ; Cable on the left side
|
||||
#define ST7789V_ORIENTATION_DOWN 0 // 240x320 ; Cable on the lower side
|
||||
|
||||
//#define ST7789V_COLOR_BGR
|
||||
#ifndef ST7789V_ORIENTATION
|
||||
#define ST7789V_ORIENTATION ST7789V_ORIENTATION_LEFT
|
||||
#endif
|
||||
#define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION | TERN(ST7789V_COLOR_BGR, ST7789V_MADCTL_BGR, ST7789V_MADCTL_RGB))
|
||||
|
||||
#define ST7789V_NOP 0x00 // No Operation
|
||||
#define ST7789V_SWRESET 0x01 // Software reset
|
||||
#define ST7789V_RDDID 0x04 // Read Display ID
|
||||
#define ST7789V_RDDST 0x09 // Read Display Status
|
||||
#define ST7789V_RDDPM 0x0A // Read Display Power Mode
|
||||
#define ST7789V_RDDMADCTL 0x0B // Read Display MADCTL
|
||||
#define ST7789V_RDDCOLMOD 0x0C // Read Display Pixel Format
|
||||
#define ST7789V_RDDIM 0x0D // Read Display Image Mode
|
||||
#define ST7789V_RDDSM 0x0E // Read Display Signal Mode
|
||||
#define ST7789V_RDDSDR 0x0F // Read Display Self-Diagnostic Result
|
||||
#define ST7789V_SLPIN 0x10 // Sleep In
|
||||
#define ST7789V_SLPOUT 0x11 // Sleep Out
|
||||
#define ST7789V_PTLON 0x12 // Partial Display Mode On
|
||||
#define ST7789V_NORON 0x13 // Normal Display Mode On
|
||||
#define ST7789V_INVOFF 0x20 // Display Inversion Off
|
||||
#define ST7789V_INVON 0x21 // Display Inversion On
|
||||
#define ST7789V_GAMSET 0x26 // Gamma Set
|
||||
#define ST7789V_DISPOFF 0x28 // Display Off
|
||||
#define ST7789V_DISPON 0x29 // Display On
|
||||
#define ST7789V_CASET 0x2A // Column Address Set
|
||||
#define ST7789V_RASET 0x2B // Row Address Set
|
||||
#define ST7789V_RAMWR 0x2C // Memory Write
|
||||
#define ST7789V_RAMRD 0x2E // Memory Read
|
||||
#define ST7789V_PTLAR 0x30 // Partial Area
|
||||
#define ST7789V_VSCRDEF 0x33 // Vertical Scrolling Definition
|
||||
#define ST7789V_TEOFF 0x34 // Tearing Effect Line OFF
|
||||
#define ST7789V_TEON 0x35 // Tearing Effect Line ON
|
||||
#define ST7789V_MADCTL 0x36 // Memory Data Access Control
|
||||
#define ST7789V_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
|
||||
#define ST7789V_IDMOFF 0x38 // Idle Mode Off
|
||||
#define ST7789V_IDMON 0x39 // Idle Mode On
|
||||
#define ST7789V_COLMOD 0x3A // Interface Pixel Format
|
||||
#define ST7789V_WRMEMC 0x3C // Write Memory Continue
|
||||
#define ST7789V_RDMEMC 0x3E // Read Memory Continue
|
||||
#define ST7789V_STE 0x44 // Set Tear Scanline
|
||||
#define ST7789V_GSCAN 0x45 // Get Scanline
|
||||
#define ST7789V_WRDISBV 0x51 // Write Display Brightness
|
||||
#define ST7789V_RDDISBV 0x52 // Read Display Brightness
|
||||
#define ST7789V_WRCTRLD 0x53 // Write CTRL Display
|
||||
#define ST7789V_RDCTRLD 0x54 // Read CTRL Value Display
|
||||
#define ST7789V_WRCACE 0x55 // Write Content Adaptive Brightness Control and Color Enhancement
|
||||
#define ST7789V_RDCABC 0x56 // Read Content Adaptive Brightness Control
|
||||
#define ST7789V_WRCABCMB 0x5E // Write CABC Minimum Brightness
|
||||
#define ST7789V_RDCABCMB 0x5F // Read CABC Minimum Brightness
|
||||
#define ST7789V_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result
|
||||
#define ST7789V_RDID1 0xDA // Read ID1 Value
|
||||
#define ST7789V_RDID2 0xDB // Read ID2 Value
|
||||
#define ST7789V_RDID3 0xDC // Read ID3 Value
|
||||
|
||||
#define ST7789V_RAMCTRL 0xB0 // RAM Control
|
||||
#define ST7789V_RGBCTRL 0xB1 // RGB Interface Control
|
||||
#define ST7789V_PORCTRL 0xB2 // Porch Setting
|
||||
#define ST7789V_FRCTRL1 0xB3 // Frame Rate Control 1 (In partial mode/ idle colors)
|
||||
#define ST7789V_GCTRL 0xB7 // Gate Control
|
||||
#define ST7789V_DGMEN 0xBA // Digital Gamma Enable
|
||||
#define ST7789V_VCOMS 0xBB // VCOM Setting
|
||||
#define ST7789V_LCMCTRL 0xC0 // LCM Control
|
||||
#define ST7789V_IDSET 0xC1 // ID Code Setting
|
||||
#define ST7789V_VDVVRHEN 0xC2 // VDV and VRH Command Enable
|
||||
#define ST7789V_VRHS 0xC3 // VRH Set
|
||||
#define ST7789V_VDVS 0xC4 // VDV Set
|
||||
#define ST7789V_VCMOFSET 0xC5 // VCOM Offset Set
|
||||
#define ST7789V_FRCTRL2 0xC6 // Frame Rate Control in Normal Mode
|
||||
#define ST7789V_CABCCTRL 0xC7 // CABC Control
|
||||
#define ST7789V_REGSEL1 0xC8 // Register Value Selection 1
|
||||
#define ST7789V_REGSEL2 0xCA // Register Value Selection 2
|
||||
#define ST7789V_PWMFRSEL 0xCC // PWM Frequency Selection
|
||||
#define ST7789V_PWCTRL1 0xD0 // Power Control 1
|
||||
#define ST7789V_VAPVANEN 0xD2 // Enable VAP/VAN signal output
|
||||
#define ST7789V_CMD2EN 0xDF // Command 2 Enable
|
||||
#define ST7789V_PVGAMCTRL 0xE0 // Positive Voltage Gamma Control
|
||||
#define ST7789V_NVGAMCTRL 0xE1 // Negative Voltage Gamma Control
|
||||
#define ST7789V_DGMLUTR 0xE2 // Digital Gamma Look-up Table for Red
|
||||
#define ST7789V_DGMLUTB 0xE3 // Digital Gamma Look-up Table for Blue
|
||||
#define ST7789V_GATECTRL 0xE4 // Gate Control
|
||||
#define ST7789V_SPI2EN 0xE7 // SPI2 Enable
|
||||
#define ST7789V_PWCTRL2 0xE8 // Power Control 2
|
||||
#define ST7789V_EQCTRL 0xE9 // Equalize time control
|
||||
#define ST7789V_PROMCTRL 0xEC // Program Mode Control
|
||||
#define ST7789V_PROMEN 0xFA // Program Mode Enable
|
||||
#define ST7789V_NVMSET 0xFC // NVM Setting
|
||||
#define ST7789V_PROMACT 0xFE // Program action
|
||||
|
||||
static const uint16_t st7789v_init[] = {
|
||||
DATASIZE_8BIT,
|
||||
ESC_REG(ST7789V_SWRESET), ESC_DELAY(100),
|
||||
ESC_REG(ST7789V_SLPOUT), ESC_DELAY(20),
|
||||
|
||||
ESC_REG(ST7789V_PORCTRL), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033,
|
||||
ESC_REG(ST7789V_GCTRL), 0x0035,
|
||||
ESC_REG(ST7789V_VCOMS), 0x001F,
|
||||
ESC_REG(ST7789V_LCMCTRL), 0x002C,
|
||||
ESC_REG(ST7789V_VDVVRHEN), 0x0001, 0x00C3,
|
||||
ESC_REG(ST7789V_VDVS), 0x0020,
|
||||
ESC_REG(ST7789V_FRCTRL2), 0x000F,
|
||||
ESC_REG(ST7789V_PWCTRL1), 0x00A4, 0x00A1,
|
||||
|
||||
ESC_REG(ST7789V_MADCTL), ST7789V_MADCTL_DATA,
|
||||
ESC_REG(ST7789V_COLMOD), 0x0055,
|
||||
|
||||
ESC_REG(ST7789V_NORON),
|
||||
ESC_REG(ST7789V_DISPON),
|
||||
ESC_END
|
||||
};
|
@ -1,175 +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 "tft.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#define ST7796S_MADCTL_MY 0x80 // Row Address Order
|
||||
#define ST7796S_MADCTL_MX 0x40 // Column Address Order
|
||||
#define ST7796S_MADCTL_MV 0x20 // Row/Column Exchange
|
||||
#define ST7796S_MADCTL_ML 0x10 // Vertical Refresh Order
|
||||
#define ST7796S_MADCTL_BGR 0x08 // RGB-BGR ORDER
|
||||
#define ST7796S_MADCTL_RGB 0x00
|
||||
#define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order
|
||||
|
||||
#define ST7796S_COLOR_BGR
|
||||
#define ST7796S_ORIENTATION ST7796S_MADCTL_MV
|
||||
#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB))
|
||||
|
||||
#define ST7796S_NOP 0x00 // No Operation
|
||||
#define ST7796S_SWRESET 0x01 // Software reset
|
||||
#define ST7796S_RDDID 0x04 // Read Display ID
|
||||
#define ST7796S_RDNUMED 0x05 // Read Number of the Errors on DSI
|
||||
#define ST7796S_RDDST 0x09 // Read Display Status
|
||||
#define ST7796S_RDDPM 0x0A // Read Display Power Mode
|
||||
#define ST7796S_RDDMADCTL 0x0B // Read Display MADCTL
|
||||
#define ST7796S_RDDCOLMOD 0x0C // Read Display Pixel Format
|
||||
#define ST7796S_RDDIM 0x0D // Read Display Image Mode
|
||||
#define ST7796S_RDDSM 0x0E // Read Display Signal Status
|
||||
#define ST7796S_RDDSDR 0x0F // Read Display Self-Diagnostic Result
|
||||
#define ST7796S_SLPIN 0x10 // Sleep In
|
||||
#define ST7796S_SLPOUT 0x11 // Sleep Out
|
||||
#define ST7796S_PTLON 0x12 // Partial Display Mode On
|
||||
#define ST7796S_NORON 0x13 // Normal Display Mode On
|
||||
#define ST7796S_INVOFF 0x20 // Display Inversion Off
|
||||
#define ST7796S_INVON 0x21 // Display Inversion On
|
||||
#define ST7796S_DISPOFF 0x28 // Display Off
|
||||
#define ST7796S_DISPON 0x29 // Display On
|
||||
#define ST7796S_CASET 0x2A // Column Address Set
|
||||
#define ST7796S_RASET 0x2B // Row Address Set
|
||||
#define ST7796S_RAMWR 0x2C // Memory Write
|
||||
#define ST7796S_RAMRD 0x2E // Memory Read
|
||||
#define ST7796S_PTLAR 0x30 // Partial Area
|
||||
#define ST7796S_VSCRDEF 0x33 // Vertical Scrolling Definition
|
||||
#define ST7796S_TEOFF 0x34 // Tearing Effect Line OFF
|
||||
#define ST7796S_TEON 0x35 // Tearing Effect Line On
|
||||
#define ST7796S_MADCTL 0x36 // Memory Data Access Control
|
||||
#define ST7796S_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
|
||||
#define ST7796S_IDMOFF 0x38 // Idle Mode Off
|
||||
#define ST7796S_IDMON 0x39 // Idle Mode On
|
||||
#define ST7796S_COLMOD 0x3A // Interface Pixel Format
|
||||
#define ST7796S_WRMEMC 0x3C // Write Memory Continue
|
||||
#define ST7796S_RDMEMC 0x3E // Read Memory Continue
|
||||
#define ST7796S_STE 0x44 // Set Tear ScanLine
|
||||
#define ST7796S_GSCAN 0x45 // Get ScanLine
|
||||
#define ST7796S_WRDISBV 0x51 // Write Display Brightness
|
||||
#define ST7796S_RDDISBV 0x52 // Read Display Brightness Value
|
||||
#define ST7796S_WRCTRLD 0x53 // Write CTRL Display
|
||||
#define ST7796S_RDCTRLD 0x54 // Read CTRL value Display
|
||||
#define ST7796S_WRCABC 0x55 // Write Adaptive Brightness Control
|
||||
#define ST7796S_RDCABC 0x56 // Read Content Adaptive Brightness Control
|
||||
#define ST7796S_WRCABCMB 0x5E // Write CABC Minimum Brightness
|
||||
#define ST7796S_RDCABCMB 0x5F // Read CABC Minimum Brightness
|
||||
#define ST7796S_RDFCS 0xAA // Read First Checksum
|
||||
#define ST7796S_RDCFCS 0xAF // Read Continue Checksum
|
||||
#define ST7796S_RDID1 0xDA // Read ID1
|
||||
#define ST7796S_RDID2 0xDB // Read ID2
|
||||
#define ST7796S_RDID3 0xDC // Read ID3
|
||||
|
||||
#define ST7796S_IFMODE 0xB0 // Interface Mode Control
|
||||
#define ST7796S_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors)
|
||||
#define ST7796S_FRMCTR2 0xB2 // Frame Rate Control 2 (In Idle Mode/8 colors)
|
||||
#define ST7796S_FRMCTR3 0xB3 // Frame Rate Control 3(In Partial Mode/Full Colors)
|
||||
#define ST7796S_DIC 0xB4 // Display Inversion Control
|
||||
#define ST7796S_BPC 0xB5 // Blanking Porch Control
|
||||
#define ST7796S_DFC 0xB6 // Display Function Control
|
||||
#define ST7796S_EM 0xB7 // Entry Mode Set
|
||||
#define ST7796S_PWR1 0xC0 // Power Control 1
|
||||
#define ST7796S_PWR2 0xC1 // Power Control 2
|
||||
#define ST7796S_PWR3 0xC2 // Power Control 3
|
||||
#define ST7796S_VCMPCTL 0xC5 // VCOM Control
|
||||
#define ST7796S_VCMOST 0xC6 // VCOM Offset Register
|
||||
#define ST7796S_NVMADW 0xD0 // NVM Address/Data Write
|
||||
#define ST7796S_NVMBPROG 0xD1 // NVM Byte Program
|
||||
#define ST7796S_NVMSTRD 0xD2 // NVM Status Read
|
||||
#define ST7796S_RDID4 0xD3 // Read ID4
|
||||
#define ST7796S_PGC 0xE0 // Positive Gamma Control
|
||||
#define ST7796S_NGC 0xE1 // Negative Gamma Control
|
||||
#define ST7796S_DGC1 0xE2 // Digital Gamma Control 1
|
||||
#define ST7796S_DGC2 0xE3 // Digital Gamma Control 2
|
||||
#define ST7796S_DOCA 0xE8 // Display Output Ctrl Adjust
|
||||
#define ST7796S_CSCON 0xF0 // Command Set Control
|
||||
#define ST7796S_SPIRC 0xFB // SPI Read Control
|
||||
|
||||
static const uint16_t 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_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_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(0xC3), 0x0009, // Register not documented in datasheet
|
||||
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
|
||||
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
|
||||
};
|
@ -25,173 +25,16 @@
|
||||
#if HAS_GRAPHICAL_TFT
|
||||
|
||||
#include "tft.h"
|
||||
#include "st7735.h"
|
||||
#include "st7789v.h"
|
||||
#include "st7796s.h"
|
||||
#include "r65105.h"
|
||||
#include "ili9328.h"
|
||||
#include "ili9341.h"
|
||||
#include "ili9488.h"
|
||||
|
||||
//#define DEBUG_GRAPHICAL_TFT
|
||||
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
|
||||
#include "../../core/debug_out.h"
|
||||
|
||||
uint16_t TFT::buffer[];
|
||||
uint32_t TFT::lcd_id = 0xFFFFFFFF;
|
||||
|
||||
void TFT::init() {
|
||||
if (lcd_id != 0xFFFFFFFF) return;
|
||||
|
||||
io.Init();
|
||||
|
||||
#if TFT_DRIVER != AUTO
|
||||
lcd_id = TFT_DRIVER;
|
||||
#endif
|
||||
|
||||
#if TFT_DRIVER == ST7735
|
||||
write_esc_sequence(st7735_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 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
|
||||
DEBUG_ECHO_MSG(" ILI9488");
|
||||
write_esc_sequence(ili9488_init);
|
||||
break;
|
||||
default:
|
||||
lcd_id = 0;
|
||||
}
|
||||
#else
|
||||
#error Unsupported TFT driver
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFT::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
|
||||
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::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();
|
||||
io.InitTFT();
|
||||
}
|
||||
|
||||
TFT tft;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "tft_color.h"
|
||||
#include "tft_string.h"
|
||||
#include "tft_image.h"
|
||||
#include "tft_io.h"
|
||||
#include "../tft_io/tft_io.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
@ -40,20 +40,6 @@
|
||||
#error "Unsupported display resolution!"
|
||||
#endif
|
||||
|
||||
#define ST7735 0x89F0
|
||||
#define ST7789 0x8552
|
||||
#define ST7796 0x7796
|
||||
#define R61505 0x1505
|
||||
#define ILI9328 0x9328
|
||||
#define ILI9341 0x9341
|
||||
#define ILI9488 0x9488
|
||||
#define LERDGE_ST7796 0xFFFE
|
||||
#define AUTO 0xFFFF
|
||||
|
||||
#ifndef TFT_DRIVER
|
||||
#define TFT_DRIVER AUTO
|
||||
#endif
|
||||
|
||||
#ifndef TFT_BUFFER_SIZE
|
||||
#ifdef STM32F103xB
|
||||
#define TFT_BUFFER_SIZE 1024
|
||||
@ -71,14 +57,8 @@
|
||||
#error "TFT_BUFFER_SIZE can not exceed 65535"
|
||||
#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 {
|
||||
private:
|
||||
static uint32_t lcd_id;
|
||||
static TFT_String string;
|
||||
static TFT_IO io;
|
||||
|
||||
@ -91,13 +71,11 @@ class TFT {
|
||||
static inline void set_font(const uint8_t *Font) { string.set_font(Font); }
|
||||
static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); }
|
||||
|
||||
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);
|
||||
|
||||
static inline bool is_busy() { return io.isBusy(); }
|
||||
static inline void abort() { io.Abort(); }
|
||||
static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); }
|
||||
static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }
|
||||
static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); }
|
||||
|
||||
static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); }
|
||||
static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }
|
||||
|
@ -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
|
@ -295,6 +295,10 @@ bool Touch::get_point(int16_t *x, int16_t *y) {
|
||||
if (is_touched && calibration.orientation != TOUCH_ORIENTATION_NONE) {
|
||||
*x = int16_t((int32_t(*x) * calibration.x) >> 16) + calibration.offset_x;
|
||||
*y = int16_t((int32_t(*y) * calibration.y) >> 16) + calibration.offset_y;
|
||||
#if (TFT_ROTATION & TFT_ROTATE_180)
|
||||
*x = TFT_WIDTH - *x;
|
||||
*y = TFT_HEIGHT - *y;
|
||||
#endif
|
||||
}
|
||||
return is_touched;
|
||||
}
|
||||
|
Reference in New Issue
Block a user