//*************************************************************** // //***** Focus LCDs ***** //***** LCDs Made Simple ***** //***** www.FocusLCDs.com ***** // //*************************************************************** // ////NOTE:VCC=3.3V //*************************************************** void write_command (unsigned char y) // (uchar y,uchar x) { unsigned char i; cs=0; rs=0; for(i=0;i<8;i++) { scl=0; if (y&0x80) { sdi=1; } else { sdi=0; } scl=1; y=y<<1; } cs=1; } //************************************数据*************************** void write_data(unsigned char w) // (uchar w, uchar v) { unsigned char i; cs=0; rs=1; for(i=0;i<8;i++) { scl=0; if (w&0x80) { sdi=1; } else { sdi=0; } scl=1; w=w<<1; } cs=1; } /*************************************************/ void initi(void) { res=1; delay(1); res=0; delay(10); res=1; delay(120); //--------------------------------ST7789S Frame rate setting----------------------------------// write_command(0x36); write_data(0x00); //--------------------------------ST7789S Frame rate setting----------------------------------// write_command(0xb2); write_data(0x05); write_data(0x05); write_data(0x00); write_data(0x33); write_data(0x33); write_command(0xb7); write_data(0x35); //---------------------------------ST7789S Power setting--------------------------------------// write_command(0xbb); write_data(0x3F);//vcom write_command(0xc0); write_data(0x2C);//17调深浅 write_command(0xc2); write_data(0x01);// write_command(0xc3); write_data(0x0F);// write_command(0xc4); write_data(0x20); write_command(0xc6); write_data(0x11); write_command(0xd0); write_data(0xa4); write_data(0xa1); write_command(0xe8); write_data(0x03); write_command(0xe9); write_data(0x09); write_data(0x09); write_data(0x08); //--------------------------------ST7789S gamma setting---------------------------------------// write_command(0xe0); write_data(0xd0); write_data(0x05); write_data(0x09); write_data(0x09); write_data(0x08); write_data(0x14); write_data(0x28); write_data(0x33); write_data(0x3F); write_data(0x07); write_data(0x13); write_data(0x14); write_data(0x28); write_data(0x30); write_command(0xe1); write_data(0xd0); write_data(0x05); write_data(0x09); write_data(0x09); write_data(0x08); write_data(0x03); write_data(0x24); write_data(0x32); write_data(0x32); write_data(0x3B); write_data(0x38); write_data(0x14); write_data(0x13); write_data(0x28); write_data(0x2F); write_command(0x21); //反显 //*********SET RGB Interfae*************** write_command(0xB0); write_data(0x11); //set RGB interface and DE mode. write_data(0x00); write_data(0x00); write_command(0xB1); write_data(0x40); // set DE mode ; SET Hs,Vs,DE,DOTCLK signal polarity write_data(0x00); write_data(0x00); write_command(0x3a); write_data(0x66); //66-18 RGB ,55-16BIT RGB 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 LCD_Enter_Standby(void) { write_command(0x28);//display off delay(10); write_command(0x10); RGB_OFF(); } void LCD_Exit_Standby (void) { RGB_ON(); elay(100); write_command(0x11);// Exit Sleep/ Standby mode delay(120); write_command(0x29); } //*****************************************************