www.pudn.com > nt35702.rar > nt35702.c, change:2010-11-24,size:6484b


#include <reg51.h> 
#include <stdio.h> 
#include <intrins.h> 
#define uchar unsigned char 
#define uint unsigned  int  
sbit    cs      =P3^5; 
sbit    reset   =P3^4; 
sbit    rs      =P3^3; 
sbit    wr      =P3^1; 
sbit    rd      =P3^0; 
/********************************************************** 
        command write conntron 
***********************************************************/ 
void LCD_CtrlWrite(uchar idx) 
{         
         
 
         rd=1; 
         cs=0; 
		 rs=0; 
		 P1=idx; 
		 wr=0; 
		 wr=1; 
		 cs=1; 
} 
void LCD_DataWrite(uchar dat) 
{  
         rd=1; 
         cs=0; 
		 rs=1; 
		 P1=dat; 
		 wr=0; 
		 wr=1; 
		 cs=1; 
} 
void write_data(uchar dat,uchar dat1) 
{  
         rd=1; 
         cs=0; 
		 rs=1; 
		 P1=dat1; 
		 
         P2=dat; 
         wr=0; 
         wr=1; 
		 cs=1; 
} 
 
void  delayms(uint t) 
{ 
    uint i,j; 
	for(i=0;i<t;i++) 
	  { 
	    for(j=0;j<500;j++) 
		  {;} 
	   } 
} 
void initial() 
{ 
      reset=0; 
	  delayms(10); 
	  reset=1; 
	  delayms(10); 
 LCD_CtrlWrite(0x01);// Software Reset 
    delayms(20); 
 
    LCD_CtrlWrite(0x11);//Sleep Out 
    delayms(120); 
 
    LCD_CtrlWrite(0xc2);//Power Control 3  
    LCD_DataWrite(0x05);//APA2 APA1 APA0   Large 
    LCD_DataWrite(0x00);//Step-up cycle in Booster circuit 1  
                         //Step-up cycle in Booster circuit 2,3 
    LCD_CtrlWrite(0xc3);//Power Control 4  
    LCD_DataWrite(0x05);//APA2 APA1 APA0   Large 
    LCD_DataWrite(0x00);//Step-up cycle in Booster circuit 1  
                         //Step-up cycle in Booster circuit 2,3 
    LCD_CtrlWrite(0xc4);//Power Control 5  
    LCD_DataWrite(0x05);//APA2 APA1 APA0   Large 
    LCD_DataWrite(0x00);//Step-up cycle in Booster circuit 1  
                         //Step-up cycle in Booster circuit 2,3 
    LCD_CtrlWrite(0x3A);  
    LCD_DataWrite(0x55); 
     
    LCD_CtrlWrite(0xD7);  
    LCD_DataWrite(0x40); 
    LCD_DataWrite(0xE0); 
 
    LCD_CtrlWrite(0xFD); 
    LCD_DataWrite(0x06); 
    LCD_DataWrite(0x11); 
 
    LCD_CtrlWrite(0xFA); 
    LCD_DataWrite(0x38); 
    LCD_DataWrite(0x20); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x19); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x19); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x19); 
 
    LCD_CtrlWrite(0xC5);//Set Vcom	 
    LCD_DataWrite(0x16); 
    LCD_DataWrite(0x3D); 
 
    LCD_CtrlWrite(0xC0);//Set GVDD	 
    LCD_DataWrite(0x05); 
 
    LCD_CtrlWrite(0xC7);//Set VCOM-OFFSET	 
    LCD_DataWrite(0xB0);//如果您感觉有flicker请修改此参数选择一个最佳值 
 
    LCD_CtrlWrite(0x56);//Memory data  access control 
    LCD_DataWrite(0xDC);//MY MX MV ML RGB MH 0 0    
 
////顯示偏黑的Gamma////////////////// 
    LCD_CtrlWrite(0xC7);//Set VCOM-OFFSET	 
    LCD_DataWrite(0xB0); 
    LCD_CtrlWrite(0xE0);//E0H Set 
    LCD_DataWrite(0x24); 
    LCD_DataWrite(0x24); 
    LCD_DataWrite(0x24); 
    LCD_DataWrite(0x03); 
    LCD_DataWrite(0x05); 
    LCD_DataWrite(0x0B); 
    LCD_DataWrite(0x37); 
    LCD_DataWrite(0x7B); 
    LCD_DataWrite(0x41); 
    LCD_DataWrite(0x0C); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x25); 
    LCD_DataWrite(0x10); 
    LCD_DataWrite(0x13); 
    LCD_DataWrite(0x32); 
 
    LCD_CtrlWrite(0xE1);//E1H Set 
    LCD_DataWrite(0x0E); 
    LCD_DataWrite(0x2D); 
    LCD_DataWrite(0x30); 
    LCD_DataWrite(0x0c); 
    LCD_DataWrite(0x14); 
    LCD_DataWrite(0x1A); 
    LCD_DataWrite(0x3F); 
    LCD_DataWrite(0x6C); 
    LCD_DataWrite(0x52); 
    LCD_DataWrite(0x14); 
    LCD_DataWrite(0x2A); 
    LCD_DataWrite(0x2C); 
    LCD_DataWrite(0x1C); 
    LCD_DataWrite(0x1C); 
    LCD_DataWrite(0x1C); 
     
//顯示偏白的Gamma/////////////////// 
/*    LCD_CtrlWrite(0xC7);//Set VCOM-OFFSET	 
    LCD_DataWrite(0xB3); 
     
    LCD_CtrlWrite(0xE0);//E0H Set 
    LCD_DataWrite(0x1D); 
    LCD_DataWrite(0x1D); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x00); 
    LCD_DataWrite(0x06); 
    LCD_DataWrite(0x0F); 
    LCD_DataWrite(0x2E); 
    LCD_DataWrite(0x8B); 
    LCD_DataWrite(0x3D); 
    LCD_DataWrite(0x0C); 
    LCD_DataWrite(0x1E); 
    LCD_DataWrite(0x25); 
    LCD_DataWrite(0x0D); 
    LCD_DataWrite(0x0F); 
    LCD_DataWrite(0x16); 
 
    LCD_CtrlWrite(0xE1);//E1H Set 
    LCD_DataWrite(0x20); 
    LCD_DataWrite(0x26); 
    LCD_DataWrite(0x29); 
    LCD_DataWrite(0x09); 
    LCD_DataWrite(0x11); 
    LCD_DataWrite(0x12); 
    LCD_DataWrite(0x3C); 
    LCD_DataWrite(0x58); 
    LCD_DataWrite(0x4A); 
    LCD_DataWrite(0x11); 
    LCD_DataWrite(0x28); 
    LCD_DataWrite(0x2E); 
    LCD_DataWrite(0x18); 
    LCD_DataWrite(0x19); 
    LCD_DataWrite(0x19); 
*/ 
    LCD_CtrlWrite(0x29);//display on 
 
    LCD_CtrlWrite(0x2c);//Memory Write 
 
 
} 
void set_ram() 
{/* 
     LCD_CtrlWrite(0x2a); 
	 LCD_DataWrite(0x00); 
    LCD_DataWrite(0x00); 
	LCD_DataWrite(0x00); 
	 LCD_DataWrite(0xef); 
	LCD_CtrlWrite(0x2b);     //page 
    LCD_DataWrite(0x00); 
    LCD_DataWrite(0x00);	   //02 
     LCD_DataWrite(0x00);   //0~127 
     LCD_DataWrite(0xef); 
	 LCD_CtrlWrite(0x2c); 
*/ 
} 
 
      
void display_rgb(uchar dath,uchar datl) 
{ 
        uint i,j; 
		set_ram(); 
		for(i=0;i<240;i++) 
		  { 
		     for(j=0;j<320;j++) 
			  {   
			      write_data(dath,datl); 
			   } 
           } 
} 
void main() 
{ 
      initial(); 
      while(1) 
       { 
         display_rgb(0x00,0x00); 
         delayms(5); 
         //display_rgb(0xff,0xff); 
         //delayms(500); 
		   
		  display_rgb(0xf8,0x00); 
         delayms(5); 
		 display_rgb(0x07,0xe0); 
         delayms(5); 
		 display_rgb(0x00,0x1f); 
         delayms(5); 
		 display_rgb(0xff,0xff); 
		 //display_bmp(m_map1); 
        } 
} 
/* 
void display_bmp(void) 
{ 
       unsigned int i,j; 
	   unsigned int k=0; 
		set_ram(); 
		for(i=0;i<160;i++) 
		    for(j=0;j<128;j++) 
			  { 
			       write_data1(map1[k++],map1[k++]); 
			   } 
} 
*/		 
/*unsigned char code map1[]= 
} 
0x10,0x61,0x10,0x61,0x10,0x61,0x10,0x61,0x10,0x61,0x10,0x61,0x10,0x62,0x10, 
0x10,0x81,0x10,0xA1,0x10,0xA2,0x10,0xA1,0x10,0xA2,0x10,0xA1,0x10,0xA2,0x18, 
0x18,0xE1,0x18,0xE1,0x21,0x02,0x20,0xE2,0x20,0xE2,0x20,0xC2,0x20,0xE3,0x29, 
0x4A,0x27,0x29,0x23,0x29,0x02,0x28,0xE1,0x29,0x01,0x39,0x62,0x49,0xA2,0x72, 
0xC4,0x6D,0xC4,0x8D,0xCC,0xAD,0xCC,0xCE,0xCC,0x8E,0xC4,0x6D,0xCC,0x8D,0xCC, 
0xCC,0x8E,0xCC,0xAE,0xCC,0xAE,0xCC,0xAE,0xCC,0xAE,0xCC,0xAE,0xCC,0xAE,0xCC, 
0xD5,0x12,0xC4,0xD1,0xC4,0xB1,0xC4,0xD2,0xCD,0x12,0xCD,0x53,0xBD,0x11,0xA4, 
0x9C,0x6B,0x9C,0x6B,0x9C,0x6B,0x9C,0x6B,0x9C,0x6B,0x9C,0x6B,0x9C,0x4B,0x9C, 
} 
*/