//*************************************************************** // //***** Focus LCDs ***** //***** LCDs Made Simple ***** //***** www.FocusLCDs.com ***** // //*************************************************************** // ////VCI=3.3V, //*********************16BIT********************************* void write_command(unsigned int i) { cs=0; rd=1; rs=0; P2=i>>8; P0=i; rw=0; rw=1; cs=1; } void write_data(unsigned int i) { cs=0; rd=1; rs=1; P2=i>>8; P0=i; rw=0;; rw=1; cs=1; } //********************8BIT**************************************** void write_command(unsigned int i) { cs=0; rd=1; rs=0; P2=i; rw=0; rw=1; cs=1; } void write_data(unsigned int i) { cs=0; rd=1; rs=1; P2=i>>8; P2=i; rw=0;; rw=1; cs=1; } /*************************************************/ void initi(void) { res=1; delay(1); res=0; delay(10); res=1; delay(120); //************************************************ write_command(0x3A); write_data(0x05); write_command(0x36); write_data(0xC0); write_command(0xE4); //Gate Line Control write_data(0x27); write_data(0x00); write_data(0x10); write_command(0xB7); //Gate control write_data(0x75); write_command(0xb8); //Gate On Timing Adjustment write_data(0x2A); write_data(0x2B); write_data(0x09); write_command(0xBB); //VCOMS Setting write_data(0x0D); //VCOMS=0.425V write_command(0x0C); //LCM Control write_data(0x2C); write_command(0xC2); // write_data(0x01); write_command(0xC3); //VRH Set write_data(0x1D); write_command(0xC4); //VDV Set write_data(0x20); write_command(0xc6); write_data(0x07); write_command(0xd0); write_data(0xa4); write_data(0x31); //--------------------------------ST7789S gamma setting---------------------------------------// write_command(0xe0); write_data(0xd0); write_data(0x10); write_data(0x0A); write_data(0x0A); write_data(0x0A); write_data(0x10); write_data(0x26); write_data(0x42); write_data(0x3E); write_data(0x36); write_data(0x13); write_data(0x34); write_data(0x18); write_data(0x1B); write_command(0xe1); write_data(0xd0); write_data(0x10); write_data(0x0A); write_data(0x0A); write_data(0x0A); write_data(0x10); write_data(0x26); write_data(0x42); write_data(0x3E); write_data(0x36); write_data(0x13); write_data(0x34); write_data(0x18); write_data(0x1B); write_command(0xE8); write_data(0x43); write_command(0xE9); write_data(0x08); write_data(0x08); write_data(0x08); write_command(0xB0); write_data(0x00); write_data(0xE0); write_command(0x21); //·´ÏÔ write_command(0x2A); //Frame rate control write_data(0x00); write_data(0x00); write_data(0x00); write_data(0xEF); write_command(0x2B); //Display function control write_data(0x00); write_data(0x00); write_data(0x01); write_data(0x3F); write_command(0x11); delay(120); //Delay 120ms write_command(0x29); //display on write_command(0x2c); } //********************************************************************************************* void EnterSleep (void) { write_command(0x28); delay(20); write_command(0x10); } //********************************************************* void ExitSleep (void) { write_command(0x11); delay(120); write_command(0x29); } //************ST7789¶Áred IDÈçÏ£¨MT6260)******************// kal_bool LCM_ID_check_ST7789S() { kal_uint8 dummy, ST7789S_1, ST7789S_2, ST7789S_3; MAIN_LCD_CtrlWrite(0x04); //LCM ID dummy = MAIN_LCD_DataRead; ST7789S_1 = MAIN_LCD_DataRead; ST7789S_2 = MAIN_LCD_DataRead; ST7789S_3 = MAIN_LCD_DataRead; if ((0x85== ST7789S_2) && (0x52 == ST7789S_3)) { #ifdef __FACTORY_GET_DRIVERS_INF__ LCM_INF="ST7789S ID=8552"; #endif return KAL_TRUE; } else return KAL_FALSE; }