LCD_WR_DATA(0x0A); LCD_WR_DATA(0x0F); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00);
LCD_WR_REG(0XE1); //Set Gamma LCD_WR_DATA(0x00); LCD_WR_DATA(0x15); LCD_WR_DATA(0x17); LCD_WR_DATA(0x07); LCD_WR_DATA(0x11); LCD_WR_DATA(0x06); LCD_WR_DATA(0x2B); LCD_WR_DATA(0x56); LCD_WR_DATA(0x3C); LCD_WR_DATA(0x05); LCD_WR_DATA(0x10); LCD_WR_DATA(0x0F); LCD_WR_DATA(0x3F); LCD_WR_DATA(0x3F); LCD_WR_DATA(0x0F); LCD_WR_REG(0x2B); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x01); LCD_WR_DATA(0x3f);
39
}
}
LCD_WR_REG(0x2A); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0xef);
LCD_WR_REG(0x11); //Exit Sleep Delay(120);
LCD_WR_REG(0x29); //display on
void LCD_Init(void) { }
void LCD_SetCursor(u16 Xpos, u16 Ypos) {
if(lcddev.id==0X9341) {
LCD_GPIO_Config(); LCD_FSMC_Config(); LCD_init_RGB(); LCD_DisplayOn(); LCD_Display_Dir(0); LCD_Clear(WHITE);
//默认为竖屏
LCD_WR_REG(lcddev.setxcmd); LCD_WR_DATA(Xpos>>8); LCD_WR_DATA(Xpos&0XFF); LCD_WR_REG(lcddev.setycmd);
40
LCD_WR_DATA(Ypos>>8); LCD_WR_DATA(Ypos&0XFF);
} }
void LCD_Scan_Dir(u8 dir) {
u16 regval=0; u8 dirreg=0; u16 temp;
if(lcddev.dir==1&&lcddev.id!=0X6804)//横屏时,对6804不改变扫描方向! { }
if(lcddev.id==0x9341||lcddev.id==0X6804)//9341/6804,很特殊 {
switch(dir) {
41
switch(dir)//方向转换 { }
case 0:dir=6;break; case 1:dir=7;break; case 2:dir=4;break; case 3:dir=5;break; case 4:dir=1;break; case 5:dir=0;break; case 6:dir=3;break; case 7:dir=2;break;
}
case L2R_U2D://从左到右,从上到下
regval|=(0<<7)|(0<<6)|(0<<5); break;
case L2R_D2U://从左到右,从下到上
regval|=(1<<7)|(0<<6)|(0<<5); break;
case R2L_U2D://从右到左,从上到下
regval|=(0<<7)|(1<<6)|(0<<5); break;
case R2L_D2U://从右到左,从下到上
regval|=(1<<7)|(1<<6)|(0<<5); break;
case U2D_L2R://从上到下,从左到右
regval|=(0<<7)|(0<<6)|(1<<5); break;
case U2D_R2L://从上到下,从右到左
regval|=(0<<7)|(1<<6)|(1<<5); break;
case D2U_L2R://从下到上,从左到右
regval|=(1<<7)|(0<<6)|(1<<5); break;
case D2U_R2L://从下到上,从右到左
regval|=(1<<7)|(1<<6)|(1<<5); break;
dirreg=0X36;
regval|=0X08;//BGR
42
if(lcddev.id==0X6804)regval|=0x02;//6804的BIT6和9341的反了 LCD_WriteReg(dirreg,regval); if((regval&0X20)||lcddev.dir==1) {
if(lcddev.width temp=lcddev.width; lcddev.width=lcddev.height; lcddev.height=temp; }else { if(lcddev.width>lcddev.height)//交换X,Y { } temp=lcddev.width; lcddev.width=lcddev.height; lcddev.height=temp; } LCD_WR_REG(lcddev.setxcmd); LCD_WR_DATA(0); LCD_WR_DATA(0); LCD_WR_DATA((lcddev.width-1)>>8); LCD_WR_DATA((lcddev.width-1)&0XFF); LCD_WR_REG(lcddev.setycmd); LCD_WR_DATA(0);LCD_WR_DATA(0); LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-43