Added initialization sequence and support for the GC9A01 lcd driver

This commit is contained in:
Th3maz1ng 2022-12-28 14:00:23 +01:00
parent a19c3a68bf
commit 0cd605e0a4
2 changed files with 67 additions and 22 deletions

View File

@ -29,8 +29,8 @@ static void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes); static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes);
// ST7789初始化 // ST7789初始化
/*const uint8_t st7789_init_seq[] = { const uint8_t st7789_init_seq[] = {
// len , delay, cmd, data ... // len, delay, cmd, data ...
0x01, 0x14, 0x01, // Software reset 0x01, 0x14, 0x01, // Software reset
0x01, 0x0A, 0x11, // Exit sleep mode 0x01, 0x0A, 0x11, // Exit sleep mode
0x02, 0x02, 0x3A, 0x55, // Set colour mode to 16 bit 0x02, 0x02, 0x3A, 0x55, // Set colour mode to 16 bit
@ -41,24 +41,10 @@ static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_
0x01, 0x02, 0x13, // Normal display on, then 10 ms delay 0x01, 0x02, 0x13, // Normal display on, then 10 ms delay
0x01, 0x02, 0x29, // Main screen turn on, then wait 500 ms 0x01, 0x02, 0x29, // Main screen turn on, then wait 500 ms
0 // Terminate list 0 // Terminate list
};*/
const uint8_t st7789_init_seq[] = {
/* len , delay, cmd, data ... */
0x01, // Software reset
0x11, // Exit sleep mode
//0x02, 0x02, 0x3A, 0x05, // Set colour mode to 16 bit
//0x02, 0x0A, 0x36, 0x00, // Set MADCTL: row then column, refresh is bottom to top ????
//0x05, 0x0A, 0x2A, 0x00, 0x00, 0x00, 0xf0, // CASET: column addresses from 0 to 240 (f0)
//0x05, 0x0A, 0x2B, 0x00, 0x00, 0x01, 0x40, // RASET: row addresses from 0 to 240 (f0)
//0x01, 0x0A, 0x21, // Inversion on, then 10 ms delay (supposedly a hack?)
0x13, // Normal display on, then 10 ms delay
0x29, // Main screen turn on, then wait 500 ms
0 // Terminate list
}; };
const uint8_t st7789_init_seq_9_bit[] = { /*const uint8_t st7789_init_seq_9_bit[] = {
/* len , delay, cmd, data ... */ // len, delay, cmd, data ...
0x01, 0x14, 0x01, // Software reset 0x01, 0x14, 0x01, // Software reset
0x01, 0x0A, 0x11, // Exit sleep mode 0x01, 0x0A, 0x11, // Exit sleep mode
//0x02, 0x02, 0x3A, 0x05, // Set colour mode to 16 bit //0x02, 0x02, 0x3A, 0x05, // Set colour mode to 16 bit
@ -69,6 +55,62 @@ const uint8_t st7789_init_seq_9_bit[] = {
0x01, 0x0A, 0x13, // Normal display on, then 10 ms delay 0x01, 0x0A, 0x13, // Normal display on, then 10 ms delay
0x01, 0x0A, 0x29, // Main screen turn on, then wait 500 ms 0x01, 0x0A, 0x29, // Main screen turn on, then wait 500 ms
0 // Terminate list 0 // Terminate list
};*/
const uint8_t gc9a01_init_seq[] = {
// len, delay, cmd, data ...
0x01, 5, 0x01,
0x01, 0, 0xEF,
0x02, 0, 0xEB, 0x14,
0x01, 0, 0xFE,
0x01, 0, 0xEF,
0x02, 0, 0xEB, 0x14,
0x02, 0, 0x84, 0x40,
0x02, 0, 0x85, 0xFF,
0x02, 0, 0x86, 0xFF,
0x02, 0, 0x87, 0xFF,
0x02, 0, 0x88, 0x0A,
0x02, 0, 0x89, 0x21,
0x02, 0, 0x8A, 0x00,
0x02, 0, 0x8B, 0x80,
0x02, 0, 0x8C, 0x01,
0x02, 0, 0x8D, 0x01,
0x02, 0, 0x8E, 0xFF,
0x02, 0, 0x8F, 0xFF,
0x03, 0, 0xB6, 0x00, 0x00,
0x02, 0, 0x36, 0x48,
0x02, 0, 0x3A, 0x55,
0x05, 0, 0x90, 0x08, 0x08, 0x08, 0x08,
0x02, 0, 0xBD, 0x06,
0x02, 0, 0xBC, 0x00,
0x04, 0, 0xFF, 0x60, 0x01, 0x04,
0x02, 0, 0xC3, 0x13,
0x02, 0, 0xC4, 0x13,
0x02, 0, 0xC9, 0x22,
0x02, 0, 0xBE, 0x11,
0x03, 0, 0xE1, 0x10, 0x0E,
0x04, 0, 0xDF, 0x21, 0x0C, 0x02,
0x07, 0, 0xF0, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2A,
0x07, 0, 0xF1, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6F,
0x07, 0, 0xF2, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2A,
0x07, 0, 0xF3, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6F,
0x03, 0, 0xED, 0x1B, 0x0B,
0x02, 0, 0xAE, 0x77,
0x02, 0, 0xCD, 0x63,
0x0A, 0, 0x70, 0x07, 0x07, 0x04, 0x0E, 0x0F, 0x09, 0x07, 0x08, 0x03,
0x02, 0, 0xE8, 0x34,
0x0D, 0, 0x62, 0x18, 0x0D, 0x71, 0xED, 0x70, 0x70, 0x18, 0x0F, 0x71, 0xEF, 0x70, 0x70,
0x0D, 0, 0x63, 0x18, 0x11, 0x71, 0xF1, 0x70, 0x70, 0x18, 0x13, 0x71, 0xF3, 0x70, 0x70,
0x08, 0, 0x64, 0x28, 0x29, 0xF1, 0x01, 0xF1, 0x00, 0x07,
0x0B, 0, 0x66, 0x3C, 0x00, 0xCD, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00,
0x0B, 0, 0x67, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98,
0x08, 0, 0x74, 0x10, 0x85, 0x80, 0x00, 0x00, 0x4E, 0x00,
0x03, 0, 0x98, 0x3E, 0x07,
0x01, 0, 0x35,
0x01, 0, 0x21,
0x01, 5, 0x11, // Exit from sleep
0x01, 0, 0x29, // Display on
0 // Terminate list
}; };
/** /**
@ -80,7 +122,7 @@ const uint8_t st7789_init_seq_9_bit[] = {
*/ */
// ILI9341初始化 // ILI9341初始化
const uint8_t ili9341_init_seq[] = { const uint8_t ili9341_init_seq[] = {
/* len , delay, cmd, data ... */ /* len, delay, cmd, data ... */
0x01, 0x14, 0x01, // Software reset 0x01, 0x14, 0x01, // Software reset
0x04, 0x00, 0xCF, 0x00, 0xD9, 0x30, 0x04, 0x00, 0xCF, 0x00, 0xD9, 0x30,
0x05, 0x00, 0xED, 0x64, 0x03, 0x12, 0x81, 0x05, 0x00, 0xED, 0x64, 0x03, 0x12, 0x81,
@ -112,7 +154,7 @@ const uint8_t ili9341_init_seq[] = {
// ILI9488初始化 // ILI9488初始化
const uint8_t ili9488_init_seq[] = { const uint8_t ili9488_init_seq[] = {
/* len , delay, cmd, data ... */ /* len, delay, cmd, data ... */
0x05, 0x00, 0xF7, 0xA9, 0x51, 0x2C, 0x82, 0x05, 0x00, 0xF7, 0xA9, 0x51, 0x2C, 0x82,
0x03, 0x00, 0xC0, 0x11, 0x09, 0x03, 0x00, 0xC0, 0x11, 0x09,
0x02, 0x00, 0xC1, 0x41, 0x02, 0x00, 0xC1, 0x41,
@ -134,7 +176,7 @@ const uint8_t ili9488_init_seq[] = {
// ST7796S初始化 // ST7796S初始化
const uint8_t ST7796S_init_seq[] = { const uint8_t ST7796S_init_seq[] = {
/* len , delay, cmd, data ... */ /* len, delay, cmd, data ... */
0x02, 0x00, 0xF0, 0xC3, 0x02, 0x00, 0xF0, 0xC3,
0x02, 0x00, 0xF0, 0x96, 0x02, 0x00, 0xF0, 0x96,
0x02, 0x00, 0x36, 0x68, 0x02, 0x00, 0x36, 0x68,
@ -292,6 +334,8 @@ void lcd_init(LCDConfig_t * const LCDConfig)
const u8 *cmd = ili9341_init_seq; const u8 *cmd = ili9341_init_seq;
#elif DISPLAY_CONTROLLER == 1 #elif DISPLAY_CONTROLLER == 1
const u8 *cmd = st7789_init_seq; const u8 *cmd = st7789_init_seq;
#elif DISPLAY_CONTROLLER == 2
const u8 *cmd = gc9a01_init_seq;
#endif #endif
// We send the init sequence to the screen : // We send the init sequence to the screen :

View File

@ -9,7 +9,8 @@
/* Display drive controller */ /* Display drive controller */
#define ILI9341 0 #define ILI9341 0
#define ST7789V 1 #define ST7789V 1
#define DISPLAY_CONTROLLER ILI9341 #define GC9A01 2
#define DISPLAY_CONTROLLER GC9A01
//#define DISPLAY_CONTROLLER ST7789V //#define DISPLAY_CONTROLLER ST7789V
/* Display properties */ /* Display properties */