first commit

This commit is contained in:
jaksatomovic 2024-03-06 12:40:28 +01:00
commit 868b14f8c8
286 changed files with 59925 additions and 0 deletions

View file

@ -0,0 +1,27 @@
// Null set for ePaper
#define TFT_WIDTH 1000
#define TFT_HEIGHT 1000
#define TFT_INIT_DELAY 0
#define TFT_NOP 0x00
#define TFT_SWRST 0x00
#define TFT_CASET 0x00
#define TFT_PASET 0x00
#define TFT_RAMWR 0x00
#define TFT_RAMRD 0x00
#define TFT_IDXRD 0x00
#define TFT_MADCTL 0x00
#define TFT_MAD_MY 0x00
#define TFT_MAD_MX 0x00
#define TFT_MAD_MV 0x00
#define TFT_MAD_ML 0x00
#define TFT_MAD_BGR 0x00
#define TFT_MAD_MH 0x00
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x00
#define TFT_INVON 0x00

View file

@ -0,0 +1,34 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21

View file

@ -0,0 +1,232 @@
// This is the command sequence that initialises the GC9A01 driver
{
writecommand(0xEF);
writecommand(0xEB);
writedata(0x14);
writecommand(0xFE);
writecommand(0xEF);
writecommand(0xEB);
writedata(0x14);
writecommand(0x84);
writedata(0x40);
writecommand(0x85);
writedata(0xFF);
writecommand(0x86);
writedata(0xFF);
writecommand(0x87);
writedata(0xFF);
writecommand(0x88);
writedata(0x0A);
writecommand(0x89);
writedata(0x21);
writecommand(0x8A);
writedata(0x00);
writecommand(0x8B);
writedata(0x80);
writecommand(0x8C);
writedata(0x01);
writecommand(0x8D);
writedata(0x01);
writecommand(0x8E);
writedata(0xFF);
writecommand(0x8F);
writedata(0xFF);
writecommand(0xB6);
writedata(0x00);
writedata(0x20);
writecommand(0x3A);
writedata(0x05);
writecommand(0x90);
writedata(0x08);
writedata(0x08);
writedata(0x08);
writedata(0x08);
writecommand(0xBD);
writedata(0x06);
writecommand(0xBC);
writedata(0x00);
writecommand(0xFF);
writedata(0x60);
writedata(0x01);
writedata(0x04);
writecommand(0xC3);
writedata(0x13);
writecommand(0xC4);
writedata(0x13);
writecommand(0xC9);
writedata(0x22);
writecommand(0xBE);
writedata(0x11);
writecommand(0xE1);
writedata(0x10);
writedata(0x0E);
writecommand(0xDF);
writedata(0x21);
writedata(0x0c);
writedata(0x02);
writecommand(0xF0);
writedata(0x45);
writedata(0x09);
writedata(0x08);
writedata(0x08);
writedata(0x26);
writedata(0x2A);
writecommand(0xF1);
writedata(0x43);
writedata(0x70);
writedata(0x72);
writedata(0x36);
writedata(0x37);
writedata(0x6F);
writecommand(0xF2);
writedata(0x45);
writedata(0x09);
writedata(0x08);
writedata(0x08);
writedata(0x26);
writedata(0x2A);
writecommand(0xF3);
writedata(0x43);
writedata(0x70);
writedata(0x72);
writedata(0x36);
writedata(0x37);
writedata(0x6F);
writecommand(0xED);
writedata(0x1B);
writedata(0x0B);
writecommand(0xAE);
writedata(0x77);
writecommand(0xCD);
writedata(0x63);
writecommand(0x70);
writedata(0x07);
writedata(0x07);
writedata(0x04);
writedata(0x0E);
writedata(0x0F);
writedata(0x09);
writedata(0x07);
writedata(0x08);
writedata(0x03);
writecommand(0xE8);
writedata(0x34);
writecommand(0x62);
writedata(0x18);
writedata(0x0D);
writedata(0x71);
writedata(0xED);
writedata(0x70);
writedata(0x70);
writedata(0x18);
writedata(0x0F);
writedata(0x71);
writedata(0xEF);
writedata(0x70);
writedata(0x70);
writecommand(0x63);
writedata(0x18);
writedata(0x11);
writedata(0x71);
writedata(0xF1);
writedata(0x70);
writedata(0x70);
writedata(0x18);
writedata(0x13);
writedata(0x71);
writedata(0xF3);
writedata(0x70);
writedata(0x70);
writecommand(0x64);
writedata(0x28);
writedata(0x29);
writedata(0xF1);
writedata(0x01);
writedata(0xF1);
writedata(0x00);
writedata(0x07);
writecommand(0x66);
writedata(0x3C);
writedata(0x00);
writedata(0xCD);
writedata(0x67);
writedata(0x45);
writedata(0x45);
writedata(0x10);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writecommand(0x67);
writedata(0x00);
writedata(0x3C);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x54);
writedata(0x10);
writedata(0x32);
writedata(0x98);
writecommand(0x74);
writedata(0x10);
writedata(0x85);
writedata(0x80);
writedata(0x00);
writedata(0x00);
writedata(0x4E);
writedata(0x00);
writecommand(0x98);
writedata(0x3e);
writedata(0x07);
writecommand(0x35);
writecommand(0x21);
writecommand(0x11);
delay(120);
writecommand(0x29);
delay(20);
}

View file

@ -0,0 +1,28 @@
// This is the command sequence that rotates the GC9A01 driver coordinate frame
rotation = m % 4;
writecommand(TFT_MADCTL);
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
}

View 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 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPar.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,76 @@
// This is the command sequence that initialises the HX8357B driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure HX8357-B display
writecommand(0x11);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x42);
writedata(0x18);
writecommand(0xD1);
writedata(0x00);
writedata(0x07);
writedata(0x10);
writecommand(0xD2);
writedata(0x01);
writedata(0x02);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x08);
writecommand(0xC8);
writedata(0x00);
writedata(0x32);
writedata(0x36);
writedata(0x45);
writedata(0x06);
writedata(0x16);
writedata(0x37);
writedata(0x75);
writedata(0x77);
writedata(0x54);
writedata(0x0C);
writedata(0x00);
writecommand(0x36);
writedata(0x0a);
writecommand(0x3A);
writedata(0x55);
writecommand(0x2A);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(0x2B);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(0x29);
delay(25);
// End of HX8357B display configuration

View file

@ -0,0 +1,47 @@
// This is the command sequence that rotates the HX8357C driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 8;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MX);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata( TFT_MAD_COLOR_ORDER | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
case 4: // Portrait
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 5: // Landscape (Portrait + 90)
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MX);
_width = _init_height;
_height = _init_width;
break;
case 6: // Inverter portrait
writedata( TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 7: // Inverted landscape
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
}

View 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 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPar.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,116 @@
// This is the command sequence that initialises the HX8357C driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure HX8357C display
writecommand(0xB9); // Enable extension command
writedata(0xFF);
writedata(0x83);
writedata(0x57);
delay(50);
writecommand(0xB6); //Set VCOM voltage
writedata(0x2C); //0x52 for HSD 3.0"
writecommand(0x11); // Sleep off
delay(200);
writecommand(0x35); // Tearing effect on
writedata(0x00); // Added parameter
writecommand(0x3A); // Interface pixel format
writedata(0x55); // 16 bits per pixel
//writecommand(0xCC); // Set panel characteristic
//writedata(0x09); // S960>S1, G1>G480, R-G-B, normally black
//writecommand(0xB3); // RGB interface
//writedata(0x43);
//writedata(0x00);
//writedata(0x06);
//writedata(0x06);
writecommand(0xB1); // Power control
writedata(0x00);
writedata(0x15);
writedata(0x0D);
writedata(0x0D);
writedata(0x83);
writedata(0x48);
writecommand(0xC0); // Does this do anything?
writedata(0x24);
writedata(0x24);
writedata(0x01);
writedata(0x3C);
writedata(0xC8);
writedata(0x08);
writecommand(0xB4); // Display cycle
writedata(0x02);
writedata(0x40);
writedata(0x00);
writedata(0x2A);
writedata(0x2A);
writedata(0x0D);
writedata(0x4F);
writecommand(0xE0); // Gamma curve
writedata(0x00);
writedata(0x15);
writedata(0x1D);
writedata(0x2A);
writedata(0x31);
writedata(0x42);
writedata(0x4C);
writedata(0x53);
writedata(0x45);
writedata(0x40);
writedata(0x3B);
writedata(0x32);
writedata(0x2E);
writedata(0x28);
writedata(0x24);
writedata(0x03);
writedata(0x00);
writedata(0x15);
writedata(0x1D);
writedata(0x2A);
writedata(0x31);
writedata(0x42);
writedata(0x4C);
writedata(0x53);
writedata(0x45);
writedata(0x40);
writedata(0x3B);
writedata(0x32);
writedata(0x2E);
writedata(0x28);
writedata(0x24);
writedata(0x03);
writedata(0x00);
writedata(0x01);
writecommand(0x36); // MADCTL Memory access control
writedata(0x48);
delay(20);
writecommand(0x21); //Display inversion on
delay(20);
writecommand(0x29); // Display on
delay(120);
// End of HX8357C display configuration

View file

@ -0,0 +1,47 @@
// This is the command sequence that rotates the HX8357C driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 8;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MX);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata( TFT_MAD_COLOR_ORDER | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
case 4: // Portrait
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 5: // Landscape (Portrait + 90)
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MX);
_width = _init_height;
_height = _init_width;
break;
case 6: // Inverter portrait
writedata( TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 7: // Inverted landscape
writedata(TFT_MAD_COLOR_ORDER | TFT_MAD_MV | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,96 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPar.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
#define HX8357_NOP 0x00
#define HX8357_SWRESET 0x01
#define HX8357_RDDID 0x04
#define HX8357_RDDST 0x09
#define HX8357_RDPOWMODE 0x0A
#define HX8357_RDMADCTL 0x0B
#define HX8357_RDCOLMOD 0x0C
#define HX8357_RDDIM 0x0D
#define HX8357_RDDSDR 0x0F
#define HX8357_SLPIN 0x10
#define HX8357_SLPOUT 0x11
#define HX8357_INVOFF 0x20
#define HX8357_INVON 0x21
#define HX8357_DISPOFF 0x28
#define HX8357_DISPON 0x29
#define HX8357_CASET 0x2A
#define HX8357_PASET 0x2B
#define HX8357_RAMWR 0x2C
#define HX8357_RAMRD 0x2E
#define HX8357_TEON 0x35
#define HX8357_TEARLINE 0x44
#define HX8357_MADCTL 0x36
#define HX8357_COLMOD 0x3A
#define HX8357_SETOSC 0xB0
#define HX8357_SETPWR1 0xB1
#define HX8357_SETRGB 0xB3
#define HX8357D_SETCOM 0xB6
#define HX8357D_SETCYC 0xB4
#define HX8357D_SETC 0xB9
#define HX8357D_SETSTBA 0xC0
#define HX8357_SETPANEL 0xCC
#define HX8357D_SETGAMMA 0xE0

View file

@ -0,0 +1,118 @@
// This is the command sequence that initialises the HX8357D driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure HX8357D display
// setextc
writecommand(HX8357D_SETC);
writedata(0xFF);
writedata(0x83);
writedata(0x57);
delay(300);
// setRGB which also enables SDO
writecommand(HX8357_SETRGB);
writedata(0x80); //enable SDO pin!
// writedata(0x00); //disable SDO pin!
writedata(0x0);
writedata(0x06);
writedata(0x06);
writecommand(HX8357D_SETCOM);
writedata(0x25); // -1.52V
writecommand(HX8357_SETOSC);
writedata(0x68); // Normal mode 70Hz, Idle mode 55 Hz
writecommand(HX8357_SETPANEL); //Set Panel
writedata(0x05); // BGR, Gate direction swapped
writecommand(HX8357_SETPWR1);
writedata(0x00); // Not deep standby
writedata(0x15); //BT
writedata(0x1C); //VSPR
writedata(0x1C); //VSNR
writedata(0x83); //AP
writedata(0xAA); //FS
writecommand(HX8357D_SETSTBA);
writedata(0x50); //OPON normal
writedata(0x50); //OPON idle
writedata(0x01); //STBA
writedata(0x3C); //STBA
writedata(0x1E); //STBA
writedata(0x08); //GEN
writecommand(HX8357D_SETCYC);
writedata(0x02); //NW 0x02
writedata(0x40); //RTN
writedata(0x00); //DIV
writedata(0x2A); //DUM
writedata(0x2A); //DUM
writedata(0x0D); //GDON
writedata(0x78); //GDOFF
writecommand(HX8357D_SETGAMMA);
writedata(0x02);
writedata(0x0A);
writedata(0x11);
writedata(0x1d);
writedata(0x23);
writedata(0x35);
writedata(0x41);
writedata(0x4b);
writedata(0x4b);
writedata(0x42);
writedata(0x3A);
writedata(0x27);
writedata(0x1B);
writedata(0x08);
writedata(0x09);
writedata(0x03);
writedata(0x02);
writedata(0x0A);
writedata(0x11);
writedata(0x1d);
writedata(0x23);
writedata(0x35);
writedata(0x41);
writedata(0x4b);
writedata(0x4b);
writedata(0x42);
writedata(0x3A);
writedata(0x27);
writedata(0x1B);
writedata(0x08);
writedata(0x09);
writedata(0x03);
writedata(0x00);
writedata(0x01);
writecommand(HX8357_COLMOD);
writedata(0x55); // 16 bit
writecommand(HX8357_MADCTL);
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
writecommand(HX8357_TEON); // TE off
writedata(0x00);
writecommand(HX8357_TEARLINE); // tear line
writedata(0x00);
writedata(0x02);
writecommand(HX8357_SLPOUT); //Exit Sleep
delay(150);
writecommand(HX8357_DISPON); // display on
delay(50);
// End of HX8357D display configuration

View file

@ -0,0 +1,26 @@
// This is the command sequence that rotates the HX8357D driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,62 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 128
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 160
#endif
#if (TFT_HEIGHT == 128) && (TFT_WIDTH == 128)
#define CGRAM_OFFSET
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ILI9163_BLACK 0x0000 /* 0, 0, 0 */
#define ILI9163_NAVY 0x000F /* 0, 0, 128 */
#define ILI9163_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ILI9163_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ILI9163_MAROON 0x7800 /* 128, 0, 0 */
#define ILI9163_PURPLE 0x780F /* 128, 0, 128 */
#define ILI9163_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ILI9163_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ILI9163_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ILI9163_BLUE 0x001F /* 0, 0, 255 */
#define ILI9163_GREEN 0x07E0 /* 0, 255, 0 */
#define ILI9163_CYAN 0x07FF /* 0, 255, 255 */
#define ILI9163_RED 0xF800 /* 255, 0, 0 */
#define ILI9163_MAGENTA 0xF81F /* 255, 0, 255 */
#define ILI9163_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ILI9163_WHITE 0xFFFF /* 255, 255, 255 */
#define ILI9163_ORANGE 0xFD20 /* 255, 165, 0 */
#define ILI9163_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ILI9163_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21

View file

@ -0,0 +1,41 @@
// This is the command sequence that initialises the ILI9163 driver
//
// This setup information is in a format accecpted by the commandList() function
// which reduces FLASH space, but on an ESP8266 there is plenty available!
//
// See ILI9341_Setup.h file for an alternative simpler format
{
// Initialization commands for ILI9163 screens
static const uint8_t ILI9163_cmds[] PROGMEM =
{
17, // 17 commands follow
0x01, 0 + TFT_INIT_DELAY, 120, // Software reset
0x11, 0 + TFT_INIT_DELAY, 5, // Exit sleep mode
0x3A, 1, 0x05, // Set pixel format
0x26, 1, 0x04, // Set Gamma curve 3
0xF2, 1, 0x01, // Gamma adjustment enabled
0xE0, 15, 0x3F, 0x25, 0x1C, 0x1E, 0x20, 0x12, 0x2A, 0x90,
0x24, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, // Positive Gamma
0xE1, 15, 0x20, 0x20, 0x20, 0x20, 0x05, 0x00, 0x15,0xA7,
0x3D, 0x18, 0x25, 0x2A, 0x2B, 0x2B, 0x3A, // Negative Gamma
0xB1, 2, 0x08, 0x08, // Frame rate control 1
0xB4, 1, 0x07, // Display inversion
0xC0, 2, 0x0A, 0x02, // Power control 1
0xC1, 1, 0x02, // Power control 2
0xC5, 2, 0x50, 0x5B, // Vcom control 1
0xC7, 1, 0x40, // Vcom offset
0x2A, 4, 0x00, 0x00, 0x00, 0x7F, // Set column address
0x2B, 4 + TFT_INIT_DELAY, 0x00, 0x00, 0x00, 0x9F, 250, // Set page address
0x36, 1, 0xC8, // Set address mode
0x29, 0, // Set display on
};
commandList(ILI9163_cmds);
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
}

View file

@ -0,0 +1,44 @@
// This is the command sequence that rotates the ILI9163 driver coordinate frame
rotation = m % 4;
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
break;
case 1:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
break;
case 2:
writedata(TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 32;
#endif
break;
case 3:
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
#ifdef CGRAM_OFFSET
colstart = 32;
rowstart = 0;
#endif
break;
}

View file

@ -0,0 +1,84 @@
// 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
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x28
#define TFT_CASET 0
#define TFT_PASET 0
#define TFT_CASET1 ILI9225_HORIZONTAL_WINDOW_ADDR2
#define TFT_CASET2 ILI9225_HORIZONTAL_WINDOW_ADDR1
#define TFT_PASET1 ILI9225_VERTICAL_WINDOW_ADDR2
#define TFT_PASET2 ILI9225_VERTICAL_WINDOW_ADDR1
#define TFT_RAM_ADDR1 ILI9225_RAM_ADDR_SET1
#define TFT_RAM_ADDR2 ILI9225_RAM_ADDR_SET2
#define TFT_RAMWR ILI9225_GRAM_DATA_REG
#define TFT_MAD_BGR 0x10
#define TFT_MAD_RGB 0x00
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
// Not used
#define TFT_INVOFF 0x00
#define TFT_INVON 0x00
#define TFT_RAMRD 0x00
#define TFT_IDXRD 0x00
/* ILI9225 Registers */
#define ILI9225_DRIVER_OUTPUT_CTRL 0x01 // Driver Output Control
#define ILI9225_LCD_AC_DRIVING_CTRL 0x02 // LCD AC Driving Control
#define ILI9225_ENTRY_MODE 0x03 // Entry Mode
#define ILI9225_DISP_CTRL1 0x07 // Display Control 1
#define ILI9225_BLANK_PERIOD_CTRL1 0x08 // Blank Period Control
#define ILI9225_FRAME_CYCLE_CTRL 0x0B // Frame Cycle Control
#define ILI9225_INTERFACE_CTRL 0x0C // Interface Control
#define ILI9225_OSC_CTRL 0x0F // Osc Control
#define ILI9225_POWER_CTRL1 0x10 // Power Control 1
#define ILI9225_POWER_CTRL2 0x11 // Power Control 2
#define ILI9225_POWER_CTRL3 0x12 // Power Control 3
#define ILI9225_POWER_CTRL4 0x13 // Power Control 4
#define ILI9225_POWER_CTRL5 0x14 // Power Control 5
#define ILI9225_VCI_RECYCLING 0x15 // VCI Recycling
#define ILI9225_RAM_ADDR_SET1 0x20 // Horizontal GRAM Address Set
#define ILI9225_RAM_ADDR_SET2 0x21 // Vertical GRAM Address Set
#define ILI9225_GRAM_DATA_REG 0x22 // GRAM Data Register
#define ILI9225_GATE_SCAN_CTRL 0x30 // Gate Scan Control Register
#define ILI9225_VERTICAL_SCROLL_CTRL1 0x31 // Vertical Scroll Control 1 Register
#define ILI9225_VERTICAL_SCROLL_CTRL2 0x32 // Vertical Scroll Control 2 Register
#define ILI9225_VERTICAL_SCROLL_CTRL3 0x33 // Vertical Scroll Control 3 Register
#define ILI9225_PARTIAL_DRIVING_POS1 0x34 // Partial Driving Position 1 Register
#define ILI9225_PARTIAL_DRIVING_POS2 0x35 // Partial Driving Position 2 Register
#define ILI9225_HORIZONTAL_WINDOW_ADDR1 0x36 // Horizontal Address Start Position
#define ILI9225_HORIZONTAL_WINDOW_ADDR2 0x37 // Horizontal Address End Position
#define ILI9225_VERTICAL_WINDOW_ADDR1 0x38 // Vertical Address Start Position
#define ILI9225_VERTICAL_WINDOW_ADDR2 0x39 // Vertical Address End Position
#define ILI9225_GAMMA_CTRL1 0x50 // Gamma Control 1
#define ILI9225_GAMMA_CTRL2 0x51 // Gamma Control 2
#define ILI9225_GAMMA_CTRL3 0x52 // Gamma Control 3
#define ILI9225_GAMMA_CTRL4 0x53 // Gamma Control 4
#define ILI9225_GAMMA_CTRL5 0x54 // Gamma Control 5
#define ILI9225_GAMMA_CTRL6 0x55 // Gamma Control 6
#define ILI9225_GAMMA_CTRL7 0x56 // Gamma Control 7
#define ILI9225_GAMMA_CTRL8 0x57 // Gamma Control 8
#define ILI9225_GAMMA_CTRL9 0x58 // Gamma Control 9
#define ILI9225_GAMMA_CTRL10 0x59 // Gamma Control 10
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x00 // Not used unless commandlist invoked

View file

@ -0,0 +1,105 @@
// This is the command sequence that initialises the ILI9225 driver
{
writecommand(ILI9225_POWER_CTRL1);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_POWER_CTRL2);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_POWER_CTRL3);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_POWER_CTRL4);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_POWER_CTRL5);
writedata(0x00);writedata(0x00);
delay(40);
writecommand(ILI9225_POWER_CTRL2);
writedata(0x00);writedata(0x18);
writecommand(ILI9225_POWER_CTRL3);
writedata(0x61);writedata(0x21);
writecommand(ILI9225_POWER_CTRL4);
writedata(0x00);writedata(0x6F);
writecommand(ILI9225_POWER_CTRL5);
writedata(0x49);writedata(0x5F);
writecommand(ILI9225_POWER_CTRL1);
writedata(0x08);writedata(0x00);
delay(10);
writecommand(ILI9225_POWER_CTRL2);
writedata(0x10);writedata(0x3B);
delay(50);
writecommand(ILI9225_LCD_AC_DRIVING_CTRL);
writedata(0x01);writedata(0x00);
writecommand(ILI9225_DISP_CTRL1);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_BLANK_PERIOD_CTRL1);
writedata(0x08);writedata(0x08);
writecommand(ILI9225_FRAME_CYCLE_CTRL);
writedata(0x11);writedata(0x00);
writecommand(ILI9225_INTERFACE_CTRL);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_OSC_CTRL);
writedata(0x0D);writedata(0x01);
writecommand(ILI9225_VCI_RECYCLING);
writedata(0x00);writedata(0x20);
writecommand(ILI9225_RAM_ADDR_SET1);
writedata(0x00);writedata(0x00);
writecommand(ILI9225_RAM_ADDR_SET2);
writedata(0x00);writedata(0x00);
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);
delay(50);
writecommand(ILI9225_DISP_CTRL1);
writedata(0x10);writedata(0x17);
}

View 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_COLOR_ORDER);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_COLOR_ORDER);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_COLOR_ORDER);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_COLOR_ORDER);writedata(0x38);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,141 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#if defined (ILI9341_DRIVER) || defined (ILI9341_2_DRIVER)
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#elif defined (ILI9342_DRIVER)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
#define ILI9341_RED 0xF800 /* 255, 0, 0 */
#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
// All ILI9341 specific commands some are used by init()
#define ILI9341_NOP 0x00
#define ILI9341_SWRESET 0x01
#define ILI9341_RDDID 0x04
#define ILI9341_RDDST 0x09
#define ILI9341_SLPIN 0x10
#define ILI9341_SLPOUT 0x11
#define ILI9341_PTLON 0x12
#define ILI9341_NORON 0x13
#define ILI9341_RDMODE 0x0A
#define ILI9341_RDMADCTL 0x0B
#define ILI9341_RDPIXFMT 0x0C
#define ILI9341_RDIMGFMT 0x0A
#define ILI9341_RDSELFDIAG 0x0F
#define ILI9341_INVOFF 0x20
#define ILI9341_INVON 0x21
#define ILI9341_GAMMASET 0x26
#define ILI9341_DISPOFF 0x28
#define ILI9341_DISPON 0x29
#define ILI9341_CASET 0x2A
#define ILI9341_PASET 0x2B
#define ILI9341_RAMWR 0x2C
#define ILI9341_RAMRD 0x2E
#define ILI9341_PTLAR 0x30
#define ILI9341_VSCRDEF 0x33
#define ILI9341_MADCTL 0x36
#define ILI9341_VSCRSADD 0x37
#define ILI9341_PIXFMT 0x3A
#define ILI9341_WRDISBV 0x51
#define ILI9341_RDDISBV 0x52
#define ILI9341_WRCTRLD 0x53
#define ILI9341_FRMCTR1 0xB1
#define ILI9341_FRMCTR2 0xB2
#define ILI9341_FRMCTR3 0xB3
#define ILI9341_INVCTR 0xB4
#define ILI9341_DFUNCTR 0xB6
#define ILI9341_PWCTR1 0xC0
#define ILI9341_PWCTR2 0xC1
#define ILI9341_PWCTR3 0xC2
#define ILI9341_PWCTR4 0xC3
#define ILI9341_PWCTR5 0xC4
#define ILI9341_VMCTR1 0xC5
#define ILI9341_VMCTR2 0xC7
#define ILI9341_RDID4 0xD3
#define ILI9341_RDINDEX 0xD9
#define ILI9341_RDID1 0xDA
#define ILI9341_RDID2 0xDB
#define ILI9341_RDID3 0xDC
#define ILI9341_RDIDX 0xDD // TBC
#define ILI9341_GMCTRP1 0xE0
#define ILI9341_GMCTRN1 0xE1
#define ILI9341_MADCTL_MY 0x80
#define ILI9341_MADCTL_MX 0x40
#define ILI9341_MADCTL_MV 0x20
#define ILI9341_MADCTL_ML 0x10
#define ILI9341_MADCTL_RGB 0x00
#define ILI9341_MADCTL_BGR 0x08
#define ILI9341_MADCTL_MH 0x04

View file

@ -0,0 +1,248 @@
// This is the command sequence that initialises the ILI9341 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
#if defined (ILI9341_DRIVER) || defined (ILI9342_DRIVER)
{
writecommand(0xEF);
writedata(0x03);
writedata(0x80);
writedata(0x02);
writecommand(0xCF);
writedata(0x00);
writedata(0XC1);
writedata(0X30);
writecommand(0xED);
writedata(0x64);
writedata(0x03);
writedata(0X12);
writedata(0X81);
writecommand(0xE8);
writedata(0x85);
writedata(0x00);
writedata(0x78);
writecommand(0xCB);
writedata(0x39);
writedata(0x2C);
writedata(0x00);
writedata(0x34);
writedata(0x02);
writecommand(0xF7);
writedata(0x20);
writecommand(0xEA);
writedata(0x00);
writedata(0x00);
writecommand(ILI9341_PWCTR1); //Power control
writedata(0x23); //VRH[5:0]
writecommand(ILI9341_PWCTR2); //Power control
writedata(0x10); //SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); //VCM control
writedata(0x3e);
writedata(0x28);
writecommand(ILI9341_VMCTR2); //VCM control2
writedata(0x86); //--
writecommand(ILI9341_MADCTL); // Memory Access Control
#ifdef M5STACK
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); // Rotation 0 (portrait mode)
#else
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); // Rotation 0 (portrait mode)
#endif
writecommand(ILI9341_PIXFMT);
writedata(0x55);
writecommand(ILI9341_FRMCTR1);
writedata(0x00);
writedata(0x13); // 0x18 79Hz, 0x1B default 70Hz, 0x13 100Hz
writecommand(ILI9341_DFUNCTR); // Display Function Control
writedata(0x08);
writedata(0x82);
writedata(0x27);
writecommand(0xF2); // 3Gamma Function Disable
writedata(0x00);
writecommand(ILI9341_GAMMASET); //Gamma curve selected
writedata(0x01);
writecommand(ILI9341_GMCTRP1); //Set Gamma
writedata(0x0F);
writedata(0x31);
writedata(0x2B);
writedata(0x0C);
writedata(0x0E);
writedata(0x08);
writedata(0x4E);
writedata(0xF1);
writedata(0x37);
writedata(0x07);
writedata(0x10);
writedata(0x03);
writedata(0x0E);
writedata(0x09);
writedata(0x00);
writecommand(ILI9341_GMCTRN1); //Set Gamma
writedata(0x00);
writedata(0x0E);
writedata(0x14);
writedata(0x03);
writedata(0x11);
writedata(0x07);
writedata(0x31);
writedata(0xC1);
writedata(0x48);
writedata(0x08);
writedata(0x0F);
writedata(0x0C);
writedata(0x31);
writedata(0x36);
writedata(0x0F);
writecommand(ILI9341_SLPOUT); //Exit Sleep
end_tft_write();
delay(120);
begin_tft_write();
writecommand(ILI9341_DISPON); //Display on
}
#elif defined (ILI9341_2_DRIVER) // Alternative init sequence, see https://github.com/Bodmer/TFT_eSPI/issues/1172
{
writecommand(0xCF);
writedata(0x00);
writedata(0XC1);
writedata(0X30);
writecommand(0xED);
writedata(0x64);
writedata(0x03);
writedata(0X12);
writedata(0X81);
writecommand(0xE8);
writedata(0x85);
writedata(0x00);
writedata(0x78);
writecommand(0xCB);
writedata(0x39);
writedata(0x2C);
writedata(0x00);
writedata(0x34);
writedata(0x02);
writecommand(0xF7);
writedata(0x20);
writecommand(0xEA);
writedata(0x00);
writedata(0x00);
writecommand(ILI9341_PWCTR1); //Power control
writedata(0x10); //VRH[5:0]
writecommand(ILI9341_PWCTR2); //Power control
writedata(0x00); //SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); //VCM control
writedata(0x30);
writedata(0x30);
writecommand(ILI9341_VMCTR2); //VCM control2
writedata(0xB7); //--
writecommand(ILI9341_PIXFMT);
writedata(0x55);
writecommand(0x36); // Memory Access Control
writedata(0x08); // Rotation 0 (portrait mode)
writecommand(ILI9341_FRMCTR1);
writedata(0x00);
writedata(0x1A);
writecommand(ILI9341_DFUNCTR); // Display Function Control
writedata(0x08);
writedata(0x82);
writedata(0x27);
writecommand(0xF2); // 3Gamma Function Disable
writedata(0x00);
writecommand(0x26); //Gamma curve selected
writedata(0x01);
writecommand(0xE0); //Set Gamma
writedata(0x0F);
writedata(0x2A);
writedata(0x28);
writedata(0x08);
writedata(0x0E);
writedata(0x08);
writedata(0x54);
writedata(0xA9);
writedata(0x43);
writedata(0x0A);
writedata(0x0F);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writecommand(0XE1); //Set Gamma
writedata(0x00);
writedata(0x15);
writedata(0x17);
writedata(0x07);
writedata(0x11);
writedata(0x06);
writedata(0x2B);
writedata(0x56);
writedata(0x3C);
writedata(0x05);
writedata(0x10);
writedata(0x0F);
writedata(0x3F);
writedata(0x3F);
writedata(0x0F);
writecommand(0x2B);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3f);
writecommand(0x2A);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0xef);
writecommand(ILI9341_SLPOUT); //Exit Sleep
end_tft_write();
delay(120);
begin_tft_write();
writecommand(ILI9341_DISPON); //Display on
}
#endif

View file

@ -0,0 +1,82 @@
// This is the command sequence that rotates the ILI9341 driver coordinate frame
rotation = m % 8; // Limit the range of values to 0-7
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
#ifdef M5STACK
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_width;
_height = _init_height;
break;
case 1:
#ifdef M5STACK
writedata(TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_height;
_height = _init_width;
break;
case 2:
#ifdef M5STACK
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_width;
_height = _init_height;
break;
case 3:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_height;
_height = _init_width;
break;
// These next rotations are for bottom up BMP drawing
case 4:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_width;
_height = _init_height;
break;
case 5:
#ifdef M5STACK
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_height;
_height = _init_width;
break;
case 6:
#ifdef M5STACK
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_COLOR_ORDER);
#endif
_width = _init_width;
_height = _init_height;
break;
case 7:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
#else
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
#endif
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,42 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,736 @@
// This is the command sequence that initialises the ILI9481 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
#define ILI9481_INIT_1 // Original default
//#define ILI9481_INIT_2 // CPT29
//#define ILI9481_INIT_3 // PVI35
//#define ILI9481_INIT_4 // AUO317
//#define ILI9481_INIT_5 // CMO35 *****
//#define ILI9481_INIT_6 // RGB
//#define ILI9481_INIT_7 // From #1774
//#define ILI9481_INIT_8 // From #1774
/////////////////////////////////////////////////////////////////////////////////////////
#ifdef ILI9481_INIT_1
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x42);
writedata(0x18);
writecommand(0xD1);
writedata(0x00);
writedata(0x07);
writedata(0x10);
writecommand(0xD2);
writedata(0x01);
writedata(0x02);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x32);
writedata(0x36);
writedata(0x45);
writedata(0x06);
writedata(0x16);
writedata(0x37);
writedata(0x75);
writedata(0x77);
writedata(0x54);
writedata(0x0C);
writedata(0x00);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
#elif defined (ILI9481_INIT_2)
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x41);
writedata(0x1D);
writecommand(0xD1);
writedata(0x00);
writedata(0x2B);
writedata(0x1F);
writecommand(0xD2);
writedata(0x01);
writedata(0x11);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x14);
writedata(0x33);
writedata(0x10);
writedata(0x00);
writedata(0x16);
writedata(0x44);
writedata(0x36);
writedata(0x77);
writedata(0x00);
writedata(0x0F);
writedata(0x00);
writecommand(0xB0);
writedata(0x00);
writecommand(0xE4);
writedata(0xA0);
writecommand(0xF0);
writedata(0x01);
writecommand(0xF3);
writedata(0x02);
writedata(0x1A);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
#elif defined (ILI9481_INIT_3)
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x41);
writedata(0x1D);
writecommand(0xD1);
writedata(0x00);
writedata(0x2B);
writedata(0x1F);
writecommand(0xD2);
writedata(0x01);
writedata(0x11);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x14);
writedata(0x33);
writedata(0x10);
writedata(0x00);
writedata(0x16);
writedata(0x44);
writedata(0x36);
writedata(0x77);
writedata(0x00);
writedata(0x0F);
writedata(0x00);
writecommand(0xB0);
writedata(0x00);
writecommand(0xE4);
writedata(0xA0);
writecommand(0xF0);
writedata(0x01);
writecommand(0xF3);
writedata(0x40);
writedata(0x0A);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
#elif defined (ILI9481_INIT_4)
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x40);
writedata(0x1D);
writecommand(0xD1);
writedata(0x00);
writedata(0x18);
writedata(0x13);
writecommand(0xD2);
writedata(0x01);
writedata(0x11);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x44);
writedata(0x06);
writedata(0x44);
writedata(0x0A);
writedata(0x08);
writedata(0x17);
writedata(0x33);
writedata(0x77);
writedata(0x44);
writedata(0x08);
writedata(0x0C);
writecommand(0xB0);
writedata(0x00);
writecommand(0xE4);
writedata(0xA0);
writecommand(0xF0);
writedata(0x01);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
#elif defined (ILI9481_INIT_5)
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x41);
writedata(0x1D);
writecommand(0xD1);
writedata(0x00);
writedata(0x1C);
writedata(0x1F);
writecommand(0xD2);
writedata(0x01);
writedata(0x11);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC6);
writedata(0x83);
writecommand(0xC8);
writedata(0x00);
writedata(0x26);
writedata(0x21);
writedata(0x00);
writedata(0x00);
writedata(0x1F);
writedata(0x65);
writedata(0x23);
writedata(0x77);
writedata(0x00);
writedata(0x0F);
writedata(0x00);
writecommand(0xB0);
writedata(0x00);
writecommand(0xE4);
writedata(0xA0);
writecommand(0xF0);
writedata(0x01);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
#elif defined (ILI9481_INIT_6)
// Configure ILI9481 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x41);
writedata(0x1D);
writecommand(0xD1);
writedata(0x00);
writedata(0x2B);
writedata(0x1F);
writecommand(0xD2);
writedata(0x01);
writedata(0x11);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writedata(0x00);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC6);
writedata(0x80);
writecommand(0xC8);
writedata(0x00);
writedata(0x14);
writedata(0x33);
writedata(0x10);
writedata(0x00);
writedata(0x16);
writedata(0x44);
writedata(0x36);
writedata(0x77);
writedata(0x00);
writedata(0x0F);
writedata(0x00);
writecommand(0xB0);
writedata(0x00);
writecommand(0xE4);
writedata(0xA0);
writecommand(0xF0);
writedata(0x08);
writecommand(0xF3);
writedata(0x40);
writedata(0x0A);
writecommand(0xF6);
writedata(0x84);
writecommand(0xF7);
writedata(0x80);
writecommand(0xB3);
writedata(0x00);
writedata(0x01);
writedata(0x06);
writedata(0x30);
writecommand(0xB4);
writedata(0x00);
writecommand(0x0C);
writedata(0x00);
writedata(0x55);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of ILI9481 display configuration
/////////////////////////////////////////////////////////////////////////////////////////
// From #1774
#elif defined (ILI9481_INIT_7)
///ili9481+cmi3.5ips //效果不好
//************* Start Initial Sequence **********//
writecommand(0x11);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x42);
writedata(0x1B);
writecommand(0xD1);
writedata(0x00);
writedata(0x14);
writedata(0x1B);
writecommand(0xD2);
writedata(0x01);
writedata(0x12);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x01);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x46);
writedata(0x44);
writedata(0x50);
writedata(0x04);
writedata(0x16);
writedata(0x33);
writedata(0x13);
writedata(0x77);
writedata(0x05);
writedata(0x0F);
writedata(0x00);
writecommand(0x36);
writedata(0x0A);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(0x22);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(0x2B);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xE0);
delay(120);
writecommand(0x29);
#elif defined (ILI9481_INIT_8)
//3.5IPS ILI9481+CMI
writecommand(0x01); //Soft_rese
delay(220);
writecommand(0x11);
delay(280);
writecommand(0xd0); //Power_Setting
writedata(0x07);//07 VC[2:0] Sets the ratio factor of Vci to generate the reference voltages Vci1
writedata(0x44);//41 BT[2:0] Sets the Step up factor and output voltage level from the reference voltages Vci1
writedata(0x1E);//1f 17 1C VRH[3:0]: Sets the factor to generate VREG1OUT from VCILVL
delay(220);
writecommand(0xd1); //VCOM Control
writedata(0x00);//00
writedata(0x0C);//1A VCM [6:0] is used to set factor to generate VCOMH voltage from the reference voltage VREG1OUT 15 09
writedata(0x1A);//1F VDV[4:0] is used to set the VCOM alternating amplitude in the range of VREG1OUT x 0.70 to VREG1OUT 1F 18
writecommand(0xC5); //Frame Rate
writedata(0x03); // 03 02
writecommand(0xd2); //Power_Setting for Normal Mode
writedata(0x01); //01
writedata(0x11); //11
writecommand(0xE4); //?
writedata(0xa0);
writecommand(0xf3);
writedata(0x00);
writedata(0x2a);
//1 OK
writecommand(0xc8);
writedata(0x00);
writedata(0x26);
writedata(0x21);
writedata(0x00);
writedata(0x00);
writedata(0x1f);
writedata(0x65);
writedata(0x23);
writedata(0x77);
writedata(0x00);
writedata(0x0f);
writedata(0x00);
//GAMMA SETTING
writecommand(0xC0); //Panel Driving Setting
writedata(0x00); //1//00 REV SM GS
writedata(0x3B); //2//NL[5:0]: Sets the number of lines to drive the LCD at an interval of 8 lines.
writedata(0x00); //3//SCN[6:0]
writedata(0x02); //4//PTV: Sets the Vcom output in non-display area drive period
writedata(0x11); //5//NDL: Sets the source output level in non-display area. PTG: Sets the scan mode in non-display area.
writecommand(0xc6); //Interface Control
writedata(0x83);
//GAMMA SETTING
writecommand(0xf0); //?
writedata(0x01);
writecommand(0xE4);//?
writedata(0xa0);
//////倒装设置 NG
writecommand(0x36);
writedata(0x0A); // 8C:出来两行 CA出来一个点
writecommand(0x3a);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT)
writecommand(TFT_INVON);
#endif
writecommand(0xb4);//Display Mode and Frame Memory Write Mode Setting
writedata(0x02);
writedata(0x00); //?
writedata(0x00);
writedata(0x01);
delay(280);
writecommand(0x2a);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F); //3F
writecommand(0x2b);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDf); //DF
//writecommand(0x21);
writecommand(0x29);
writecommand(0x2c);
#endif

View file

@ -0,0 +1,27 @@
// This is the command sequence that rotates the ILI9481 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_SS);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_BGR | TFT_MAD_GS);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_SS | TFT_MAD_GS);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
}

View file

@ -0,0 +1,61 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// For Raspberry Pi ILI9486 only with a modified board to add a write strobe:
#if defined (TFT_WR) && defined (RPI_ILI9486_DRIVER)
#define RPI_WRITE_STROBE
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ILI9486_BLACK 0x0000 /* 0, 0, 0 */
#define ILI9486_NAVY 0x000F /* 0, 0, 128 */
#define ILI9486_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ILI9486_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ILI9486_MAROON 0x7800 /* 128, 0, 0 */
#define ILI9486_PURPLE 0x780F /* 128, 0, 128 */
#define ILI9486_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ILI9486_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ILI9486_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ILI9486_BLUE 0x001F /* 0, 0, 255 */
#define ILI9486_GREEN 0x07E0 /* 0, 255, 0 */
#define ILI9486_CYAN 0x07FF /* 0, 255, 255 */
#define ILI9486_RED 0xF800 /* 255, 0, 0 */
#define ILI9486_MAGENTA 0xF81F /* 255, 0, 255 */
#define ILI9486_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ILI9486_WHITE 0xFFFF /* 255, 255, 255 */
#define ILI9486_ORANGE 0xFD20 /* 255, 165, 0 */
#define ILI9486_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ILI9486_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21

View file

@ -0,0 +1,78 @@
// This is the command sequence that initialises the ILI9486 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
{
// From https://github.com/notro/fbtft/blob/master/fb_ili9486.c
writecommand(0x01); // SW reset
delay(120);
writecommand(0x11); // Sleep out, also SW reset
delay(120);
writecommand(0x3A);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour interface
#else
writedata(0x66); // 18 bit colour interface
#endif
writecommand(0xC2);
writedata(0x44);
writecommand(0xC5);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0x00);
writecommand(0xE0);
writedata(0x0F);
writedata(0x1F);
writedata(0x1C);
writedata(0x0C);
writedata(0x0F);
writedata(0x08);
writedata(0x48);
writedata(0x98);
writedata(0x37);
writedata(0x0A);
writedata(0x13);
writedata(0x04);
writedata(0x11);
writedata(0x0D);
writedata(0x00);
writecommand(0xE1);
writedata(0x0F);
writedata(0x32);
writedata(0x2E);
writedata(0x0B);
writedata(0x0D);
writedata(0x05);
writedata(0x47);
writedata(0x75);
writedata(0x37);
writedata(0x06);
writedata(0x10);
writedata(0x03);
writedata(0x24);
writedata(0x20);
writedata(0x00);
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writecommand(TFT_INVOFF);
#else
writecommand(TFT_INVON);
#endif
writecommand(0x36);
writedata(0x48);
writecommand(0x29); // display on
delay(150);
}

View file

@ -0,0 +1,47 @@
// This is the command sequence that rotates the ILI9486 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 8;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata( TFT_MAD_BGR | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
case 4: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY);
_width = _init_width;
_height = _init_height;
break;
case 5: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX);
_width = _init_height;
_height = _init_width;
break;
case 6: // Inverter portrait
writedata( TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 7: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,42 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,99 @@
// This is the command sequence that initialises the ILI9488 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure ILI9488 display
writecommand(0xE0); // Positive Gamma Control
writedata(0x00);
writedata(0x03);
writedata(0x09);
writedata(0x08);
writedata(0x16);
writedata(0x0A);
writedata(0x3F);
writedata(0x78);
writedata(0x4C);
writedata(0x09);
writedata(0x0A);
writedata(0x08);
writedata(0x16);
writedata(0x1A);
writedata(0x0F);
writecommand(0XE1); // Negative Gamma Control
writedata(0x00);
writedata(0x16);
writedata(0x19);
writedata(0x03);
writedata(0x0F);
writedata(0x05);
writedata(0x32);
writedata(0x45);
writedata(0x46);
writedata(0x04);
writedata(0x0E);
writedata(0x0D);
writedata(0x35);
writedata(0x37);
writedata(0x0F);
writecommand(0XC0); // Power Control 1
writedata(0x17);
writedata(0x15);
writecommand(0xC1); // Power Control 2
writedata(0x41);
writecommand(0xC5); // VCOM Control
writedata(0x00);
writedata(0x12);
writedata(0x80);
writecommand(TFT_MADCTL); // Memory Access Control
writedata(0x48); // MX, BGR
writecommand(0x3A); // Pixel Interface Format
#if defined (TFT_PARALLEL_8_BIT) || defined (TFT_PARALLEL_16_BIT) || defined (RPI_DISPLAY_TYPE)
writedata(0x55); // 16 bit colour for parallel
#else
writedata(0x66); // 18 bit colour for SPI
#endif
writecommand(0xB0); // Interface Mode Control
writedata(0x00);
writecommand(0xB1); // Frame Rate Control
writedata(0xA0);
writecommand(0xB4); // Display Inversion Control
writedata(0x02);
writecommand(0xB6); // Display Function Control
writedata(0x02);
writedata(0x02);
writedata(0x3B);
writecommand(0xB7); // Entry Mode Set
writedata(0xC6);
writecommand(0xF7); // Adjust Control 3
writedata(0xA9);
writedata(0x51);
writedata(0x2C);
writedata(0x82);
writecommand(TFT_SLPOUT); //Exit Sleep
delay(120);
writecommand(TFT_DISPON); //Display on
delay(25);
// End of ILI9488 display configuration

View file

@ -0,0 +1,27 @@
// This is the command sequence that rotates the ILI9488 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_MX | TFT_MAD_BGR);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
}

View file

@ -0,0 +1,42 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,80 @@
// This is the command sequence that initialises the R61581 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure R61581 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xB0);
writedata(0x00);
writecommand(0xD0);
writedata(0x07);
writedata(0x42);
writedata(0x18);
writecommand(0xD1);
writedata(0x00);
writedata(0x07);
writedata(0x10);
writecommand(0xD2);
writedata(0x01);
writedata(0x02);
writecommand(0xC0);
writedata(0x12);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x32);
writedata(0x36);
writedata(0x45);
writedata(0x06);
writedata(0x16);
writedata(0x37);
writedata(0x75);
writedata(0x77);
writedata(0x54);
writedata(0x0C);
writedata(0x00);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
writedata(0x55);
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of R61581 display configuration

View file

@ -0,0 +1,27 @@
// This is the command sequence that rotates the R61581 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_BGR | TFT_MAD_GS);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_GS);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
}

View file

@ -0,0 +1,47 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
// RM68120_DRIVER
#define TFT_WIDTH 480
#define TFT_HEIGHT 800
//Set driver type common to all TBD initialisation options
#ifndef RM68120_DRIVER
#define RM68120_DRIVER
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x0000
#define TFT_SWRST 0x0100
#define TFT_CASET 0x2A00
#define TFT_PASET 0x2B00
#define TFT_RAMWR 0x2C00
#define TFT_RAMRD 0x2E00
#define TFT_IDXRD 0xDD00 // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x3600
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#define TFT_INVOFF 0x2000
#define TFT_INVON 0x2100

View file

@ -0,0 +1,429 @@
writeRegister(0xF000, 0x55);
writeRegister(0xF001, 0xAA);
writeRegister(0xF002, 0x52);
writeRegister(0xF003, 0x08);
writeRegister(0xF004, 0x01);
//GAMMA SETING RED
writeRegister(0xD100, 0x00);
writeRegister(0xD101, 0x00);
writeRegister(0xD102, 0x1b);
writeRegister(0xD103, 0x44);
writeRegister(0xD104, 0x62);
writeRegister(0xD105, 0x00);
writeRegister(0xD106, 0x7b);
writeRegister(0xD107, 0xa1);
writeRegister(0xD108, 0xc0);
writeRegister(0xD109, 0xee);
writeRegister(0xD10A, 0x55);
writeRegister(0xD10B, 0x10);
writeRegister(0xD10C, 0x2c);
writeRegister(0xD10D, 0x43);
writeRegister(0xD10E, 0x57);
writeRegister(0xD10F, 0x55);
writeRegister(0xD110, 0x68);
writeRegister(0xD111, 0x78);
writeRegister(0xD112, 0x87);
writeRegister(0xD113, 0x94);
writeRegister(0xD114, 0x55);
writeRegister(0xD115, 0xa0);
writeRegister(0xD116, 0xac);
writeRegister(0xD117, 0xb6);
writeRegister(0xD118, 0xc1);
writeRegister(0xD119, 0x55);
writeRegister(0xD11A, 0xcb);
writeRegister(0xD11B, 0xcd);
writeRegister(0xD11C, 0xd6);
writeRegister(0xD11D, 0xdf);
writeRegister(0xD11E, 0x95);
writeRegister(0xD11F, 0xe8);
writeRegister(0xD120, 0xf1);
writeRegister(0xD121, 0xfa);
writeRegister(0xD122, 0x02);
writeRegister(0xD123, 0xaa);
writeRegister(0xD124, 0x0b);
writeRegister(0xD125, 0x13);
writeRegister(0xD126, 0x1d);
writeRegister(0xD127, 0x26);
writeRegister(0xD128, 0xaa);
writeRegister(0xD129, 0x30);
writeRegister(0xD12A, 0x3c);
writeRegister(0xD12B, 0x4A);
writeRegister(0xD12C, 0x63);
writeRegister(0xD12D, 0xea);
writeRegister(0xD12E, 0x79);
writeRegister(0xD12F, 0xa6);
writeRegister(0xD130, 0xd0);
writeRegister(0xD131, 0x20);
writeRegister(0xD132, 0x0f);
writeRegister(0xD133, 0x8e);
writeRegister(0xD134, 0xff);
//GAMMA SETING GREEN
writeRegister(0xD200, 0x00);
writeRegister(0xD201, 0x00);
writeRegister(0xD202, 0x1b);
writeRegister(0xD203, 0x44);
writeRegister(0xD204, 0x62);
writeRegister(0xD205, 0x00);
writeRegister(0xD206, 0x7b);
writeRegister(0xD207, 0xa1);
writeRegister(0xD208, 0xc0);
writeRegister(0xD209, 0xee);
writeRegister(0xD20A, 0x55);
writeRegister(0xD20B, 0x10);
writeRegister(0xD20C, 0x2c);
writeRegister(0xD20D, 0x43);
writeRegister(0xD20E, 0x57);
writeRegister(0xD20F, 0x55);
writeRegister(0xD210, 0x68);
writeRegister(0xD211, 0x78);
writeRegister(0xD212, 0x87);
writeRegister(0xD213, 0x94);
writeRegister(0xD214, 0x55);
writeRegister(0xD215, 0xa0);
writeRegister(0xD216, 0xac);
writeRegister(0xD217, 0xb6);
writeRegister(0xD218, 0xc1);
writeRegister(0xD219, 0x55);
writeRegister(0xD21A, 0xcb);
writeRegister(0xD21B, 0xcd);
writeRegister(0xD21C, 0xd6);
writeRegister(0xD21D, 0xdf);
writeRegister(0xD21E, 0x95);
writeRegister(0xD21F, 0xe8);
writeRegister(0xD220, 0xf1);
writeRegister(0xD221, 0xfa);
writeRegister(0xD222, 0x02);
writeRegister(0xD223, 0xaa);
writeRegister(0xD224, 0x0b);
writeRegister(0xD225, 0x13);
writeRegister(0xD226, 0x1d);
writeRegister(0xD227, 0x26);
writeRegister(0xD228, 0xaa);
writeRegister(0xD229, 0x30);
writeRegister(0xD22A, 0x3c);
writeRegister(0xD22B, 0x4a);
writeRegister(0xD22C, 0x63);
writeRegister(0xD22D, 0xea);
writeRegister(0xD22E, 0x79);
writeRegister(0xD22F, 0xa6);
writeRegister(0xD230, 0xd0);
writeRegister(0xD231, 0x20);
writeRegister(0xD232, 0x0f);
writeRegister(0xD233, 0x8e);
writeRegister(0xD234, 0xff);
//GAMMA SETING BLUE
writeRegister(0xD300, 0x00);
writeRegister(0xD301, 0x00);
writeRegister(0xD302, 0x1b);
writeRegister(0xD303, 0x44);
writeRegister(0xD304, 0x62);
writeRegister(0xD305, 0x00);
writeRegister(0xD306, 0x7b);
writeRegister(0xD307, 0xa1);
writeRegister(0xD308, 0xc0);
writeRegister(0xD309, 0xee);
writeRegister(0xD30A, 0x55);
writeRegister(0xD30B, 0x10);
writeRegister(0xD30C, 0x2c);
writeRegister(0xD30D, 0x43);
writeRegister(0xD30E, 0x57);
writeRegister(0xD30F, 0x55);
writeRegister(0xD310, 0x68);
writeRegister(0xD311, 0x78);
writeRegister(0xD312, 0x87);
writeRegister(0xD313, 0x94);
writeRegister(0xD314, 0x55);
writeRegister(0xD315, 0xa0);
writeRegister(0xD316, 0xac);
writeRegister(0xD317, 0xb6);
writeRegister(0xD318, 0xc1);
writeRegister(0xD319, 0x55);
writeRegister(0xD31A, 0xcb);
writeRegister(0xD31B, 0xcd);
writeRegister(0xD31C, 0xd6);
writeRegister(0xD31D, 0xdf);
writeRegister(0xD31E, 0x95);
writeRegister(0xD31F, 0xe8);
writeRegister(0xD320, 0xf1);
writeRegister(0xD321, 0xfa);
writeRegister(0xD322, 0x02);
writeRegister(0xD323, 0xaa);
writeRegister(0xD324, 0x0b);
writeRegister(0xD325, 0x13);
writeRegister(0xD326, 0x1d);
writeRegister(0xD327, 0x26);
writeRegister(0xD328, 0xaa);
writeRegister(0xD329, 0x30);
writeRegister(0xD32A, 0x3c);
writeRegister(0xD32B, 0x4A);
writeRegister(0xD32C, 0x63);
writeRegister(0xD32D, 0xea);
writeRegister(0xD32E, 0x79);
writeRegister(0xD32F, 0xa6);
writeRegister(0xD330, 0xd0);
writeRegister(0xD331, 0x20);
writeRegister(0xD332, 0x0f);
writeRegister(0xD333, 0x8e);
writeRegister(0xD334, 0xff);
//GAMMA SETING RED
writeRegister(0xD400, 0x00);
writeRegister(0xD401, 0x00);
writeRegister(0xD402, 0x1b);
writeRegister(0xD403, 0x44);
writeRegister(0xD404, 0x62);
writeRegister(0xD405, 0x00);
writeRegister(0xD406, 0x7b);
writeRegister(0xD407, 0xa1);
writeRegister(0xD408, 0xc0);
writeRegister(0xD409, 0xee);
writeRegister(0xD40A, 0x55);
writeRegister(0xD40B, 0x10);
writeRegister(0xD40C, 0x2c);
writeRegister(0xD40D, 0x43);
writeRegister(0xD40E, 0x57);
writeRegister(0xD40F, 0x55);
writeRegister(0xD410, 0x68);
writeRegister(0xD411, 0x78);
writeRegister(0xD412, 0x87);
writeRegister(0xD413, 0x94);
writeRegister(0xD414, 0x55);
writeRegister(0xD415, 0xa0);
writeRegister(0xD416, 0xac);
writeRegister(0xD417, 0xb6);
writeRegister(0xD418, 0xc1);
writeRegister(0xD419, 0x55);
writeRegister(0xD41A, 0xcb);
writeRegister(0xD41B, 0xcd);
writeRegister(0xD41C, 0xd6);
writeRegister(0xD41D, 0xdf);
writeRegister(0xD41E, 0x95);
writeRegister(0xD41F, 0xe8);
writeRegister(0xD420, 0xf1);
writeRegister(0xD421, 0xfa);
writeRegister(0xD422, 0x02);
writeRegister(0xD423, 0xaa);
writeRegister(0xD424, 0x0b);
writeRegister(0xD425, 0x13);
writeRegister(0xD426, 0x1d);
writeRegister(0xD427, 0x26);
writeRegister(0xD428, 0xaa);
writeRegister(0xD429, 0x30);
writeRegister(0xD42A, 0x3c);
writeRegister(0xD42B, 0x4A);
writeRegister(0xD42C, 0x63);
writeRegister(0xD42D, 0xea);
writeRegister(0xD42E, 0x79);
writeRegister(0xD42F, 0xa6);
writeRegister(0xD430, 0xd0);
writeRegister(0xD431, 0x20);
writeRegister(0xD432, 0x0f);
writeRegister(0xD433, 0x8e);
writeRegister(0xD434, 0xff);
//GAMMA SETING GREEN
writeRegister(0xD500, 0x00);
writeRegister(0xD501, 0x00);
writeRegister(0xD502, 0x1b);
writeRegister(0xD503, 0x44);
writeRegister(0xD504, 0x62);
writeRegister(0xD505, 0x00);
writeRegister(0xD506, 0x7b);
writeRegister(0xD507, 0xa1);
writeRegister(0xD508, 0xc0);
writeRegister(0xD509, 0xee);
writeRegister(0xD50A, 0x55);
writeRegister(0xD50B, 0x10);
writeRegister(0xD50C, 0x2c);
writeRegister(0xD50D, 0x43);
writeRegister(0xD50E, 0x57);
writeRegister(0xD50F, 0x55);
writeRegister(0xD510, 0x68);
writeRegister(0xD511, 0x78);
writeRegister(0xD512, 0x87);
writeRegister(0xD513, 0x94);
writeRegister(0xD514, 0x55);
writeRegister(0xD515, 0xa0);
writeRegister(0xD516, 0xac);
writeRegister(0xD517, 0xb6);
writeRegister(0xD518, 0xc1);
writeRegister(0xD519, 0x55);
writeRegister(0xD51A, 0xcb);
writeRegister(0xD51B, 0xcd);
writeRegister(0xD51C, 0xd6);
writeRegister(0xD51D, 0xdf);
writeRegister(0xD51E, 0x95);
writeRegister(0xD51F, 0xe8);
writeRegister(0xD520, 0xf1);
writeRegister(0xD521, 0xfa);
writeRegister(0xD522, 0x02);
writeRegister(0xD523, 0xaa);
writeRegister(0xD524, 0x0b);
writeRegister(0xD525, 0x13);
writeRegister(0xD526, 0x1d);
writeRegister(0xD527, 0x26);
writeRegister(0xD528, 0xaa);
writeRegister(0xD529, 0x30);
writeRegister(0xD52A, 0x3c);
writeRegister(0xD52B, 0x4a);
writeRegister(0xD52C, 0x63);
writeRegister(0xD52D, 0xea);
writeRegister(0xD52E, 0x79);
writeRegister(0xD52F, 0xa6);
writeRegister(0xD530, 0xd0);
writeRegister(0xD531, 0x20);
writeRegister(0xD532, 0x0f);
writeRegister(0xD533, 0x8e);
writeRegister(0xD534, 0xff);
//GAMMA SETING BLUE
writeRegister(0xD600, 0x00);
writeRegister(0xD601, 0x00);
writeRegister(0xD602, 0x1b);
writeRegister(0xD603, 0x44);
writeRegister(0xD604, 0x62);
writeRegister(0xD605, 0x00);
writeRegister(0xD606, 0x7b);
writeRegister(0xD607, 0xa1);
writeRegister(0xD608, 0xc0);
writeRegister(0xD609, 0xee);
writeRegister(0xD60A, 0x55);
writeRegister(0xD60B, 0x10);
writeRegister(0xD60C, 0x2c);
writeRegister(0xD60D, 0x43);
writeRegister(0xD60E, 0x57);
writeRegister(0xD60F, 0x55);
writeRegister(0xD610, 0x68);
writeRegister(0xD611, 0x78);
writeRegister(0xD612, 0x87);
writeRegister(0xD613, 0x94);
writeRegister(0xD614, 0x55);
writeRegister(0xD615, 0xa0);
writeRegister(0xD616, 0xac);
writeRegister(0xD617, 0xb6);
writeRegister(0xD618, 0xc1);
writeRegister(0xD619, 0x55);
writeRegister(0xD61A, 0xcb);
writeRegister(0xD61B, 0xcd);
writeRegister(0xD61C, 0xd6);
writeRegister(0xD61D, 0xdf);
writeRegister(0xD61E, 0x95);
writeRegister(0xD61F, 0xe8);
writeRegister(0xD620, 0xf1);
writeRegister(0xD621, 0xfa);
writeRegister(0xD622, 0x02);
writeRegister(0xD623, 0xaa);
writeRegister(0xD624, 0x0b);
writeRegister(0xD625, 0x13);
writeRegister(0xD626, 0x1d);
writeRegister(0xD627, 0x26);
writeRegister(0xD628, 0xaa);
writeRegister(0xD629, 0x30);
writeRegister(0xD62A, 0x3c);
writeRegister(0xD62B, 0x4A);
writeRegister(0xD62C, 0x63);
writeRegister(0xD62D, 0xea);
writeRegister(0xD62E, 0x79);
writeRegister(0xD62F, 0xa6);
writeRegister(0xD630, 0xd0);
writeRegister(0xD631, 0x20);
writeRegister(0xD632, 0x0f);
writeRegister(0xD633, 0x8e);
writeRegister(0xD634, 0xff);
//AVDD VOLTAGE SETTING
writeRegister(0xB000, 0x05);
writeRegister(0xB001, 0x05);
writeRegister(0xB002, 0x05);
//AVEE VOLTAGE SETTING
writeRegister(0xB100, 0x05);
writeRegister(0xB101, 0x05);
writeRegister(0xB102, 0x05);
//AVDD Boosting
writeRegister(0xB600, 0x34);
writeRegister(0xB601, 0x34);
writeRegister(0xB603, 0x34);
//AVEE Boosting
writeRegister(0xB700, 0x24);
writeRegister(0xB701, 0x24);
writeRegister(0xB702, 0x24);
//VCL Boosting
writeRegister(0xB800, 0x24);
writeRegister(0xB801, 0x24);
writeRegister(0xB802, 0x24);
//VGLX VOLTAGE SETTING
writeRegister(0xBA00, 0x14);
writeRegister(0xBA01, 0x14);
writeRegister(0xBA02, 0x14);
//VCL Boosting
writeRegister(0xB900, 0x24);
writeRegister(0xB901, 0x24);
writeRegister(0xB902, 0x24);
//Gamma Voltage
writeRegister(0xBc00, 0x00);
writeRegister(0xBc01, 0xa0);//vgmp=5.0
writeRegister(0xBc02, 0x00);
writeRegister(0xBd00, 0x00);
writeRegister(0xBd01, 0xa0);//vgmn=5.0
writeRegister(0xBd02, 0x00);
//VCOM Setting
writeRegister(0xBe01, 0x3d);//3
//ENABLE PAGE 0
writeRegister(0xF000, 0x55);
writeRegister(0xF001, 0xAA);
writeRegister(0xF002, 0x52);
writeRegister(0xF003, 0x08);
writeRegister(0xF004, 0x00);
//Vivid Color Function Control
writeRegister(0xB400, 0x10);
//Z-INVERSION
writeRegister(0xBC00, 0x05);
writeRegister(0xBC01, 0x05);
writeRegister(0xBC02, 0x05);
//*************** add on 20111021**********************//
writeRegister(0xB700, 0x22);//GATE EQ CONTROL
writeRegister(0xB701, 0x22);//GATE EQ CONTROL
writeRegister(0xC80B, 0x2A);//DISPLAY TIMING CONTROL
writeRegister(0xC80C, 0x2A);//DISPLAY TIMING CONTROL
writeRegister(0xC80F, 0x2A);//DISPLAY TIMING CONTROL
writeRegister(0xC810, 0x2A);//DISPLAY TIMING CONTROL
//*************** add on 20111021**********************//
//PWM_ENH_OE =1
writeRegister(0xd000, 0x01);
//DM_SEL =1
writeRegister(0xb300, 0x10);
//VBPDA=07h
writeRegister(0xBd02, 0x07);
//VBPDb=07h
writeRegister(0xBe02, 0x07);
//VBPDc=07h
writeRegister(0xBf02, 0x07);
//ENABLE PAGE 2
writeRegister(0xF000, 0x55);
writeRegister(0xF001, 0xAA);
writeRegister(0xF002, 0x52);
writeRegister(0xF003, 0x08);
writeRegister(0xF004, 0x02);
//SDREG0 =0
writeRegister(0xc301, 0xa9);
//DS=14
writeRegister(0xfe01, 0x94);
//OSC =60h
writeRegister(0xf600, 0x60);
//TE ON
writeRegister(0x3500, 0x00);
//SLEEP OUT
writecommand(0x1100);
delay(100);
//DISPLY ON
writecommand(0x2900);
delay(100);
writeRegister(0x3A00, 0x55);
writeRegister(0x3600, 0xA3);

View file

@ -0,0 +1,29 @@
// This is the command sequence that rotates the RM68120 driver coordinate frame
rotation = m % 4; // Limit the range of values to 0-3
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1:
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,42 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read

View file

@ -0,0 +1,77 @@
// This is the command sequence that initialises the RM68140 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
// Configure RM68140 display
writecommand(TFT_SLPOUT);
delay(20);
writecommand(0xD0);
writedata(0x07);
writedata(0x42);
writedata(0x18);
writecommand(0xD1);
writedata(0x00);
writedata(0x07);
writedata(0x10);
writecommand(0xD2);
writedata(0x01);
writedata(0x02);
writecommand(0xC0);
writedata(0x10);
writedata(0x3B);
writedata(0x00);
writedata(0x02);
writedata(0x11);
writecommand(0xC5);
writedata(0x03);
writecommand(0xC8);
writedata(0x00);
writedata(0x32);
writedata(0x36);
writedata(0x45);
writedata(0x06);
writedata(0x16);
writedata(0x37);
writedata(0x75);
writedata(0x77);
writedata(0x54);
writedata(0x0C);
writedata(0x00);
writecommand(TFT_MADCTL);
writedata(0x0A);
writecommand(0x3A);
writedata(0x55);
writecommand(TFT_CASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F);
writecommand(TFT_PASET);
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0xDF);
delay(120);
writecommand(TFT_DISPON);
delay(25);
// End of RM68140 display configuration

View file

@ -0,0 +1,44 @@
// This is the command sequence that rotates the RM68140 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR);
writecommand(0xB6);
writedata(0);
writedata(0x22);
writedata(0x3B);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_BGR);
writecommand(0xB6);
writedata(0);
writedata(0x02);
writedata(0x3B);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_BGR);
writecommand(0xB6);
writedata(0);
writedata(0x42);
writedata(0x3B);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MV | TFT_MAD_BGR);
writecommand(0xB6);
writedata(0);
writedata(0x62);
writedata(0x3B);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
}

View file

@ -0,0 +1,55 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 128
#define TFT_HEIGHT 160
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define S6D02A1_BLACK 0x0000 /* 0, 0, 0 */
#define S6D02A1_NAVY 0x000F /* 0, 0, 128 */
#define S6D02A1_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define S6D02A1_DARKCYAN 0x03EF /* 0, 128, 128 */
#define S6D02A1_MAROON 0x7800 /* 128, 0, 0 */
#define S6D02A1_PURPLE 0x780F /* 128, 0, 128 */
#define S6D02A1_OLIVE 0x7BE0 /* 128, 128, 0 */
#define S6D02A1_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define S6D02A1_DARKGREY 0x7BEF /* 128, 128, 128 */
#define S6D02A1_BLUE 0x001F /* 0, 0, 255 */
#define S6D02A1_GREEN 0x07E0 /* 0, 255, 0 */
#define S6D02A1_CYAN 0x07FF /* 0, 255, 255 */
#define S6D02A1_RED 0xF800 /* 255, 0, 0 */
#define S6D02A1_MAGENTA 0xF81F /* 255, 0, 255 */
#define S6D02A1_YELLOW 0xFFE0 /* 255, 255, 0 */
#define S6D02A1_WHITE 0xFFFF /* 255, 255, 255 */
#define S6D02A1_ORANGE 0xFD20 /* 255, 165, 0 */
#define S6D02A1_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define S6D02A1_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21

View file

@ -0,0 +1,47 @@
// This is the command sequence that initialises the S6D02A1 driver
//
// This setup information is in a format accecpted by the commandList() function
// which reduces FLASH space, but on an ESP8266 there is plenty available!
//
// See ILI9341_Setup.h file for an alternative simpler format
{
// Initialization commands for S6D02A1 screens
static const uint8_t S6D02A1_cmds[] PROGMEM =
{
29,
0xf0, 2, 0x5a, 0x5a, // Excommand2
0xfc, 2, 0x5a, 0x5a, // Excommand3
0x26, 1, 0x01, // Gamma set
0xfa, 15, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, // Positive gamma control
0xfb, 15, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, // Negative gamma control
0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, 0x01, 0x00, 0x1f, 0x1f, // Analog parameter control
0xf4, 15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control
0xf5, 13, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, // VCOM control
0xf6, 11, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x01, 0x00, // Source control
0xf2, 17, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, //Display control
0xf8, 1, 0x11, // Gate control
0xf7, 4, 0xc8, 0x20, 0x00, 0x00, // Interface control
0xf3, 2, 0x00, 0x00, // Power sequence control
0x11, TFT_INIT_DELAY, 50, // Wake
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x01, 50, // Power sequence control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x03, 50, // Power sequence control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x07, 50, // Power sequence control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x0f, 50, // Power sequence control
0xf4, 15+TFT_INIT_DELAY, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, 50, // Power control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x1f, 50, // Power sequence control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0x7f, 50, // Power sequence control
0xf3, 2+TFT_INIT_DELAY, 0x00, 0xff, 50, // Power sequence control
0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, 0x01, 0x00, 0x16, 0x16, // Analog parameter control
0xf4, 15, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control
0x36, 1, 0xC8, // Memory access data control
0x35, 1, 0x00, // Tearing effect line on
0x3a, 1+TFT_INIT_DELAY, 0x05, 150, // Interface pixel control
0x29, 0, // Display on
0x2c, 0 // Memory write
};
commandList(S6D02A1_cmds);
}

View file

@ -0,0 +1,28 @@
// This is the command sequence that rotates the S6D02A1 driver coordinate frame
rotation = m % 4;
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 1:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
case 2:
writedata(TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 3:
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,20 @@
#ifndef TFT_WIDTH
#define TFT_WIDTH 128
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 128
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST TFT_NOP
#define TFT_CASET 0x15 // SETCOLUMN
#define TFT_PASET 0x75 // SETROW
#define TFT_RAMWR 0x5C // WRITERAM
#define TFT_RAMRD 0x5D // READRAM
#define TFT_IDXRD TFT_NOP
#define TFT_INVOFF 0xA6 // NORMALDISPLAY
#define TFT_INVON 0xA7 // INVERTDISPLAY

View file

@ -0,0 +1,35 @@
{
writecommand(0xFD); // COMMANDLOCK
writedata(0x12);
writecommand(0xFD); // COMMANDLOCK
writedata(0xB1);
writecommand(0xAE); // DISPLAYOFF
writecommand(0xB3); // CLOCKDIV
writedata(0xF1);
writecommand(0xCA); // MUXRATIO
writedata(127);
writecommand(0xA2); // DISPLAYOFFSET
writedata(0x00);
writecommand(0xB5); // SETGPIO
writedata(0x00);
writecommand(0xAB); // FUNCTIONSELECT
writedata(0x01);
writecommand(0xB1); // PRECHARGE
writedata(0x32);
writecommand(0xBE); // VCOMH
writedata(0x05);
writecommand(0xA6); // NORMALDISPLAY
writecommand(0xC1); // CONTRASTABC
writedata(0xC8);
writedata(0x80);
writedata(0xC8);
writecommand(0xC7); // CONTRASTMASTER
writedata(0x0F);
writecommand(0xB4); // SETVSL
writedata(0xA0);
writedata(0xB5);
writedata(0x55);
writecommand(0xB6); // PRECHARGE2
writedata(0x01);
writecommand(0xAF); // DISPLAYON
}

View file

@ -0,0 +1,34 @@
// This is the command sequence that rotates the SSD1351 driver coordinate frame
rotation = m % 4; // Limit the range of values to 0-3
uint8_t madctl = 0x64;
switch (rotation) {
case 0:
madctl |= 0x10;
_width = _init_width;
_height = _init_height;
break;
case 1:
madctl |= 0x13;
_width = _init_height;
_height = _init_width;
break;
case 2:
madctl |= 0x02;
_width = _init_width;
_height = _init_height;
break;
case 3:
madctl |= 0x01;
_width = _init_height;
_height = _init_width;
break;
}
writecommand(0xA0); // SETREMAP
writedata(madctl);
writecommand(0xA1); // STARTLINE
writedata(rotation < 2 ? TFT_HEIGHT : 0);

View file

@ -0,0 +1,56 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#if defined (SSD1963_480_DRIVER)
#define TFT_WIDTH 272
#define TFT_HEIGHT 480
#elif defined (SSD1963_800_DRIVER)
#define TFT_WIDTH 480
#define TFT_HEIGHT 800
#elif defined (SSD1963_800ALT_DRIVER)
#define TFT_WIDTH 480
#define TFT_HEIGHT 800
#elif defined (SSD1963_800BD_DRIVER)
#define TFT_WIDTH 480
#define TFT_HEIGHT 800
#endif
//Set driver type common to all initialisation options
#ifndef SSD1963_DRIVER
#define SSD1963_DRIVER
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21

View file

@ -0,0 +1,398 @@
#if defined (SSD1963_480_DRIVER)
writecommand(0xE2); //PLL multiplier, set PLL clock to 120M
writedata(0x23); //N=0x36 for 6.5M, 0x23 for 10M crystal
writedata(0x02);
writedata(0x54);
writecommand(0xE0); // PLL enable
writedata(0x01);
delay(10);
writecommand(0xE0);
writedata(0x03);
delay(10);
writecommand(0x01); // software reset
delay(100);
writecommand(0xE6); //PLL setting for PCLK, depends on resolution
writedata(0x01);
writedata(0x1F);
writedata(0xFF);
writecommand(0xB0); //LCD SPECIFICATION
writedata(0x20);
writedata(0x00);
writedata(0x01); //Set HDP 479
writedata(0xDF);
writedata(0x01); //Set VDP 271
writedata(0x0F);
writedata(0x00);
writecommand(0xB4); //HSYNC
writedata(0x02); //Set HT 531
writedata(0x13);
writedata(0x00); //Set HPS 8
writedata(0x08);
writedata(0x2B); //Set HPW 43
writedata(0x00); //Set LPS 2
writedata(0x02);
writedata(0x00);
writecommand(0xB6); //VSYNC
writedata(0x01); //Set VT 288
writedata(0x20);
writedata(0x00); //Set VPS 4
writedata(0x04);
writedata(0x0c); //Set VPW 12
writedata(0x00); //Set FPS 2
writedata(0x02);
writecommand(0xBA);
writedata(0x0F); //GPIO[3:0] out 1
writecommand(0xB8);
writedata(0x07); //GPIO3=input, GPIO[2:0]=output
writedata(0x01); //GPIO0 normal
writecommand(0x36); //rotation
writedata(0x21 | TFT_MAD_COLOR_ORDER);
writecommand(0xF0); //pixel data interface
writedata(0x00); //8 bit bus
delay(1);
writecommand(0xB8);
writedata(0x0f); //GPIO is controlled by host GPIO[3:0]=output GPIO[0]=1 LCD ON GPIO[0]=1 LCD OFF
writedata(0x01); //GPIO0 normal
writecommand(0xBA);
writedata(0x01); //GPIO[0] out 1 --- LCD display on/off control PIN
writecommand(0x2A);
writedata(0);
writedata(0);
writedata((271 & 0xFF00)>>8);
writedata(271 & 0xFF);
writecommand(0x2B);
writedata(0);
writedata(0);
writedata((479 & 0xFF00)>>8);
writedata(479 & 0xFF);
writecommand(0x2C);
writecommand(0x29); //display on
writecommand(0xBE); //set PWM for B/L
writedata(0x06);
writedata(0xf0);
writedata(0x01);
writedata(0xf0);
writedata(0x00);
writedata(0x00);
writecommand(0xd0);
writedata(0x0d);
writecommand(0x2C);
#elif defined (SSD1963_800_DRIVER)
writecommand(0xE2); //PLL multiplier, set PLL clock to 120M
writedata(0x1E); //N=0x36 for 6.5M, 0x23 for 10M crystal
writedata(0x02);
writedata(0x54);
writecommand(0xE0); // PLL enable
writedata(0x01);
delay(10);
writecommand(0xE0);
writedata(0x03);
delay(10);
writecommand(0x01); // software reset
delay(100);
writecommand(0xE6); //PLL setting for PCLK, depends on resolution
writedata(0x03);
writedata(0xFF);
writedata(0xFF);
writecommand(0xB0); //LCD SPECIFICATION
writedata(0x20);
writedata(0x00);
writedata(0x03); //Set HDP 799
writedata(0x1F);
writedata(0x01); //Set VDP 479
writedata(0xDF);
writedata(0x00);
writecommand(0xB4); //HSYNC
writedata(0x03); //Set HT 928
writedata(0xA0);
writedata(0x00); //Set HPS 46
writedata(0x2E);
writedata(0x30); //Set HPW 48
writedata(0x00); //Set LPS 15
writedata(0x0F);
writedata(0x00);
writecommand(0xB6); //VSYNC
writedata(0x02); //Set VT 525
writedata(0x0D);
writedata(0x00); //Set VPS 16
writedata(0x10);
writedata(0x10); //Set VPW 16
writedata(0x00); //Set FPS 8
writedata(0x08);
writecommand(0xBA);
writedata(0x0F); //GPIO[3:0] out 1
writecommand(0xB8);
writedata(0x07); //GPIO3=input, GPIO[2:0]=output
writedata(0x01); //GPIO0 normal
writecommand(0x36); //rotation
writedata(0x21 | TFT_MAD_COLOR_ORDER);
writecommand(0xF0); //pixel data interface
writedata(0x00); //8 bit bus
delay(1);
writecommand(0xB8);
writedata(0x0f); //GPIO is controlled by host GPIO[3:0]=output GPIO[0]=1 LCD ON GPIO[0]=1 LCD OFF
writedata(0x01); //GPIO0 normal
writecommand(0xBA);
writedata(0x01); //GPIO[0] out 1 --- LCD display on/off control PIN
writecommand(0x2A);
writedata(0);
writedata(0);
writedata((479 & 0xFF00)>>8);
writedata(479 & 0xFF);
writecommand(0x2B);
writedata(0);
writedata(0);
writedata((799 & 0xFF00)>>8);
writedata(799 & 0xFF);
writecommand(0x2C);
writecommand(0x29); //display on
writecommand(0xBE); //set PWM for B/L
writedata(0x06);
writedata(0xf0);
writedata(0x01);
writedata(0xf0);
writedata(0x00);
writedata(0x00);
writecommand(0xd0);
writedata(0x0d);
writecommand(0x2C);
#elif defined (SSD1963_800ALT_DRIVER)
writecommand(0xE2); //PLL multiplier, set PLL clock to 120M
writedata(0x23); //N=0x36 for 6.5M, 0x23 for 10M crystal
writedata(0x02);
writedata(0x04);
writecommand(0xE0); // PLL enable
writedata(0x01);
delay(10);
writecommand(0xE0);
writedata(0x03);
delay(10);
writecommand(0x01); // software reset
delay(100);
writecommand(0xE6); //PLL setting for PCLK, depends on resolution
writedata(0x04);
writedata(0x93);
writedata(0xE0);
writecommand(0xB0); //LCD SPECIFICATION
writedata(0x00); // 0x24
writedata(0x00);
writedata(0x03); //Set HDP 799
writedata(0x1F);
writedata(0x01); //Set VDP 479
writedata(0xDF);
writedata(0x00);
writecommand(0xB4); //HSYNC
writedata(0x03); //Set HT 928
writedata(0xA0);
writedata(0x00); //Set HPS 46
writedata(0x2E);
writedata(0x30); //Set HPW 48
writedata(0x00); //Set LPS 15
writedata(0x0F);
writedata(0x00);
writecommand(0xB6); //VSYNC
writedata(0x02); //Set VT 525
writedata(0x0D);
writedata(0x00); //Set VPS 16
writedata(0x10);
writedata(0x10); //Set VPW 16
writedata(0x00); //Set FPS 8
writedata(0x08);
writecommand(0xBA);
writedata(0x05); //GPIO[3:0] out 1
writecommand(0xB8);
writedata(0x07); //GPIO3=input, GPIO[2:0]=output
writedata(0x01); //GPIO0 normal
writecommand(0x36); //rotation
writedata(0x21 | TFT_MAD_COLOR_ORDER); // -- Set rotation
writecommand(0xF0); //pixel data interface
writedata(0x00); //8 bit bus
delay(10);
writecommand(0x2A);
writedata(0);
writedata(0);
writedata((479 & 0xFF00)>>8);
writedata(479 & 0xFF);
writecommand(0x2B);
writedata(0);
writedata(0);
writedata((799 & 0xFF00)>>8);
writedata(799 & 0xFF);
writecommand(0x2C);
writecommand(0x29); //display on
writecommand(0xBE); //set PWM for B/L
writedata(0x06);
writedata(0xF0);
writedata(0x01);
writedata(0xF0);
writedata(0x00);
writedata(0x00);
writecommand(0xD0);
writedata(0x0D);
writecommand(0x2C);
#elif defined (SSD1963_800BD_DRIVER) // Copied from Buy Display code
writecommand(0xE2); //PLL multiplier, set PLL clock to 120M
writedata(0x23); //N=0x36 for 6.5M, 0x23 for 10M crystal
writedata(0x02);
writedata(0x54);
writecommand(0xE0); // PLL enable
writedata(0x01);
delay(10);
writecommand(0xE0);
writedata(0x03);
delay(10);
writecommand(0x01); // software reset
delay(100);
writecommand(0xE6); //PLL setting for PCLK, depends on resolution
writedata(0x03);
writedata(0x33);
writedata(0x33);
writecommand(0xB0); //LCD SPECIFICATION
writedata(0x20);
writedata(0x00);
writedata(799 >> 8); //Set HDP 799
writedata(799 & 0xFF);
writedata(479 >> 8); //Set VDP 479
writedata(479 & 0xFF);
writedata(0x00);
writecommand(0xB4); //HSYNC
writedata(0x04); //Set HT
writedata(0x1F);
writedata(0x00); //Set HPS
writedata(0xD2);
writedata(0x00); //Set HPW
writedata(0x00); //Set LPS
writedata(0x00);
writedata(0x00);
writecommand(0xB6); //VSYNC
writedata(0x02); //Set VT
writedata(0x0C);
writedata(0x00); //Set VPS
writedata(0x22);
writedata(0x00); //Set VPW
writedata(0x00); //Set FPS
writedata(0x00);
writecommand(0xB8);
writedata(0x0F); //GPIO3=input, GPIO[2:0]=output
writedata(0x01); //GPIO0 normal
writecommand(0xBA);
writedata(0x01); //GPIO[0] out 1 --- LCD display on/off control PIN
writecommand(0x36); //rotation
writedata(0x21 | TFT_MAD_COLOR_ORDER); //set to rotate
//writecommand(0x003A); //Set the current pixel format for RGB image data
//writedata(0x0050); //16-bit/pixel
writecommand(0xF0); //pixel data interface
writedata(0x00); //000 = 8 bit bus, 011 = 16 bit, 110 = 9 bit
writecommand(0xBC);
writedata(0x40); //contrast value
writedata(0x80); //brightness value
writedata(0x40); //saturation value
writedata(0x01); //Post Processor Enable
delay(10);
writecommand(0x29); //display on
writecommand(0xBE); //set PWM for B/L
writedata(0x06);
writedata(0x80);
writedata(0x01);
writedata(0xF0);
writedata(0x00);
writedata(0x00);
writecommand(0xD0);
writedata(0x0D);
#endif

View file

@ -0,0 +1,29 @@
// This is the command sequence that rotates the SSD1963 driver coordinate frame
rotation = m % 4; // Limit the range of values to 0-3
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
writedata(0x21 | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1:
writedata(0x00 | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2:
writedata(0x22 | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3:
writedata(0x03 | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,176 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 128
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 160
#endif
// Enumerate the different configurations
#define INITR_GREENTAB 0x0
#define INITR_REDTAB 0x1
#define INITR_BLACKTAB 0x2 // Display with no offsets
#define INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of green tab display
#define INITR_GREENTAB3 0x4 // Use if you get random pixels on edge(s) of 128x128 screen
#define INITR_GREENTAB128 0x5 // Use if you only get part of 128x128 screen in rotation 0 & 1
#define INITR_GREENTAB160x80 0x6 // Use if you only get part of 128x128 screen in rotation 0 & 1
#define INITR_REDTAB160x80 0x7 // Added for https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html
#define INITR_ROBOTLCD 0x8
#define INITB 0xB
// Setup the tab color that will be used by the library setRotation() and setup command list
#if defined (ST7735_INITB)
#define TAB_COLOUR INITB
#elif defined (ST7735_GREENTAB)
#define TAB_COLOUR INITR_GREENTAB
#define CGRAM_OFFSET
#elif defined (ST7735_GREENTAB2)
#define TAB_COLOUR INITR_GREENTAB2
#define CGRAM_OFFSET
#elif defined (ST7735_GREENTAB3)
#define TAB_COLOUR INITR_GREENTAB3
#define CGRAM_OFFSET
#elif defined (ST7735_GREENTAB128)
#define TAB_COLOUR INITR_GREENTAB128
#define CGRAM_OFFSET
#elif defined (ST7735_GREENTAB160x80)
#define TAB_COLOUR INITR_GREENTAB160x80
#define CGRAM_OFFSET
#elif defined (ST7735_ROBOTLCD)
#define TAB_COLOUR INITR_ROBOTLCD
#define CGRAM_OFFSET
#elif defined (ST7735_REDTAB160x80)
#define TAB_COLOUR INITR_REDTAB160x80
#define CGRAM_OFFSET
#elif defined (ST7735_REDTAB)
#define TAB_COLOUR INITR_REDTAB
#elif defined (ST7735_BLACKTAB)
#define TAB_COLOUR INITR_BLACKTAB
#else // Make sure it is not undefined
#define TAB_COLOUR INITR_BLACKTAB
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ST7735_BLACK 0x0000 /* 0, 0, 0 */
#define ST7735_NAVY 0x000F /* 0, 0, 128 */
#define ST7735_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ST7735_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ST7735_MAROON 0x7800 /* 128, 0, 0 */
#define ST7735_PURPLE 0x780F /* 128, 0, 128 */
#define ST7735_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ST7735_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ST7735_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ST7735_BLUE 0x001F /* 0, 0, 255 */
#define ST7735_GREEN 0x07E0 /* 0, 255, 0 */
#define ST7735_CYAN 0x07FF /* 0, 255, 255 */
#define ST7735_RED 0xF800 /* 255, 0, 0 */
#define ST7735_MAGENTA 0xF81F /* 255, 0, 255 */
#define ST7735_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ST7735_WHITE 0xFFFF /* 255, 255, 255 */
#define ST7735_ORANGE 0xFD20 /* 255, 165, 0 */
#define ST7735_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ST7735_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifndef TFT_RGB_ORDER
#if defined(ST7735_BLACKTAB) || defined(ST7735_GREENTAB2) || defined(ST7735_INITB)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#endif
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
// ST7735 specific commands used in init
#define ST7735_NOP 0x00
#define ST7735_SWRESET 0x01
#define ST7735_RDDID 0x04
#define ST7735_RDDST 0x09
#define ST7735_SLPIN 0x10
#define ST7735_SLPOUT 0x11
#define ST7735_PTLON 0x12
#define ST7735_NORON 0x13
#define ST7735_INVOFF 0x20
#define ST7735_INVON 0x21
#define ST7735_DISPOFF 0x28
#define ST7735_DISPON 0x29
#define ST7735_CASET 0x2A
#define ST7735_RASET 0x2B // PASET
#define ST7735_RAMWR 0x2C
#define ST7735_RAMRD 0x2E
#define ST7735_PTLAR 0x30
#define ST7735_COLMOD 0x3A
#define ST7735_MADCTL 0x36
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR 0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1 0xC0
#define ST7735_PWCTR2 0xC1
#define ST7735_PWCTR3 0xC2
#define ST7735_PWCTR4 0xC3
#define ST7735_PWCTR5 0xC4
#define ST7735_VMCTR1 0xC5
#define ST7735_RDID1 0xDA
#define ST7735_RDID2 0xDB
#define ST7735_RDID3 0xDC
#define ST7735_RDID4 0xDD
#define ST7735_PWCTR6 0xFC
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1

View file

@ -0,0 +1,218 @@
// This is the command sequence that initialises the ST7735 driver
//
// This setup information is in a format accepted by the commandList() function
// which reduces FLASH space, but on an ESP8266 there is plenty available!
//
// See ILI9341_Setup.h file for an alternative simpler format
{
// Initialization commands for ST7735 screens
static const uint8_t PROGMEM
Bcmd[] = { // Initialization commands for 7735B screens
18, // 18 commands in list:
ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, no args, w/delay
50, // 50 ms delay
ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, no args, w/delay
255, // 255 = 500 ms delay
ST7735_COLMOD , 1+TFT_INIT_DELAY, // 3: Set color mode, 1 arg + delay:
0x05, // 16-bit color
10, // 10 ms delay
ST7735_FRMCTR1, 3+TFT_INIT_DELAY, // 4: Frame rate control, 3 args + delay:
0x00, // fastest refresh
0x06, // 6 lines front porch
0x03, // 3 lines back porch
10, // 10 ms delay
ST7735_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg:
0x40 | TFT_MAD_COLOR_ORDER, // Row addr/col addr, bottom to top refresh
ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay:
0x15, // 1 clk cycle nonoverlap, 2 cycle gate
// rise, 3 cycle osc equalize
0x02, // Fix on VTL
ST7735_INVCTR , 1 , // 7: Display inversion control, 1 arg:
0x0, // Line inversion
ST7735_PWCTR1 , 2+TFT_INIT_DELAY, // 8: Power control, 2 args + delay:
0x02, // GVDD = 4.7V
0x70, // 1.0uA
10, // 10 ms delay
ST7735_PWCTR2 , 1 , // 9: Power control, 1 arg, no delay:
0x05, // VGH = 14.7V, VGL = -7.35V
ST7735_PWCTR3 , 2 , // 10: Power control, 2 args, no delay:
0x01, // Opamp current small
0x02, // Boost frequency
ST7735_VMCTR1 , 2+TFT_INIT_DELAY, // 11: Power control, 2 args + delay:
0x3C, // VCOMH = 4V
0x38, // VCOML = -1.1V
10, // 10 ms delay
ST7735_PWCTR6 , 2 , // 12: Power control, 2 args, no delay:
0x11, 0x15,
ST7735_GMCTRP1,16 , // 13: Magical unicorn dust, 16 args, no delay:
0x09, 0x16, 0x09, 0x20, // (seriously though, not sure what
0x21, 0x1B, 0x13, 0x19, // these config values represent)
0x17, 0x15, 0x1E, 0x2B,
0x04, 0x05, 0x02, 0x0E,
ST7735_GMCTRN1,16+TFT_INIT_DELAY, // 14: Sparkles and rainbows, 16 args + delay:
0x0B, 0x14, 0x08, 0x1E, // (ditto)
0x22, 0x1D, 0x18, 0x1E,
0x1B, 0x1A, 0x24, 0x2B,
0x06, 0x06, 0x02, 0x0F,
10, // 10 ms delay
ST7735_CASET , 4 , // 15: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 2
0x00, 0x81, // XEND = 129
ST7735_RASET , 4 , // 16: Row addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 1
0x00, 0x81, // XEND = 160
ST7735_NORON , TFT_INIT_DELAY, // 17: Normal display on, no args, w/delay
10, // 10 ms delay
ST7735_DISPON , TFT_INIT_DELAY, // 18: Main screen turn on, no args, w/delay
255 }, // 255 = 500 ms delay
Rcmd1[] = { // Init for 7735R, part 1 (red or green tab)
15, // 15 commands in list:
ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, 0 args, w/delay
150, // 150 ms delay
ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, 0 args, w/delay
255, // 500 ms delay
ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args:
0x01, 0x2C, 0x2D, // Dot inversion mode
0x01, 0x2C, 0x2D, // Line inversion mode
ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay:
0x07, // No inversion
ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay:
0xA2,
0x02, // -4.6V
0x84, // AUTO mode
ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay:
0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay:
0x0A, // Opamp current small
0x00, // Boost frequency
ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay:
0x8A, // BCLK/2, Opamp current small & Medium low
0x2A,
ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay:
0x8A, 0xEE,
ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay:
0x0E,
ST7735_INVOFF , 0 , // 13: Don't invert display, no args, no delay
ST7735_MADCTL , 1 , // 14: Memory access control (directions), 1 arg:
0xC0 | TFT_MAD_COLOR_ORDER, // row addr/col addr, bottom to top refresh
ST7735_COLMOD , 1 , // 15: set color mode, 1 arg, no delay:
0x05 }, // 16-bit color
Rcmd2green[] = { // Init for 7735R, part 2 (green tab only)
2, // 2 commands in list:
ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 0
0x00, 0x7F+0x02, // XEND = 127
ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay:
0x00, 0x01, // XSTART = 0
0x00, 0x9F+0x01 }, // XEND = 159
Rcmd2red[] = { // Init for 7735R, part 2 (red tab only)
2, // 2 commands in list:
ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F, // XEND = 127
ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
// Frame control init for RobotLCD, taken from https://github.com/arduino-libraries/TFT, Adafruit_ST7735.cpp l. 263, commit 61b8a7e
Rcmd3RobotLCD[] = {
3,
ST7735_FRMCTR1, 2 , // 1: Frame rate ctrl - normal mode, 2 args
0x0B, 0x14,
ST7735_FRMCTR2, 2 , // 2: Frame rate ctrl - idle mode, 2 args
0x0B, 0x14,
ST7735_FRMCTR3, 4 , // 3: Frame rate ctrl - partial mode, 4 args
0x0B, 0x14,
0x0B, 0x14 },
Rcmd3[] = { // Init for 7735R, part 3 (red or green tab)
4, // 4 commands in list:
ST7735_GMCTRP1, 16 , // 1: 16 args, no delay:
0x02, 0x1c, 0x07, 0x12,
0x37, 0x32, 0x29, 0x2d,
0x29, 0x25, 0x2B, 0x39,
0x00, 0x01, 0x03, 0x10,
ST7735_GMCTRN1, 16 , // 2: 16 args, no delay:
0x03, 0x1d, 0x07, 0x06,
0x2E, 0x2C, 0x29, 0x2D,
0x2E, 0x2E, 0x37, 0x3F,
0x00, 0x00, 0x02, 0x10,
ST7735_NORON , TFT_INIT_DELAY, // 3: Normal display on, no args, w/delay
10, // 10 ms delay
ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay
100 }; // 100 ms delay
if (tabcolor == INITB)
{
commandList(Bcmd);
}
else
{
commandList(Rcmd1);
if (tabcolor == INITR_GREENTAB)
{
commandList(Rcmd2green);
colstart = 2;
rowstart = 1;
}
else if (tabcolor == INITR_GREENTAB2)
{
commandList(Rcmd2green);
writecommand(ST7735_MADCTL);
writedata(0xC0 | TFT_MAD_COLOR_ORDER);
colstart = 2;
rowstart = 1;
}
else if (tabcolor == INITR_GREENTAB3)
{
commandList(Rcmd2green);
colstart = 2;
rowstart = 3;
}
else if (tabcolor == INITR_GREENTAB128)
{
commandList(Rcmd2green);
colstart = 0;
rowstart = 32;
}
else if (tabcolor == INITR_GREENTAB160x80)
{
commandList(Rcmd2green);
writecommand(TFT_INVON);
colstart = 26;
rowstart = 1;
}
else if (tabcolor == INITR_ROBOTLCD)
{
commandList(Rcmd2green);
commandList(Rcmd3RobotLCD);
}
else if (tabcolor == INITR_REDTAB160x80)
{
commandList(Rcmd2green);
colstart = 24;
rowstart = 0;
}
else if (tabcolor == INITR_REDTAB)
{
commandList(Rcmd2red);
}
else if (tabcolor == INITR_BLACKTAB)
{
writecommand(ST7735_MADCTL);
writedata(0xC0 | TFT_MAD_COLOR_ORDER);
}
commandList(Rcmd3);
}
}

View file

@ -0,0 +1,132 @@
// This is the command sequence that rotates the ST7735 driver coordinate frame
rotation = m % 4; // Limit the range of values to 0-3
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
colstart = 2;
rowstart = 3;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
colstart = 0;
rowstart = 32;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
colstart = 26;
rowstart = 1;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
colstart = 24;
rowstart = 0;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
} else {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
}
_width = _init_width;
_height = _init_height;
break;
case 1:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 3;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
colstart = 32;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
colstart = 1;
rowstart = 26;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
colstart = 0;
rowstart = 24;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
} else {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
}
_width = _init_height;
_height = _init_width;
break;
case 2:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_COLOR_ORDER);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_COLOR_ORDER);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_COLOR_ORDER);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_COLOR_ORDER);
colstart = 0;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_COLOR_ORDER);
colstart = 26;
rowstart = 1;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_COLOR_ORDER);
colstart = 24;
rowstart = 0;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
} else {
writedata(TFT_MAD_COLOR_ORDER);
}
_width = _init_width;
_height = _init_height;
break;
case 3:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 0;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 1;
rowstart = 26;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
colstart = 0;
rowstart = 24;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
} else {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
}
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,178 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Adafruit 1.44 TFT support
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 135)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Adafruit 1.69 round corner TFT support
#if (TFT_HEIGHT == 280) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// 1.47" 172x320 Round Rectangle Color IPS TFT Display
#if (TFT_HEIGHT == 320) && (TFT_WIDTH == 172)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
#if (TFT_HEIGHT == 320) && (TFT_WIDTH == 170)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
#if (TFT_HEIGHT == 300) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_NORON 0x13
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_COLMOD 0x3A
// Flags for TFT_MADCTL
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#ifdef CGRAM_OFFSET
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
#define ST_CMD_DELAY 0x80 // special signifier for command lists
#define ST7789_240x240_XSTART 0
#define ST7789_240x240_YSTART 0
// ST7789 specific commands used in init
#define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01
#define ST7789_RDDID 0x04
#define ST7789_RDDST 0x09
#define ST7789_RDDPM 0x0A // Read display power mode
#define ST7789_RDD_MADCTL 0x0B // Read display MADCTL
#define ST7789_RDD_COLMOD 0x0C // Read display pixel format
#define ST7789_RDDIM 0x0D // Read display image mode
#define ST7789_RDDSM 0x0E // Read display signal mode
#define ST7789_RDDSR 0x0F // Read display self-diagnostic result (ST7789V)
#define ST7789_SLPIN 0x10
#define ST7789_SLPOUT 0x11
#define ST7789_PTLON 0x12
#define ST7789_NORON 0x13
#define ST7789_INVOFF 0x20
#define ST7789_INVON 0x21
#define ST7789_GAMSET 0x26 // Gamma set
#define ST7789_DISPOFF 0x28
#define ST7789_DISPON 0x29
#define ST7789_CASET 0x2A
#define ST7789_RASET 0x2B
#define ST7789_RAMWR 0x2C
#define ST7789_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
#define ST7789_RAMRD 0x2E
#define ST7789_PTLAR 0x30
#define ST7789_VSCRDEF 0x33 // Vertical scrolling definition (ST7789V)
#define ST7789_TEOFF 0x34 // Tearing effect line off
#define ST7789_TEON 0x35 // Tearing effect line on
#define ST7789_MADCTL 0x36 // Memory data access control
#define ST7789_IDMOFF 0x38 // Idle mode off
#define ST7789_IDMON 0x39 // Idle mode on
#define ST7789_RAMWRC 0x3C // Memory write continue (ST7789V)
#define ST7789_RAMRDC 0x3E // Memory read continue (ST7789V)
#define ST7789_COLMOD 0x3A
#define ST7789_RAMCTRL 0xB0 // RAM control
#define ST7789_RGBCTRL 0xB1 // RGB control
#define ST7789_PORCTRL 0xB2 // Porch control
#define ST7789_FRCTRL1 0xB3 // Frame rate control
#define ST7789_PARCTRL 0xB5 // Partial mode control
#define ST7789_GCTRL 0xB7 // Gate control
#define ST7789_GTADJ 0xB8 // Gate on timing adjustment
#define ST7789_DGMEN 0xBA // Digital gamma enable
#define ST7789_VCOMS 0xBB // VCOMS setting
#define ST7789_LCMCTRL 0xC0 // LCM control
#define ST7789_IDSET 0xC1 // ID setting
#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable
#define ST7789_VRHS 0xC3 // VRH set
#define ST7789_VDVSET 0xC4 // VDV setting
#define ST7789_VCMOFSET 0xC5 // VCOMS offset set
#define ST7789_FRCTR2 0xC6 // FR Control 2
#define ST7789_CABCCTRL 0xC7 // CABC control
#define ST7789_REGSEL1 0xC8 // Register value section 1
#define ST7789_REGSEL2 0xCA // Register value section 2
#define ST7789_PWMFRSEL 0xCC // PWM frequency selection
#define ST7789_PWCTRL1 0xD0 // Power control 1
#define ST7789_VAPVANEN 0xD2 // Enable VAP/VAN signal output
#define ST7789_CMD2EN 0xDF // Command 2 enable
#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control
#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control
#define ST7789_DGMLUTR 0xE2 // Digital gamma look-up table for red
#define ST7789_DGMLUTB 0xE3 // Digital gamma look-up table for blue
#define ST7789_GATECTRL 0xE4 // Gate control
#define ST7789_SPI2EN 0xE7 // SPI2 enable
#define ST7789_PWCTRL2 0xE8 // Power control 2
#define ST7789_EQCTRL 0xE9 // Equalize time control
#define ST7789_PROMCTRL 0xEC // Program control
#define ST7789_PROMEN 0xFA // Program mode enable
#define ST7789_NVMSET 0xFC // NVM setting
#define ST7789_PROMACT 0xFE // Program action

View file

@ -0,0 +1,22 @@
// This is the command sequence that initialises the ST7789 driver
// Configure ST7789 display
{
static const uint8_t PROGMEM
st7789[] = {
8,
TFT_SLPOUT, TFT_INIT_DELAY, 255,
TFT_COLMOD, 1+TFT_INIT_DELAY, 0x55, 10,
TFT_MADCTL, 1, 0x00,
TFT_CASET, 4, 0x00, 0x00, 0x00, 0xF0,
TFT_PASET, 4, 0x00, 0x00, 0x00, 0xF0,
TFT_INVON, TFT_INIT_DELAY, 10,
TFT_NORON, TFT_INIT_DELAY, 10,
TFT_DISPON, TFT_INIT_DELAY, 255
};
commandList(st7789);
}
// End of ST7789 display configuration

View file

@ -0,0 +1,280 @@
// This is the command sequence that rotates the ST7789 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 52;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 53;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 53;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 80;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 52;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 80;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}
// This is the command sequence that rotates the ST7789 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 52;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 53;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 53;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 80;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 52;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 80;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,175 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Adafruit 1.44 TFT support
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 135)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Adafruit 1.69 round corner TFT support
#if (TFT_HEIGHT == 280) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// 1.47" 172x320 Round Rectangle Color IPS TFT Display
#if (TFT_HEIGHT == 320) && (TFT_WIDTH == 172)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
#if (TFT_HEIGHT == 320) && (TFT_WIDTH == 170)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
#if (TFT_HEIGHT == 300) && (TFT_WIDTH == 240)
#ifndef CGRAM_OFFSET
#define CGRAM_OFFSET
#endif
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_NORON 0x13
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_COLMOD 0x3A
// Flags for TFT_MADCTL
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#ifdef CGRAM_OFFSET
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
// ST7789 specific commands used in init
#define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01
#define ST7789_RDDID 0x04
#define ST7789_RDDST 0x09
#define ST7789_RDDPM 0x0A // Read display power mode
#define ST7789_RDD_MADCTL 0x0B // Read display MADCTL
#define ST7789_RDD_COLMOD 0x0C // Read display pixel format
#define ST7789_RDDIM 0x0D // Read display image mode
#define ST7789_RDDSM 0x0E // Read display signal mode
#define ST7789_RDDSR 0x0F // Read display self-diagnostic result (ST7789V)
#define ST7789_SLPIN 0x10
#define ST7789_SLPOUT 0x11
#define ST7789_PTLON 0x12
#define ST7789_NORON 0x13
#define ST7789_INVOFF 0x20
#define ST7789_INVON 0x21
#define ST7789_GAMSET 0x26 // Gamma set
#define ST7789_DISPOFF 0x28
#define ST7789_DISPON 0x29
#define ST7789_CASET 0x2A
#define ST7789_RASET 0x2B
#define ST7789_RAMWR 0x2C
#define ST7789_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
#define ST7789_RAMRD 0x2E
#define ST7789_PTLAR 0x30
#define ST7789_VSCRDEF 0x33 // Vertical scrolling definition (ST7789V)
#define ST7789_TEOFF 0x34 // Tearing effect line off
#define ST7789_TEON 0x35 // Tearing effect line on
#define ST7789_MADCTL 0x36 // Memory data access control
#define ST7789_VSCRSADD 0x37 // Vertical screoll address
#define ST7789_IDMOFF 0x38 // Idle mode off
#define ST7789_IDMON 0x39 // Idle mode on
#define ST7789_RAMWRC 0x3C // Memory write continue (ST7789V)
#define ST7789_RAMRDC 0x3E // Memory read continue (ST7789V)
#define ST7789_COLMOD 0x3A
#define ST7789_RAMCTRL 0xB0 // RAM control
#define ST7789_RGBCTRL 0xB1 // RGB control
#define ST7789_PORCTRL 0xB2 // Porch control
#define ST7789_FRCTRL1 0xB3 // Frame rate control
#define ST7789_PARCTRL 0xB5 // Partial mode control
#define ST7789_GCTRL 0xB7 // Gate control
#define ST7789_GTADJ 0xB8 // Gate on timing adjustment
#define ST7789_DGMEN 0xBA // Digital gamma enable
#define ST7789_VCOMS 0xBB // VCOMS setting
#define ST7789_LCMCTRL 0xC0 // LCM control
#define ST7789_IDSET 0xC1 // ID setting
#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable
#define ST7789_VRHS 0xC3 // VRH set
#define ST7789_VDVSET 0xC4 // VDV setting
#define ST7789_VCMOFSET 0xC5 // VCOMS offset set
#define ST7789_FRCTR2 0xC6 // FR Control 2
#define ST7789_CABCCTRL 0xC7 // CABC control
#define ST7789_REGSEL1 0xC8 // Register value section 1
#define ST7789_REGSEL2 0xCA // Register value section 2
#define ST7789_PWMFRSEL 0xCC // PWM frequency selection
#define ST7789_PWCTRL1 0xD0 // Power control 1
#define ST7789_VAPVANEN 0xD2 // Enable VAP/VAN signal output
#define ST7789_CMD2EN 0xDF // Command 2 enable
#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control
#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control
#define ST7789_DGMLUTR 0xE2 // Digital gamma look-up table for red
#define ST7789_DGMLUTB 0xE3 // Digital gamma look-up table for blue
#define ST7789_GATECTRL 0xE4 // Gate control
#define ST7789_SPI2EN 0xE7 // SPI2 enable
#define ST7789_PWCTRL2 0xE8 // Power control 2
#define ST7789_EQCTRL 0xE9 // Equalize time control
#define ST7789_PROMCTRL 0xEC // Program control
#define ST7789_PROMEN 0xFA // Program mode enable
#define ST7789_NVMSET 0xFC // NVM setting
#define ST7789_PROMACT 0xFE // Program action

View file

@ -0,0 +1,128 @@
// This is the command sequence that initialises the ST7789 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
{
writecommand(ST7789_SLPOUT); // Sleep out
delay(120);
writecommand(ST7789_NORON); // Normal display mode on
//------------------------------display and color format setting--------------------------------//
writecommand(ST7789_MADCTL);
//writedata(0x00);
writedata(TFT_MAD_COLOR_ORDER);
// JLX240 display datasheet
writecommand(0xB6);
writedata(0x0A);
writedata(0x82);
writecommand(ST7789_RAMCTRL);
writedata(0x00);
writedata(0xE0); // 5 to 6 bit conversion: r0 = r5, b0 = b5
writecommand(ST7789_COLMOD);
writedata(0x55);
delay(10);
//--------------------------------ST7789V Frame rate setting----------------------------------//
writecommand(ST7789_PORCTRL);
writedata(0x0c);
writedata(0x0c);
writedata(0x00);
writedata(0x33);
writedata(0x33);
writecommand(ST7789_GCTRL); // Voltages: VGH / VGL
writedata(0x35);
//---------------------------------ST7789V Power setting--------------------------------------//
writecommand(ST7789_VCOMS);
writedata(0x28); // JLX240 display datasheet
writecommand(ST7789_LCMCTRL);
writedata(0x0C);
writecommand(ST7789_VDVVRHEN);
writedata(0x01);
writedata(0xFF);
writecommand(ST7789_VRHS); // voltage VRHS
writedata(0x10);
writecommand(ST7789_VDVSET);
writedata(0x20);
writecommand(ST7789_FRCTR2);
writedata(0x0f);
writecommand(ST7789_PWCTRL1);
writedata(0xa4);
writedata(0xa1);
//--------------------------------ST7789V gamma setting---------------------------------------//
writecommand(ST7789_PVGAMCTRL);
writedata(0xd0);
writedata(0x00);
writedata(0x02);
writedata(0x07);
writedata(0x0a);
writedata(0x28);
writedata(0x32);
writedata(0x44);
writedata(0x42);
writedata(0x06);
writedata(0x0e);
writedata(0x12);
writedata(0x14);
writedata(0x17);
writecommand(ST7789_NVGAMCTRL);
writedata(0xd0);
writedata(0x00);
writedata(0x02);
writedata(0x07);
writedata(0x0a);
writedata(0x28);
writedata(0x31);
writedata(0x54);
writedata(0x47);
writedata(0x0e);
writedata(0x1c);
writedata(0x17);
writedata(0x1b);
writedata(0x1e);
writecommand(ST7789_INVON);
writecommand(ST7789_CASET); // Column address set
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0xE5); // 239
writecommand(ST7789_RASET); // Row address set
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F); // 319
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
end_tft_write();
delay(120);
begin_tft_write();
writecommand(ST7789_DISPON); //Display on
delay(120);
#ifdef TFT_BL
// Turn on the back-light LED
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_BL, OUTPUT);
#endif
}

View file

@ -0,0 +1,140 @@
// This is the command sequence that rotates the ST7789 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 52;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 53;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 53;
rowstart = 40;
}
else if(_init_height == 280)
{
colstart = 0;
rowstart = 20;
}
else if(_init_width == 172)
{
colstart = 34;
rowstart = 0;
}
else if(_init_width == 170)
{
colstart = 35;
rowstart = 0;
}
else
{
colstart = 0;
rowstart = 80;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
if (_init_width == 135)
{
colstart = 40;
rowstart = 52;
}
else if(_init_height == 280)
{
colstart = 20;
rowstart = 0;
}
else if(_init_width == 172)
{
colstart = 0;
rowstart = 34;
}
else if(_init_width == 170)
{
colstart = 0;
rowstart = 35;
}
else
{
colstart = 80;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -0,0 +1,100 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
// ST7796 specific commands
#define ST7796_NOP 0x00
#define ST7796_SWRESET 0x01
#define ST7796_RDDID 0x04
#define ST7796_RDDST 0x09
#define ST7796_SLPIN 0x10
#define ST7796_SLPOUT 0x11
#define ST7796_PTLON 0x12
#define ST7796_NORON 0x13
#define ST7796_RDMODE 0x0A
#define ST7796_RDMADCTL 0x0B
#define ST7796_RDPIXFMT 0x0C
#define ST7796_RDIMGFMT 0x0A
#define ST7796_RDSELFDIAG 0x0F
#define ST7796_INVOFF 0x20
#define ST7796_INVON 0x21
#define ST7796_DISPOFF 0x28
#define ST7796_DISPON 0x29
#define ST7796_CASET 0x2A
#define ST7796_PASET 0x2B
#define ST7796_RAMWR 0x2C
#define ST7796_RAMRD 0x2E
#define ST7796_PTLAR 0x30
#define ST7796_VSCRDEF 0x33
#define ST7796_MADCTL 0x36
#define ST7796_VSCRSADD 0x37
#define ST7796_PIXFMT 0x3A
#define ST7796_WRDISBV 0x51
#define ST7796_RDDISBV 0x52
#define ST7796_WRCTRLD 0x53
#define ST7796_FRMCTR1 0xB1
#define ST7796_FRMCTR2 0xB2
#define ST7796_FRMCTR3 0xB3
#define ST7796_INVCTR 0xB4
#define ST7796_DFUNCTR 0xB6
#define ST7796_PWCTR1 0xC0
#define ST7796_PWCTR2 0xC1
#define ST7796_PWCTR3 0xC2
#define ST7796_VMCTR1 0xC5
#define ST7796_VMCOFF 0xC6
#define ST7796_RDID4 0xD3
#define ST7796_GMCTRP1 0xE0
#define ST7796_GMCTRN1 0xE1
#define ST7796_MADCTL_MY 0x80
#define ST7796_MADCTL_MX 0x40
#define ST7796_MADCTL_MV 0x20
#define ST7796_MADCTL_ML 0x10
#define ST7796_MADCTL_RGB 0x00
#define ST7796_MADCTL_BGR 0x08
#define ST7796_MADCTL_MH 0x04

View file

@ -0,0 +1,107 @@
// This is the command sequence that initialises the ST7796 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
#define TFT_INIT_DELAY 0
{
delay(120);
writecommand(0x01); //Software reset
delay(120);
writecommand(0x11); //Sleep exit
delay(120);
writecommand(0xF0); //Command Set control
writedata(0xC3); //Enable extension command 2 partI
writecommand(0xF0); //Command Set control
writedata(0x96); //Enable extension command 2 partII
writecommand(0x36); //Memory Data Access Control MX, MY, RGB mode
writedata(0x48); //X-Mirror, Top-Left to right-Buttom, RGB
writecommand(0x3A); //Interface Pixel Format
writedata(0x55); //Control interface color format set to 16
writecommand(0xB4); //Column inversion
writedata(0x01); //1-dot inversion
writecommand(0xB6); //Display Function Control
writedata(0x80); //Bypass
writedata(0x02); //Source Output Scan from S1 to S960, Gate Output scan from G1 to G480, scan cycle=2
writedata(0x3B); //LCD Drive Line=8*(59+1)
writecommand(0xE8); //Display Output Ctrl Adjust
writedata(0x40);
writedata(0x8A);
writedata(0x00);
writedata(0x00);
writedata(0x29); //Source eqaulizing period time= 22.5 us
writedata(0x19); //Timing for "Gate start"=25 (Tclk)
writedata(0xA5); //Timing for "Gate End"=37 (Tclk), Gate driver EQ function ON
writedata(0x33);
writecommand(0xC1); //Power control2
writedata(0x06); //VAP(GVDD)=3.85+( vcom+vcom offset), VAN(GVCL)=-3.85+( vcom+vcom offset)
writecommand(0xC2); //Power control 3
writedata(0xA7); //Source driving current level=low, Gamma driving current level=High
writecommand(0xC5); //VCOM Control
writedata(0x18); //VCOM=0.9
delay(120);
//ST7796 Gamma Sequence
writecommand(0xE0); //Gamma"+"
writedata(0xF0);
writedata(0x09);
writedata(0x0b);
writedata(0x06);
writedata(0x04);
writedata(0x15);
writedata(0x2F);
writedata(0x54);
writedata(0x42);
writedata(0x3C);
writedata(0x17);
writedata(0x14);
writedata(0x18);
writedata(0x1B);
writecommand(0xE1); //Gamma"-"
writedata(0xE0);
writedata(0x09);
writedata(0x0B);
writedata(0x06);
writedata(0x04);
writedata(0x03);
writedata(0x2B);
writedata(0x43);
writedata(0x42);
writedata(0x3B);
writedata(0x16);
writedata(0x14);
writedata(0x17);
writedata(0x1B);
delay(120);
writecommand(0xF0); //Command Set control
writedata(0x3C); //Disable extension command 2 partI
writecommand(0xF0); //Command Set control
writedata(0x69); //Disable extension command 2 partII
end_tft_write();
delay(120);
begin_tft_write();
writecommand(0x29); //Display on
}

View file

@ -0,0 +1,50 @@
// This is the command sequence that rotates the ST7796 driver coordinate frame
rotation = m % 8; // Limit the range of values to 0-7
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1:
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2:
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
// These next rotations are for bottom up BMP drawing
case 4:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 5:
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 6:
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 7:
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}