//*************************************************************** // //***** 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(1); res=0; delay(10); res=1; delay(120); //************************************************************ write_command(0xb2); write_data(0x0c); write_data(0x0c); write_data(0x00); write_data(0x33); write_data(0x33); write_command(0xb7); write_data(0x35); write_command(0x3A); write_data(0x55); write_command(0x36); write_data(0x00); write_command(0xbb); write_data(0x2A);//VCOM write_command(0xc3); write_data(0x0A);//GVDD write_command(0xc4); write_data(0x20); write_command(0xc6); write_data(0x0f); write_command(0xd0); write_data(0xa4); write_data(0xa2); write_command(0xe0); write_data(0xd0); write_data(0x00); write_data(0x02); write_data(0x07); write_data(0x0a); write_data(0x28); write_data(0x32); write_data(0x44); write_data(0x42); write_data(0x06); write_data(0x0e); write_data(0x12); write_data(0x14); write_data(0x17); write_command(0xe1); write_data(0xd0); write_data(0x00); write_data(0x02); write_data(0x07); write_data(0x0a); write_data(0x28); write_data(0x31); write_data(0x54); write_data(0x47); write_data(0x0e); write_data(0x1c); write_data(0x17); write_data(0x1b); write_data(0x1e); 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); //Exit Sleep delay(120); 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); } //*****************窗口地址例************************************ void LCD_Window_Set(int x0,int y0,int x1,int y1) { LCD_Cmd_wr(0x2a); LCD_para_wr(x0>>8); LCD_para_wr(x0); LCD_para_wr(x1>>8); LCD_para_wr(x1); LCD_Cmd_wr(0x2b); LCD_para_wr(y0>>8); LCD_para_wr(y0); LCD_para_wr(y1>>8); LCD_para_wr(y1); LCD_Cmd_wr(0x2c); }