Beispiel #1
0
void LCD_Init(void)
{
	     LCD_PORT_INI();
	     LCD_RST_L();//硬件复位
	     delay_ms(100);
	     LCD_RST_H();
	     delay_ms(100); 
	//initializing funciton 1 
		 LCD_WR_REG(0x00E3,0x3008);        
	     LCD_WR_REG(0x00E7,0x0012);
	     LCD_WR_REG(0x00Ef,0x1231); 	// Set the internal timing;    
         LCD_WR_REG(0x00,0x0001);
         LCD_WR_REG(0x01, 0x0000); // set SS and SM bit
         LCD_WR_REG(0x02, 0x0700); // set 1 line inversion
        // LCD_WR_REG(0x03, 0x10B0); // set GRAM write direction and BGR=1.
#if   ID_AM==000       
	     LCD_WR_REG(0x0003,0x1000);//屏幕旋转控制 TFM=0,TRI=0,SWAP=1,16 bits system interface  swap RGB to BRG,此处ORG和HWM 为0
#elif ID_AM==001        
	     LCD_WR_REG(0x0003,0x1008);      
#elif ID_AM==010  
	     LCD_WR_REG(0x0003,0x1010);        
#elif ID_AM==011
	     LCD_WR_REG(0x0003,0x1018);
#elif ID_AM==100  
	     LCD_WR_REG(0x0003,0x1020);      
#elif ID_AM==101  
	     LCD_WR_REG(0x0003,0x1028);      
#elif ID_AM==110  
	     LCD_WR_REG(0x0003,0x1030);      
#elif ID_AM==111  
	     LCD_WR_REG(0x0003,0x1038);
#endif    
        LCD_WR_REG(0x04, 0x0000); // Resize register
         LCD_WR_REG(0x08, 0x0404); // set the back porch and front porch
         LCD_WR_REG(0x09, 0x0000); // set non-display area refresh cycle ISC[3:0]
         LCD_WR_REG(0x0A, 0x0000); // FMARK function
        // LCD_WR_REG(0x0C, 0x0000); // RGB interface setting
        // LCD_WR_REG(0x0D, 0x0000); // Frame marker Position
        // LCD_WR_REG(0x0F, 0x0000); // RGB interface polarity
//Power On sequence //
         LCD_WR_REG(0x10, 0x0080); // SAP, BT[3:0], AP, DSTB, SLP, STB
         LCD_WR_REG(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
         LCD_WR_REG(0x12, 0x0000); // VREG1OUT voltage
         LCD_WR_REG(0x13, 0x0000); // VDV[4:0] for VCOM amplitude
	 LCD_WR_REG(0x07, 0x0001); // 
		 
         delay_ms(2000); // Dis-charge capacitor power voltage
         
         LCD_WR_REG(0x10, 0x1590); // SAP, BT[3:0], AP, DSTB, SLP, STB
         LCD_WR_REG(0x11, 0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
         delay_ms(1000); // Delay 50ms
        
         LCD_WR_REG(0x12, 0x001e); // Internal reference voltage= Vci;
         delay_ms(1000); // Delay 50ms
         LCD_WR_REG(0x13, 0x1500); // Set VDV[4:0] for VCOM amplitude
         LCD_WR_REG(0x29, 0x0028); // Set VCM[5:0] for VCOMH
         LCD_WR_REG(0x2B, 0x000f); // Set Frame Rate
         delay_ms(500); // Delay 50ms
         
#if   ID_AM==000         
	     LCD_WR_REG(0x0020,0x00ef);//GRAM水平起始位置
	     LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==001
	     LCD_WR_REG(0x0020,0x00ef);
	     LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==010
	     LCD_WR_REG(0x0020,0x0000);
	     LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==011
	     LCD_WR_REG(0x0020,0x0000);
	     LCD_WR_REG(0x0021,0x013f);       
#elif ID_AM==100
	     LCD_WR_REG(0x0020,0x00ef);
	     LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==101  
	     LCD_WR_REG(0x0020,0x00ef);
	     LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==110
	     LCD_WR_REG(0x0020,0x0000);
	     LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==111
	     LCD_WR_REG(0x0020,0x0000);
	     LCD_WR_REG(0x0021,0x0000);         
#endif  
// ----------- Adjust the Gamma Curve ----------//
		LCD_WR_REG(0x0030,0x0007);
		LCD_WR_REG(0x0031,0x0707);
		LCD_WR_REG(0x0032,0x0107);
		LCD_WR_REG(0x0035,0x0206);
		LCD_WR_REG(0x0036,0x0406);
		LCD_WR_REG(0x0037,0x0101);
		LCD_WR_REG(0x0038,0x0101);
		LCD_WR_REG(0x0039,0x0207);
		LCD_WR_REG(0x003C,0x0504);
		LCD_WR_REG(0x003D,0x0806);
	

		 
//------------------ Set GRAM area ---------------//
         LCD_WR_REG(0x0050, 0x0000); // Horizontal GRAM Start Address
         LCD_WR_REG(0x0051, 0x00EF); // Horizontal GRAM End Address
         LCD_WR_REG(0x0052, 0x0000); // Vertical GRAM Start Address
         LCD_WR_REG(0x0053, 0x013F); // Vertical GRAM Start Address
         LCD_WR_REG(0x0060, 0x2700); // Gate Scan Line
         LCD_WR_REG(0x0061, 0x0001); // NDL,VLE, REV
         LCD_WR_REG(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
         LCD_WR_REG(0x80, 0x0000);
         LCD_WR_REG(0x81, 0x0000);
         LCD_WR_REG(0x82, 0x0000);
         LCD_WR_REG(0x83, 0x0000);
         LCD_WR_REG(0x84, 0x0000);
         LCD_WR_REG(0x85, 0x0000);
//-------------- Panel Control -------------------//
         LCD_WR_REG(0x90, 0x0010);
         LCD_WR_REG(0x92, 0x0600);
         LCD_WR_REG(0x93, 0x0003);
         LCD_WR_REG(0x95, 0x0110);
         LCD_WR_REG(0x97, 0x0000);
         LCD_WR_REG(0x98, 0x0000);
		 
         LCD_WR_REG(0x07, 0x0173); // 262K color and display ON   0133
		 LCD_Clear(0);
		 delay_ms(2000); // Delay 5ms
		 
		 LCD_BL_H();
  
}
Beispiel #2
0
void ILI9341_Init( void )
{
  // reset
  LCD_RST_L();
  delay_ms(100);
  LCD_RST_H();
  delay_ms(50);

  LCD_WriteCmd(0xCB);
  LCD_WriteData(0x39);
  LCD_WriteData(0x2C);
  LCD_WriteData(0x00);
  LCD_WriteData(0x34);
  LCD_WriteData(0x02);

  LCD_WriteCmd(0xCF);
  LCD_WriteData(0x00);
  LCD_WriteData(0XC1);
  LCD_WriteData(0X30);

  LCD_WriteCmd(0xE8);
  LCD_WriteData(0x85);
  LCD_WriteData(0x00);
  LCD_WriteData(0x78);

  LCD_WriteCmd(0xEA);
  LCD_WriteData(0x00);
  LCD_WriteData(0x00);

  LCD_WriteCmd(0xED);
  LCD_WriteData(0x64);
  LCD_WriteData(0x03);
  LCD_WriteData(0X12);
  LCD_WriteData(0X81);

  LCD_WriteCmd(0xF7);
  LCD_WriteData(0x20);

  LCD_WriteCmd(0xC0);   // Power control
  LCD_WriteData(0x23);  // VRH[5:0]

  LCD_WriteCmd(0xC1);   // Power control
  LCD_WriteData(0x10);  // SAP[2:0];BT[3:0]

  LCD_WriteCmd(0xC5);   // VCM control
  LCD_WriteData(0x3e);  // 
  LCD_WriteData(0x28); 

  LCD_WriteCmd(0xC7);   // VCM control2
  LCD_WriteData(0x86);  // --

  LCD_WriteCmd(0x36);   // Memory Access Control
#ifdef H_VIEW
  LCD_WriteData(0x48);  // H
#else
  LCD_WriteData(0xE8);  // V
#endif

  LCD_WriteCmd(0x3A);
  LCD_WriteData(0x55);

  LCD_WriteCmd(0xB1);
  LCD_WriteData(0x00);
  LCD_WriteData(0x18);

  LCD_WriteCmd(0xB6);   // Display Function Control
  LCD_WriteData(0x08);
  LCD_WriteData(0x82);
  LCD_WriteData(0x27);

  LCD_WriteCmd(0xF2);   // 3Gamma Function Disable
  LCD_WriteData(0x00);

  LCD_WriteCmd(0x26);   // Gamma curve selected
  LCD_WriteData(0x01);

  LCD_WriteCmd(0xE0);   // Set Gamma
  LCD_WriteData(0x0F);
  LCD_WriteData(0x31);
  LCD_WriteData(0x2B);
  LCD_WriteData(0x0C);
  LCD_WriteData(0x0E);
  LCD_WriteData(0x08);
  LCD_WriteData(0x4E);
  LCD_WriteData(0xF1);
  LCD_WriteData(0x37);
  LCD_WriteData(0x07);
  LCD_WriteData(0x10);
  LCD_WriteData(0x03);
  LCD_WriteData(0x0E);
  LCD_WriteData(0x09);
  LCD_WriteData(0x00);

  LCD_WriteCmd(0XE1);   // Set Gamma
  LCD_WriteData(0x00);
  LCD_WriteData(0x0E);
  LCD_WriteData(0x14);
  LCD_WriteData(0x03);
  LCD_WriteData(0x11);
  LCD_WriteData(0x07);
  LCD_WriteData(0x31);
  LCD_WriteData(0xC1);
  LCD_WriteData(0x48);
  LCD_WriteData(0x08);
  LCD_WriteData(0x0F);
  LCD_WriteData(0x0C);
  LCD_WriteData(0x31);
  LCD_WriteData(0x36);
  LCD_WriteData(0x0F);

  LCD_WriteCmd(0x11);   // Exit Sleep
  delay_ms(120);

  LCD_WriteCmd(0x29);   // Display on
  LCD_WriteCmd(0x2C);

  LCD_Clear(BLACK);
  LCD_SetBackLight(BLIGHT_DEFAULT);
}