//NOTE:VCC=3.3V,在进入RGB模式前必须要用SPI对屏进行初始化 //**************************************************************** void write_command (unsigned char y) // (uchar y,uchar x) { unsigned char i; csb=0; sclb=0; sdi=0; sclb=1; for(i=0;i<8;i++) { sclb=0; if (y&0x80) { sdi=1; } else { sdi=0; } sclb=1; y=y<<1; } csb=1; } //*************************************************************** void write_data(unsigned char w) // (uchar w, uchar v) { unsigned char i; csb=0; sclb=0; sdi=1; sclb=1; for(i=0;i<8;i++) { sclb=0; if (w&0x80) { sdi=1; } else { sdi=0; } sclb=1; w=w<<1; } csb=1; } /**********************LCD***************************/ void initi(void) { res=1; delay(1); res=0; delay(10); res=1; delay(200); //***************************************************************//LCD SETING write_command(0xFF); // Change to Page 1 CMD write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x01); write_command(0x08); //Output SDA write_data(0x10); write_command(0x20);//set DE/VSYNC mode write_data(0x00); write_command(0x21); //DE = 1 Active write_data(0x01); write_command(0x30);//Resolution setting 480 X 854 write_data(0x01); write_command(0x31); //Inversion setting 2-dot write_data(0x00); write_command(0x40); //BT AVDD,AVDD write_data(0x16); // write_command(0x41); write_data(0x33);//22 write_command(0x42); write_data(0x03); //VGL=DDVDH+VCIP -DDVDL,VGH=2DDVDL-VCIP write_command(0x43); write_data(0x09); //SET VGH clamp level write_command(0x44); write_data(0x06); //SET VGL clamp level write_command(0x50); //VREG1 write_data(0x88); write_command(0x51); //VREG2 write_data(0x88); write_command(0x52); //Flicker MSB write_data(0x00); write_command(0x53); //Flicker LSB write_data(0x49); //VCOM write_command(0x55); // //Flicker write_data(0x49); write_command(0x60); write_data(0x07); write_command(0x61); write_data(0x00); write_command(0x62); write_data(0x07); write_command(0x63); write_data(0x00); //++++++++++++++++++ Gamma Setting ++++++++++++++++++// write_command(0xA0); //Positive Gamma write_data(0x00); write_command(0xA1); // write_data(0x09); write_command(0xA2); // write_data(0x11); write_command(0xA3); // write_data(0x0B); write_command(0xA4); // write_data(0x05); write_command(0xA5); // write_data(0x08); write_command(0xA6); // write_data(0x06); write_command(0xA7); // write_data(0x04); write_command(0xA8); // write_data(0x09); write_command(0xA9); // write_data(0x0C); write_command(0xAA); // write_data(0x15); write_command(0xAB); // write_data(0x08); write_command(0xAC); // write_data(0x0F); write_command(0xAD); // write_data(0x12); write_command(0xAE); // write_data(0x09); write_command(0xAF); // write_data(0x00); ///==============Nagitive write_command(0xC0); //Negative Gamma write_data(0x00); write_command(0xC1); // write_data(0x09); write_command(0xC2); // write_data(0x10); write_command(0xC3); // write_data(0x0C); write_command(0xC4); // write_data(0x05); write_command(0xC5); // write_data(0x08); write_command(0xC6); // write_data(0x06); write_command(0xC7); // write_data(0x04); write_command(0xC8); // write_data(0x08); write_command(0xC9); // write_data(0x0C); write_command(0xCA); // write_data(0x14); write_command(0xCB); // write_data(0x08); write_command(0xCC); // write_data(0x0F); write_command(0xCD); // write_data(0x11); write_command(0xCE); // write_data(0x09); write_command(0xCF); // write_data(0x00); write_command(0xFF); // Change to Page 6 CMD for GIP timing write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x06); write_command(0x00); // write_data(0x20); write_command(0x01); // write_data(0x0A); write_command(0x02); // write_data(0x00); write_command(0x03); // write_data(0x00); write_command(0x04); // write_data(0x01); write_command(0x05); // write_data(0x01); write_command(0x06); // write_data(0x98); write_command(0x07); // write_data(0x06); write_command(0x08); // write_data(0x01); write_command(0x09); // write_data(0x80); write_command(0x0A); // write_data(0x00); write_command(0x0B); // write_data(0x00); write_command(0x0C); // write_data(0x01); write_command(0x0D); // write_data(0x01); write_command(0x0E); // write_data(0x05); write_command(0x0F); // write_data(0x00); write_command(0x10); // write_data(0xF0); write_command(0x11); // write_data(0xF4); write_command(0x12); // write_data(0x01); write_command(0x13); // write_data(0x00); write_command(0x14); // write_data(0x00); write_command(0x15); // write_data(0xC0); write_command(0x16); // write_data(0x08); write_command(0x17); // write_data(0x00); write_command(0x18); // write_data(0x00); write_command(0x19); // write_data(0x00); write_command(0x1A); // write_data(0x00); write_command(0x1B); // write_data(0x00); write_command(0x1C); // write_data(0x00); write_command(0x1D); // write_data(0x00); write_command(0x20); // write_data(0x01); write_command(0x21); // write_data(0x23); write_command(0x22); // write_data(0x45); write_command(0x23); // write_data(0x67); write_command(0x24); // write_data(0x01); write_command(0x25); // write_data(0x23); write_command(0x26); // write_data(0x45); write_command(0x27); // write_data(0x67); write_command(0x30); // write_data(0x11); write_command(0x31); // write_data(0x11); write_command(0x32); // write_data(0x00); write_command(0x33); // write_data(0xEE); write_command(0x34); // write_data(0xFF); write_command(0x35); // write_data(0xBB); write_command(0x36); // write_data(0xAA); write_command(0x37); // write_data(0xDD); write_command(0x38); // write_data(0xCC); write_command(0x39); // write_data(0x66); write_command(0x3A); // write_data(0x77); write_command(0x3B); // write_data(0x22); write_command(0x3C); // write_data(0x22); write_command(0x3D); // write_data(0x22); write_command(0x3E); // write_data(0x22); write_command(0x3F); // write_data(0x22); write_command(0x40); // write_data(0x22); write_command(0xFF);// Change to Page 7 CMD for GIP timing write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x07); write_command(0x17); write_data(0x22); write_command(0x02); write_data(0x77); write_command(0x26); write_data(0xB2); write_command(0xFF); // Change to Page 0 CMD for Normal command write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x00); write_command(0x3A); write_data(0x50); //24BIT write_command(0x11); delay(120); write_command(0x29); delay(25); } //******************************************* void EnterSleep (void) { write_command(0x28); delay(10); write_command(0x10); } //********************************************************* void ExitSleep (void) { write_command(0x11); delay(120); write_command(0x29); }