//*************************************************************** // //***** 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 write_DISPdata(unsigned char data3,data4) { unsigned char a,i,b; cs=0; rs=1; a=data3; for(i=0;i<8;i++) { scl=0; if (a&0x80) { sdi=1; } else { sdi=0; } scl=1; a=a<<1; } cs=1; cs=0; b=data4; for(i=0;i<8;i++) { scl=0; if (b&0x80) { sdi=1; } else { sdi=0; } scl=1; b=b<<1; } cs=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(0x36); //Memory Access Control write_data(0x08); //MY,MX,MV,ML,BGR,MH write_command(0x3A); //Pixel Format Set write_data(0x55); //DPI [2:0],DBI [2:0] write_command(0xC0); //Power Control 1 write_data(0x0C); //VRH[5:0] write_data(0x06); //VC[3:0] write_command(0xC1); //Power Control 2 write_data(0x20); //SAP[2:0],BT[3:0] write_command(0xC5); //VCOM write_data(0XE7); //C8++ write_command(0xB1); write_data(0x00); write_data(0x1B); write_command(0xB4); write_data(0x02); write_command(0xb6); write_data(0x0a); write_data(0xE0);//SS GS //*****************GAMMA***************** write_command(0xE0); write_data(0x00);//P01-VP63 write_data(0x04);//P02-VP62 write_data(0x09);//P03-VP61 write_data(0x05);//P04-VP59 write_data(0x13);//P05-VP57 write_data(0x09);//P06-VP50 write_data(0x35);//P07-VP43 write_data(0x69);//P08-VP27,36 write_data(0x46);//P09-VP20 write_data(0x04);//P10-VP13 write_data(0x0C);//P11-VP6 write_data(0x09);//P12-VP4 write_data(0x15);//P13-VP2 write_data(0x16);//P14-VP1 write_data(0x0F);//P15-VP0 write_command(0xE1); write_data(0x00);//P01 write_data(0x1F);//P02 write_data(0x20);//P03 write_data(0x03);//P04 write_data(0x0F);//P05 write_data(0x05);//P06 write_data(0x38);//P07 write_data(0x55);//P08 write_data(0x4C);//P09 write_data(0x04);//P10 write_data(0x0E);//P11 write_data(0x0B);//P12 write_data(0x37);//P13 write_data(0x37);//P14 write_data(0x0F);//P15 //********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); } void LCD_Exit_Standby (void) { write_command(0x11);// Exit Sleep/ Standby mode delay(120); write_command(0x29); } //*****************************************************