mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-07 14:44:43 +02:00
Add ILI9255 driver
This commit is contained in:
52
TFT_Drivers/ILI9225_Defines.h
Normal file
52
TFT_Drivers/ILI9225_Defines.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 176
|
||||
#define TFT_HEIGHT 220
|
||||
|
||||
/* ILI9225 LCD Registers */
|
||||
#define ILI9225_DRIVER_OUTPUT_CTRL (0x01u) // Driver Output Control
|
||||
#define ILI9225_LCD_AC_DRIVING_CTRL (0x02u) // LCD AC Driving Control
|
||||
#define ILI9225_ENTRY_MODE (0x03u) // Entry Mode
|
||||
#define ILI9225_DISP_CTRL1 (0x07u) // Display Control 1
|
||||
#define ILI9225_BLANK_PERIOD_CTRL1 (0x08u) // Blank Period Control
|
||||
#define ILI9225_FRAME_CYCLE_CTRL (0x0Bu) // Frame Cycle Control
|
||||
#define ILI9225_INTERFACE_CTRL (0x0Cu) // Interface Control
|
||||
#define ILI9225_OSC_CTRL (0x0Fu) // Osc Control
|
||||
#define ILI9225_POWER_CTRL1 (0x10u) // Power Control 1
|
||||
#define ILI9225_POWER_CTRL2 (0x11u) // Power Control 2
|
||||
#define ILI9225_POWER_CTRL3 (0x12u) // Power Control 3
|
||||
#define ILI9225_POWER_CTRL4 (0x13u) // Power Control 4
|
||||
#define ILI9225_POWER_CTRL5 (0x14u) // Power Control 5
|
||||
#define ILI9225_VCI_RECYCLING (0x15u) // VCI Recycling
|
||||
#define ILI9225_RAM_ADDR_SET1 (0x20u) // Horizontal GRAM Address Set
|
||||
#define ILI9225_RAM_ADDR_SET2 (0x21u) // Vertical GRAM Address Set
|
||||
#define ILI9225_GRAM_DATA_REG (0x22u) // GRAM Data Register
|
||||
#define ILI9225_GATE_SCAN_CTRL (0x30u) // Gate Scan Control Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL1 (0x31u) // Vertical Scroll Control 1 Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL2 (0x32u) // Vertical Scroll Control 2 Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL3 (0x33u) // Vertical Scroll Control 3 Register
|
||||
#define ILI9225_PARTIAL_DRIVING_POS1 (0x34u) // Partial Driving Position 1 Register
|
||||
#define ILI9225_PARTIAL_DRIVING_POS2 (0x35u) // Partial Driving Position 2 Register
|
||||
#define ILI9225_HORIZONTAL_WINDOW_ADDR1 (0x36u) // Horizontal Address Start Position
|
||||
#define ILI9225_HORIZONTAL_WINDOW_ADDR2 (0x37u) // Horizontal Address End Position
|
||||
#define ILI9225_VERTICAL_WINDOW_ADDR1 (0x38u) // Vertical Address Start Position
|
||||
#define ILI9225_VERTICAL_WINDOW_ADDR2 (0x39u) // Vertical Address End Position
|
||||
#define ILI9225_GAMMA_CTRL1 (0x50u) // Gamma Control 1
|
||||
#define ILI9225_GAMMA_CTRL2 (0x51u) // Gamma Control 2
|
||||
#define ILI9225_GAMMA_CTRL3 (0x52u) // Gamma Control 3
|
||||
#define ILI9225_GAMMA_CTRL4 (0x53u) // Gamma Control 4
|
||||
#define ILI9225_GAMMA_CTRL5 (0x54u) // Gamma Control 5
|
||||
#define ILI9225_GAMMA_CTRL6 (0x55u) // Gamma Control 6
|
||||
#define ILI9225_GAMMA_CTRL7 (0x56u) // Gamma Control 7
|
||||
#define ILI9225_GAMMA_CTRL8 (0x57u) // Gamma Control 8
|
||||
#define ILI9225_GAMMA_CTRL9 (0x58u) // Gamma Control 9
|
||||
#define ILI9225_GAMMA_CTRL10 (0x59u) // Gamma Control 10
|
||||
|
||||
#define TFT_INVOFF 0x20
|
||||
#define TFT_INVON 0x21
|
||||
#define TFT_SWRST 0x28
|
||||
|
||||
// Delay between some initialisation commands
|
||||
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
|
||||
|
||||
#define TFT_MAD_BGR 0x10
|
114
TFT_Drivers/ILI9225_Init.h
Normal file
114
TFT_Drivers/ILI9225_Init.h
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
// This is the command sequence that initialises the ILI9225 driver
|
||||
|
||||
{
|
||||
/* Start Initial Sequence */
|
||||
|
||||
//LCD Init For 2.2inch LCD Panel with ILI9225.
|
||||
writecommand(ILI9225_POWER_CTRL1);
|
||||
writedata(0x00);writedata(0x00); // Set SAP,DSTB,STB
|
||||
writecommand(ILI9225_POWER_CTRL2);
|
||||
writedata(0x00);writedata(0x00); // Set APON,PON,AON,VCI1EN,VC
|
||||
writecommand(ILI9225_POWER_CTRL3);
|
||||
writedata(0x00);writedata(0x00); // Set BT,DC1,DC2,DC3
|
||||
writecommand(ILI9225_POWER_CTRL4);
|
||||
writedata(0x00);writedata(0x00); // Set GVDD
|
||||
writecommand(ILI9225_POWER_CTRL5);
|
||||
writedata(0x00);writedata(0x00); // Set VCOMH/VCOML voltage
|
||||
spi_end();
|
||||
delay(40);
|
||||
spi_begin();
|
||||
|
||||
// Power-on sequence
|
||||
writecommand(ILI9225_POWER_CTRL2);
|
||||
writedata(0x00);writedata(0x18); // Set APON,PON,AON,VCI1EN,VC
|
||||
writecommand(ILI9225_POWER_CTRL3);
|
||||
writedata(0x61);writedata(0x21); // Set BT,DC1,DC2,DC3
|
||||
writecommand(ILI9225_POWER_CTRL4);
|
||||
writedata(0x00);writedata(0x6F); // Set GVDD /*007F 0088 */
|
||||
writecommand(ILI9225_POWER_CTRL5);
|
||||
writedata(0x49);writedata(0x5F); // Set VCOMH/VCOML voltage
|
||||
writecommand(ILI9225_POWER_CTRL1);
|
||||
writedata(0x08);writedata(0x00); // Set SAP,DSTB,STB
|
||||
spi_end();
|
||||
delay(10);
|
||||
spi_begin();
|
||||
|
||||
writecommand(ILI9225_POWER_CTRL2);
|
||||
writedata(0x10);writedata(0x3B); // Set APON,PON,AON,VCI1EN,VC
|
||||
spi_end();
|
||||
delay(50);
|
||||
spi_begin();
|
||||
|
||||
writecommand(ILI9225_LCD_AC_DRIVING_CTRL);
|
||||
writedata(0x01);writedata(0x00); // set 1 line inversion
|
||||
writecommand(ILI9225_DISP_CTRL1);
|
||||
writedata(0x00);writedata(0x00); // Display off
|
||||
writecommand(ILI9225_BLANK_PERIOD_CTRL1);
|
||||
writedata(0x08);writedata(0x08); // set the back porch and front porch
|
||||
writecommand(ILI9225_FRAME_CYCLE_CTRL);
|
||||
writedata(0x11);writedata(0x00); // set the clocks number per line
|
||||
writecommand(ILI9225_INTERFACE_CTRL);
|
||||
writedata(0x00);writedata(0x00); // CPU interface
|
||||
writecommand(ILI9225_OSC_CTRL);
|
||||
writedata(0x0D);writedata(0x01); // Set Osc /*0e01*/
|
||||
writecommand(ILI9225_VCI_RECYCLING);
|
||||
writedata(0x00);writedata(0x20); // Set VCI recycling
|
||||
writecommand(ILI9225_RAM_ADDR_SET1);
|
||||
writedata(0x00);writedata(0x00); // RAM Address
|
||||
writecommand(ILI9225_RAM_ADDR_SET2);
|
||||
writedata(0x00);writedata(0x00); // RAM Address
|
||||
|
||||
/* Set GRAM area */
|
||||
writecommand(ILI9225_GATE_SCAN_CTRL);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_VERTICAL_SCROLL_CTRL1);
|
||||
writedata(0x00);writedata(0xDB);
|
||||
writecommand(ILI9225_VERTICAL_SCROLL_CTRL2);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_VERTICAL_SCROLL_CTRL3);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_PARTIAL_DRIVING_POS1);
|
||||
writedata(0x00);writedata(0xDB);
|
||||
writecommand(ILI9225_PARTIAL_DRIVING_POS2);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_HORIZONTAL_WINDOW_ADDR1);
|
||||
writedata(0x00);writedata(0xAF);
|
||||
writecommand(ILI9225_HORIZONTAL_WINDOW_ADDR2);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_VERTICAL_WINDOW_ADDR1);
|
||||
writedata(0x00);writedata(0xDB);
|
||||
writecommand(ILI9225_VERTICAL_WINDOW_ADDR2);
|
||||
writedata(0x00);writedata(0x00);
|
||||
|
||||
/* Set GAMMA curve */
|
||||
writecommand(ILI9225_GAMMA_CTRL1);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_GAMMA_CTRL2);
|
||||
writedata(0x08);writedata(0x08);
|
||||
writecommand(ILI9225_GAMMA_CTRL3);
|
||||
writedata(0x08);writedata(0x0A);
|
||||
writecommand(ILI9225_GAMMA_CTRL4);
|
||||
writedata(0x00);writedata(0x0A);
|
||||
writecommand(ILI9225_GAMMA_CTRL5);
|
||||
writedata(0x0A);writedata(0x08);
|
||||
writecommand(ILI9225_GAMMA_CTRL6);
|
||||
writedata(0x08);writedata(0x08);
|
||||
writecommand(ILI9225_GAMMA_CTRL7);
|
||||
writedata(0x00);writedata(0x00);
|
||||
writecommand(ILI9225_GAMMA_CTRL8);
|
||||
writedata(0x0A);writedata(0x00);
|
||||
writecommand(ILI9225_GAMMA_CTRL9);
|
||||
writedata(0x07);writedata(0x10);
|
||||
writecommand(ILI9225_GAMMA_CTRL10);
|
||||
writedata(0x07);writedata(0x10);
|
||||
|
||||
writecommand(ILI9225_DISP_CTRL1);
|
||||
writedata(0x00);writedata(0x12);
|
||||
|
||||
spi_end();
|
||||
delay(50);
|
||||
spi_begin();
|
||||
writecommand(ILI9225_DISP_CTRL1);
|
||||
writedata(0x10);writedata(0x17);
|
||||
}
|
39
TFT_Drivers/ILI9225_Rotation.h
Normal file
39
TFT_Drivers/ILI9225_Rotation.h
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
// This is the command sequence that rotates the ILI9225 driver coordinate frame
|
||||
|
||||
rotation = m % 4; // Limit the range of values to 0-3
|
||||
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
writecommand(ILI9225_DRIVER_OUTPUT_CTRL);
|
||||
writedata(0x01);writedata(0x1C);
|
||||
writecommand(ILI9225_ENTRY_MODE);
|
||||
writedata(TFT_MAD_BGR);writedata(0x30);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1:
|
||||
writecommand(ILI9225_DRIVER_OUTPUT_CTRL);
|
||||
writedata(0x00);writedata(0x1C);
|
||||
writecommand(ILI9225_ENTRY_MODE);
|
||||
writedata(TFT_MAD_BGR);writedata(0x38);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2:
|
||||
writecommand(ILI9225_DRIVER_OUTPUT_CTRL);
|
||||
writedata(0x02);writedata(0x1C);
|
||||
writecommand(ILI9225_ENTRY_MODE);
|
||||
writedata(TFT_MAD_BGR);writedata(0x30);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3:
|
||||
writecommand(ILI9225_DRIVER_OUTPUT_CTRL);
|
||||
writedata(0x03);writedata(0x1C);
|
||||
writecommand(ILI9225_ENTRY_MODE);
|
||||
writedata(TFT_MAD_BGR);writedata(0x38);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
@@ -628,6 +628,9 @@ void TFT_eSPI::init(uint8_t tc)
|
||||
#elif defined (GC9A01_DRIVER)
|
||||
#include "TFT_Drivers/GC9A01_Init.h"
|
||||
|
||||
#elif defined (ILI9225_DRIVER)
|
||||
#include "TFT_Drivers/ILI9225_Init.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TFT_INVERSION_ON
|
||||
@@ -710,6 +713,9 @@ void TFT_eSPI::setRotation(uint8_t m)
|
||||
#elif defined (GC9A01_DRIVER)
|
||||
#include "TFT_Drivers/GC9A01_Rotation.h"
|
||||
|
||||
#elif defined (ILI9225_DRIVER)
|
||||
#include "TFT_Drivers/ILI9225_Rotation.h"
|
||||
|
||||
#endif
|
||||
|
||||
delayMicroseconds(10);
|
||||
|
@@ -173,6 +173,9 @@
|
||||
#elif defined (GC9A01_DRIVER)
|
||||
#include "TFT_Drivers/GC9A01_Defines.h"
|
||||
#define TFT_DRIVER 0x9A01
|
||||
#elif defined (ILI9225_DRIVER)
|
||||
#include "TFT_Drivers/ILI9225_Defines.h"
|
||||
#define TFT_DRIVER 0x9225
|
||||
// <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
|
||||
// XYZZY_init.h and XYZZY_rotation.h must also be added in TFT_eSPI.cpp
|
||||
#elif defined (XYZZY_DRIVER)
|
||||
|
Reference in New Issue
Block a user