⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 8051带32Mflash的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "display_h.h"

void lcm_cs(bit flag)
{	if(flag==0)
	{	P40=0;
		P41=0;
		P42=0;
	}
	else
	{	P40=1;
		P41=1;
		P42=1;		
	}
}

/*----------------------------------------------------------------
		Write data sub program	
		SELECT  16BIT/8BIT
-----------------------------------------------------------------*/
#if INTERFACE_16BIT             //16BIT DATA INPUT
	void W_D(uint wdata)
	{
		uchar high,low;
		low=(uchar)wdata;
		high=wdata>>8;
		LCM_RS=1;
		lcm_cs(0);
		OUTPORT_H=high;
		OUTPORT_L=low;
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
		
	}
#elif INTERFACE_8BIT           //8BIT  DATA INPUT 
	void W_D(uint wdata)
	{
		uchar high;
		LCM_RS=1;//==>Data
		lcm_cs(0);
		high=(uchar)(wdata>>8);
		OUTPORT_L=high;//
		LCM_WR=0;
		LCM_WR=1;
		OUTPORT_L=(uchar)wdata;//
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
	
	}
#else 
	#error W_D() DON'T SET INTERFACE
#endif

#if INTERFACE_16BIT             //16BIT DATA INPUT
	void W_D_HL(uchar h,uchar l)
	{
		LCM_RS=1;
		lcm_cs(0);
		OUTPORT_H=h;
		OUTPORT_L=l;
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
		
	}
#elif INTERFACE_8BIT           //8BIT  DATA INPUT 
	void W_D_HL(uchar h,uchar l)
	{
		LCM_RS=1;//==>Data
		lcm_cs(0);
		OUTPORT_L=h;//
		LCM_WR=0;
		LCM_WR=1;
		OUTPORT_L=l;//
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
	
	}
#else 
	#error W_D_HL() DON'T SET INTERFACE
#endif

/*----------------------------------------------------------------
		Write command sub program	
-----------------------------------------------------------------*/
#if INTERFACE_16BIT 
	void W_C(uchar command)     //Write  command to LCM
	{
		LCM_RS=0;//==>Command
		lcm_cs(0);
		OUTPORT_H=0;//
		OUTPORT_L=command;//
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
	
	}
#elif INTERFACE_8BIT 
	void W_C(uchar command)     //Write  command to LCM
	{
		LCM_RS=0;//==>Command
	
		lcm_cs(0);
		OUTPORT_L=0;//
		LCM_WR=0;
		LCM_WR=1;
		OUTPORT_L=command;//
		LCM_WR=0;
		LCM_WR=1;
		lcm_cs(1);
//		LCM_CS=1;
	}
#else 
	#error DON'T SET INTERFACE
#endif
/*----------------------------------------------------------------
		Write command/data sub program	
-----------------------------------------------------------------*/

void CMD(unsigned char a,unsigned int b)
{
	W_C(a);
	W_D(b);
}

/*----------------------------------------------------------------
		LCM init sub program	
-----------------------------------------------------------------*/ 
#if DT1505S
	void LCM_init()
	{
		LCM_RES=0;
		delay10ms(10);
		LCM_RES=1;
		delay10ms(10);
	
		CMD(0x00,0x0000);
	    CMD(0x00,0x0000);
	    CMD(0x00,0x0000);
	    CMD(0x00,0x0000);

		CMD(0xB0,0x0001);
	    CMD(0x00,0x0001);
	    CMD(0x07,0x0000);
	    CMD(0x12,0x0000);

		CMD(0x70,0x2700);
	    CMD(0x08,0x0405);
	   
	
	    CMD(0x30,0x0000);
	    CMD(0x31,0x0105);
	    CMD(0x32,0x0004);
	    CMD(0x33,0x0006);
	    CMD(0x34,0x0105);
	    CMD(0x35,0x0001);
	    CMD(0x36,0x0707);
	    CMD(0x37,0x0704);
	    CMD(0x38,0x0300);
	    CMD(0x39,0x0800);
	    
		CMD(0x15,0x0001);
	    CMD(0x10,0x66B0);
		delay10ms(10);
	    CMD(0x11,0x0257);//4230
	    CMD(0x12,0x0108);
	    CMD(0x12,0x0118);   
		
		CMD(0x13,0xA324);
	    CMD(0x01,0x0100);
		delay10ms(10);
	    CMD(0x02,0x0700);//4230
	    CMD(0x03,0x4030);
	    CMD(0x71,0x0000);   
	
	    CMD(0x90,0x0108);
	    CMD(0x91,0x0000);
	    CMD(0x92,0x0000);  
	    CMD(0x09,0x0000);

	    CMD(0x80,0x0000);
	    CMD(0x81,0x0000);
	    CMD(0x82,0x013F);  
	    CMD(0x83,0x0000);
		delay10ms(50);
	   CMD(0x84,0x0000);
	    CMD(0x85,0x013F);
	    CMD(0x50,0x0000);
	    CMD(0x51,0x00EF);
	    CMD(0x52,0x0000);
		delay10ms(10);
	    CMD(0x53,0x013F);
		
		CMD(0x10,0x76b0);
//	    CMD(0x07,0x0001);
//	    CMD(0x12,0x111a);
//	    CMD(0x07,0x0233);




	}
#elif NT39106
	void LCM_init()
	{
		LCM_RES=0;
		delay10ms(10);
		LCM_RES=1;
		delay10ms(10);		
		CMD(0x12,0x0009);
	    CMD(0x13,0x131e);
	    CMD(0x10,0x0604);
	    CMD(0x11,0x0004);
	
	    CMD(0x10,0x4634);
	    CMD(0x12,0x0018);
		delay10ms(10);
	    CMD(0x10,0x4030);//4230
	    CMD(0x13,0x331e);
	    CMD(0x02,0x0700);   
	
	    CMD(0x01,0x011b);
	    CMD(0x08,0x0202);
	    CMD(0x03,0x1030);  
	    CMD(0x0b,0x5820);
		delay10ms(10);
	    CMD(0x21,0x0000);
	
	    CMD(0x30,0x0303);
	    CMD(0x31,0x0303);
	    CMD(0x32,0x0303);
	    CMD(0x33,0x0303);
	    CMD(0x34,0x0404);
	    CMD(0x35,0x0404);
	    CMD(0x36,0x0404);
	    CMD(0x37,0x0303);
	
	    CMD(0x38,0x0000);
	    CMD(0x39,0x0000);
	    CMD(0x40,0x0000);
		delay10ms(50);
	    CMD(0x41,0x0000);
	    CMD(0x42,0xdb00);
	    CMD(0x43,0x0000);
	    CMD(0x44,0xaf00);
	    CMD(0x45,0xdb00);
		delay10ms(10);
	    CMD(0x07,0x005);
		delay10ms(10);
	    CMD(0x07,0x025);
		delay10ms(10);
	    CMD(0x07,0x27);
		delay10ms(1);
	    CMD(0x07,0x037);

	}
#elif ILI9320
	void LCM_init()
	{
	
		LCM_RES=0;
		delay10ms(50);
		LCM_RES=1;
		delay10ms(50);
		//************* Start Initial Sequence **********//
		CMD(0x2b, 0x0000);
		CMD(0xE5, 0x8000); // Set the Vcore voltage and this setting is must.
		CMD(0x00, 0x0001); // Start internal OSC.
		CMD(0x01, 0x0100); // set SS and SM bit
		CMD(0x02, 0x0700); // set 1 line inversion
		CMD(0x03, 0x1030); // set GRAM write direction and BGR=1.
		CMD(0x04, 0x0000); // Resize register
		CMD(0x08, 0x0202); // set the back porch and front porch
		CMD(0x09, 0x0000); // set non-display area refresh cycle ISC[3:0]
		CMD(0x0A, 0x0000); // FMARK function
		CMD(0x0C, 0x0000); // RGB interface setting
		CMD(0x0D, 0x0000); // Frame marker Position
		CMD(0x0F, 0x0000); // RGB interface polarity
		//*************Power On sequence ****************//
		CMD(0x10, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
		CMD(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
		CMD(0x12, 0x0000); // VREG1OUT voltage
		CMD(0x13, 0x0000); // VDV[4:0] for VCOM amplitude
		delay10ms(10); // Dis-charge capacitor power voltage
		CMD(0x10, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
		CMD(0x11, 0x0007); // R11h=0x0001 at VCI=3.3V DC1[2:0], DC0[2:0], VC[2:0]
		delay10ms(10); // Delay 50ms
		CMD(0x12, 0x013A); // R11h=0x0138 at VCI=3.3V VREG1OUT voltage
		delay10ms(10); // Delay 50ms
		CMD(0x13, 0x1A00); // R11h=0x1800 at VCI=3.3V VDV[4:0] for VCOM amplitude
		CMD(0x29, 0x000C); // R11h=0x0008 at VCI=3.3V VCM[4:0] for VCOMH
		delay10ms(10);
		CMD(0x20, 0x0000); // GRAM horizontal Address
		CMD(0x21, 0x0000); // GRAM Vertical Address
		// ----------- Adjust the Gamma Curve ----------//
		CMD(0x30, 0x0000);
		CMD(0x31, 0x0505);
		CMD(0x32, 0x0004);
		CMD(0x35, 0x0006);
		CMD(0x36, 0x0707);
		CMD(0x37, 0x0105);
		CMD(0x38, 0x0002);
		CMD(0x39, 0x0707);
		CMD(0x3C, 0x0704);
		CMD(0x3D, 0x0807);
		//------------------ Set GRAM area ---------------// 		 
		CMD(0x50, 0x0000);	// Horizontal GRAM Start Address 	 
		CMD(0x51, 0x00EF);	// Horizontal GRAM End Address 	 
		CMD(0x52, 0x0000);	// Vertical GRAM Start Address 	 
		CMD(0x53, 0x013F);	// Vertical GRAM Start Address 	 
		CMD(0x60, 0x2700);	// Gate Scan Line 	 
		CMD(0x61, 0x0001);	// NDL,VLE, REV 	 
		CMD(0x6A, 0x0000);	// set scrolling line 	 
		//-------------- Partial Display Control ---------// 		 
		CMD(0x80, 0x0000); 		 
		CMD(0x81, 0x0000); 		 
		CMD(0x82, 0x0000); 		 
		CMD(0x83, 0x0000); 		 
		CMD(0x84, 0x0000); 		 
		CMD(0x85, 0x0000); 		 
		//-------------- Panel Control -------------------// 		 
		CMD(0x90, 0x0010); 		 
		CMD(0x92, 0x0000); 		 
		CMD(0x93, 0x0003); 		 
		CMD(0x95, 0x0110); 		 
		CMD(0x97, 0x0000); 		 
		CMD(0x98, 0x0000); 		 
		CMD(0x07, 0x0173);	// 262K color and display ON 
	}
#elif ILI9320AUO
	void LCM_init()
{ 
  // VCI=2.8V  
  //************* Reset LCD Driver ****************// 
  	LCM_RES=0;
		delay10ms(50);
		LCM_RES=1;
		delay10ms(50);     
  //************* Start Initial Sequence **********// 
   
    CMD(0x00E5, 0x8000);     // Set the internal vcore voltage   
    CMD(0x0000, 0x0001);     // Start internal OSC. 
    CMD(0x0001, 0x0100);    // set SS and SM bit 
    CMD(0x0002, 0x0700);    // set 1 line inversion 
    CMD(0x0003, 0x1030);    // set GRAM write direction and BG
    CMD(0x0004, 0x0000);    // Resize register 
     
    CMD(0x0008, 0x0202);    // set the back porch and front porc
    CMD(0x0009, 0x0000);    // set non-display area refresh cycl
    CMD(0x000A, 0x0000);    // FMARK function 
    CMD(0x000C, 0x0000);    // RGB interface setting 
    CMD(0x000D, 0x0000);    // Frame marker Position 
    CMD(0x000F, 0x0000);     // RGB interface polarity 
   
  //*************Power On sequence ****************// 
    CMD(0x0010, 0x0000);         // SAP, BT[3:0], AP, DSTB, S
    CMD(0x0011, 0x0000);         // DC1[2:0], DC0[2:0], VC[2:0
    CMD(0x0012, 0x0000);         // VREG1OUT voltage 
    CMD(0x0013, 0x0000);         // VDV[4:0] for VCOM amplitu
      delay10ms(200);                                // Dis-charge capacitor powe
   
    CMD(0x0010, 0x17B0);         // SAP, BT[3:0], AP, DSTB, S
    CMD(0x0011, 0x0137);         // DC1[2:0], DC0[2:0], VC[2:0
      delay10ms(50);                       // Delay 50ms   
    CMD(0x0012, 0x0139);         // VREG1OUT voltage 
      delay10ms(50);                       // Delay 50ms 
    CMD(0x0013, 0x1d00);         // VDV[4:0] for VCOM amplitu
    CMD(0x0029, 0x0013);         // VCM[4:0] for VCOMH 
      delay10ms(50);     
    CMD(0x0020, 0x0000);         // GRAM horizontal Address 
    CMD(0x0021, 0x0000);         // GRAM Vertical Address 
     
  // ----------- Adjust the Gamma  Curve ----------// 
    CMD(0x0030, 0x0006);   
    CMD(0x0031, 0x0101);   
    CMD(0x0032, 0x0003); 
    CMD(0x0035, 0x0106);   
    CMD(0x0036, 0x0b02);   
    CMD(0x0037, 0x0302);   
    CMD(0x0038, 0x0707);   
    CMD(0x0039, 0x0007); 
    CMD(0x003C, 0x0600);   
    CMD(0x003D, 0x020b);  
   
  //------------------ Set GRAM area ---------------// 
    CMD(0x0050, 0x0000);     // Horizontal GRAM Start Address 
    CMD(0x0051, 0x00EF);     // Horizontal GRAM End Address 
    CMD(0x0052, 0x0000);     // Vertical GRAM Start Address 
    CMD(0x0053, 0x013F);     // Vertical GRAM Start Address 
 
    CMD(0x0060, 0x2700);     // Gate Scan Line 
    CMD(0x0061, 0x0001);     // NDL,VLE, REV 
    CMD(0x006A, 0x0000);     // set scrolling line 
   
  //-------------- Partial Display Control ---------// 
    CMD(0x0080, 0x0000); 
    CMD(0x0081, 0x0000); 
    CMD(0x0082, 0x0000); 
    CMD(0x0083, 0x0000); 
    CMD(0x0084, 0x0000); 
    CMD(0x0085, 0x0000); 
     
  //-------------- Panel Control -------------------// 
    CMD(0x0090, 0x0010); 
    CMD(0x0092, 0x0000); 
    CMD(0x0093, 0x0003); 
    CMD(0x0095, 0x0110); 
    CMD(0x0097, 0x0000); 
    CMD(0x0098, 0x0000); 
   
    CMD(0x0007, 0x0173);     // 262K color and display ON 
} 
 
#elif SSD1289Z
	void LCM_init()
	  { 	LCM_RES=0;
			delay10ms(50);
			LCM_RES=1;
			delay10ms(50);
	/*		CMD(0x0,0x00001);///osc on
			CMD(0x01,0x2b3f);/// 
			CMD(0x10,0x0000);/// 
		 	CMD(0x07,0x0033);	////display control 1 
			delay10ms(50);
		
			//power setting sequence
		//	CMD(0x11,0x6830);	//6830//power control 2
		 	CMD(0x02,0x0600);	
			CMD(0x03,0x000e);	
			CMD(0x0d,0x000e);
			CMD(0x0e,0x2d00);	//3300
			CMD(0x25,0x5000);	
			CMD(0x0b,0x4030);
		//	CMD(0x17,0x1b1b);
		
			CMD(0x1e,0x00a5);//9b
		
			CMD(0x0f,0x0000);

        */
		/*
			CMD(0x41,0x0000);
			CMD(0x42,0x0000);
			CMD(0x44,0xef00);
			CMD(0x45,0x0000);
			CMD(0x46,0x013f);
			CMD(0x48,0x0000);
			CMD(0x49,0x013f);
			CMD(0x4a,0x0000);
			CMD(0x4b,0x0000);
		*/
		/*
			CMD(0x30,0x0100);
		 	CMD(0x31,0x0707);
		 	CMD(0x32,0x0707);
		 	CMD(0x33,0x0200);
			CMD(0x34,0x0000);
		 
		 	CMD(0x35,0x0000);
		 	CMD(0x36,0x0706);
		 	CMD(0x37,0x0002);
		 	CMD(0x3a,0x1e00);
		 	CMD(0x3b,0x000F);
		 */
			//display on sequence

		CMD(0x00,0x0001);
 
 CMD(0x01,0x6B3F);//
 CMD(0x10,0x0000);
 CMD(0x03,0x626E);
 CMD(0x0D,0x0006);
 CMD(0x0E,0x3300);
 CMD(0x1E,0x00AE);
 CMD(0x07,0x0033);
 CMD(0x0F,0x0000);
 CMD(0x11,0x4820);
 CMD(0x25,0x8000);
 CMD(0x44,0xEF00);
 CMD(0x45,0x0000);
 CMD(0x46,0x013F);
 CMD(0x48,0x0000);
 CMD(0x49,0x013F);
 CMD(0x4E,0x00EF);
 CMD(0x4F,0x0000);
 CMD(0x16,0x1FFF);
 CMD(0x28,0x0006);
 //CMD(0x2F,0x12AE);
 CMD(0x02,0x0600); //0600
	
	} 

#elif SPFD5408
	void LCM_init()
{
CMD(0x00E5,0x8000); 	// Set the internal vcore voltage 
CMD(0x00,0x0001);
CMD(0x01,0x0100); 
CMD(0x02,0x0700); 
CMD(0x03,0x1000); //D0A0
CMD(0x04,0x0000);
 
CMD(0x08,0x0207); 
CMD(0x09,0x0000); 
CMD(0x0A,0x0000); 
CMD(0x0C,0x0000);
CMD(0x0D,0x0000); 
CMD(0x0F,0x0000);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -