//*************************************************************** // //***** 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; 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; } /*************************************************/ void initi(void) { res=1; delay(10); res=0; delay(10); res=1; delay(120); //************Start Initial Sequence**************************** write_command(0xC8); //Set EXTC write_data(0xFF); write_data(0x93); write_data(0x42); write_command(0xb6); write_data(0x0a); write_data(0xE0);//SS GS write_command(0x36); //Memory Access Control write_data(0x08); //MY,MX,MV,ML,BGR,MH write_command(0xC0); //Power Control 1 write_data(0x12); //VRH[5:0] write_data(0x12); //VC[3:0] write_command(0xC1); //Power Control 2 write_data(0x04); //02,SAP[2:0],BT[3:0]VGL=12V,VGH=15V write_command(0xC5); //VCOM write_data(0XFD); //C8++ write_command(0xB1); write_data(0x00); write_data(0x1B); write_command(0xB4); write_data(0x02); //*****************GAMMA***************** write_command(0xE0); write_data(0x00);//P01-VP63 write_data(0x05);//P02-VP62 write_data(0x08);//P03-VP61 write_data(0x04);//P04-VP59 write_data(0x13);//P05-VP57 write_data(0x0A);//P06-VP50 write_data(0x34);//P07-VP43 write_data(0x8A);//P08-VP27,36 write_data(0x46);//P09-VP20 write_data(0x07);//P10-VP13 write_data(0x0E);//P11-VP6 write_data(0x0A);//P12-VP4 write_data(0x1B);//P13-VP2 write_data(0x1D);//P14-VP1 write_data(0x0F);//P15-VP0 write_command(0xE1); write_data(0x0C);//P01 write_data(0x05);//P02 write_data(0x08);//P03 write_data(0x04);//P04 write_data(0x13);//P05 write_data(0x0A);//P06 write_data(0x34);//P07 write_data(0x8A);//P08 write_data(0x46);//P09 write_data(0x07);//P10 write_data(0x0E);//P11 write_data(0x0A);//P12 write_data(0x1B);//P13 write_data(0x1D);//P14 write_data(0x0F);//P15 write_command(0x21); //*************RGB interface set************** write_command(0x3A); //Pixel Format Set write_data(0x66); //18BIT write_command(0xB0); //此寄存器很重要,重点设置DEN,DOCLK,HSYNC,VSYNC的极性,与客人的主控有很大的联系,客人请自己行根据IC规格书和主控进行调整. write_data(0xC0);//40,42,60,62,cc。C0客人反映OK,麻点是PCLK的时序没有配合好,如果客人是上升沿的,那么我的为下降沿. write_command(0xf6);//此寄存器设RGB模式或VSYNC模式接口,选择用16或18BIT 数据线. write_data(0x00);//01 write_data(0x00); write_data(0x06);//08 //********Window(窗口/地址)**************** write_command(0x2A); //320 write_data(0x00); write_data(0x00); write_data(0x01); write_data(0x3F); write_command(0x2B); //240 write_data(0x00); write_data(0x00); write_data(0x00); write_data(0xEF); //****************************** write_command(0x11);//Exit Sleep delay(120); 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); } //*****************************************************