|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
u16 POINT_COLOR=0x0000;
u16 BACK_COLOR=0xFFFF;
_lcd_dev lcddev;
void LCD_WR_REG(u16 regval)
{
LCD->LCD_REG=regval;
}
void LCD_WR_DATA(u16 data)
{
LCD->LCD_RAM=data;
}
u16 LCD_RD_DATA(void)
{
return LCD->LCD_RAM;
}
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{
LCD->LCD_REG = LCD_Reg;
LCD->LCD_RAM = LCD_RegValue;
}
u16 LCD_ReadReg(u8 LCD_Reg)
{
LCD_WR_REG(LCD_Reg);
delay_us(5);
return LCD_RD_DATA();
}
void LCD_WriteRAM_Prepare(void)
{
LCD->LCD_REG=lcddev.wramcmd;
}
void LCD_WriteRAM(u16 RGB_Code)
{
LCD->LCD_RAM = RGB_Code;//дʮÁùλGRAM
}
u16 LCD_BGR2RGB(u16 c)
{
u16 r,g,b,rgb;
b=(c>>0)&0x1f;
g=(c>>5)&0x3f;
r=(c>>11)&0x1f;
rgb=(b<<11)+(g<<5)+(r<<0);
return(rgb);
}
void opt_delay(u8 i)
{
while(i--);
}
u16 LCD_ReadPoint(u16 x,u16 y)
{
u16 r=0,g=0,b=0;
if(x>=lcddev.width||y>=lcddev.height)return 0;
LCD_SetCursor(x,y);
if(lcddev.id==0X9341||lcddev.id==0X6804)LCD_WR_REG(0X2E);
else LCD_WR_REG(R34);
if(lcddev.id==0X9320)opt_delay(2);
if(LCD->LCD_RAM)r=0;
opt_delay(2);
r=LCD->LCD_RAM;
if(lcddev.id==0X9341)
{
opt_delay(2);
b=LCD->LCD_RAM;
g=r&0XFF;
g<<=8;
}else if(lcddev.id==0X6804)r=LCD->LCD_RAM;
if(lcddev.id==0X9325||lcddev.id==0X4535||lcddev.id==0X4531||lcddev.id==0X8989||lcddev.id==0XB505)return r;
else if(lcddev.id==0X9341)return (((r>>11)<<11)|((g>>10)<<5)|(b>>11));
else return LCD_BGR2RGB(r);
}
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
if(lcddev.id==0X9341||lcddev.id==0X6804)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);
LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);
LCD_WR_DATA(Ypos&0XFF);
}else
{
if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;
LCD_WriteReg(lcddev.setxcmd, Xpos);
LCD_WriteReg(lcddev.setycmd, Ypos);
}
}
void LCD_Scan_Dir(u8 dir)
{
u16 regval=0;
u8 dirreg=0;
u16 temp;
if(lcddev.dir==1&&lcddev.id!=0X6804)
{
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;
}
}
if(lcddev.id==0x9341||lcddev.id==0X6804)
{
switch(dir)
{
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
if(lcddev.id==0X6804)regval|=0x02;
LCD_WriteReg(dirreg,regval);
if(regval&0X20)
{
if(lcddev.width<lcddev.height)
{
temp=lcddev.width;
lcddev.width=lcddev.height;
lcddev.height=temp;
}
}else
{
if(lcddev.width>lcddev.height)
{
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-1)&0XFF);
}else
{
switch(dir)
{
case L2R_U2D:
regval|=(1<<5)|(1<<4)|(0<<3);
break;
case L2R_D2U:
regval|=(0<<5)|(1<<4)|(0<<3);
break;
case R2L_U2D:
regval|=(1<<5)|(0<<4)|(0<<3);
break;
case R2L_D2U:
regval|=(0<<5)|(0<<4)|(0<<3);
break;
case U2D_L2R:
regval|=(1<<5)|(1<<4)|(1<<3);
break;
case U2D_R2L:
regval|=(1<<5)|(0<<4)|(1<<3);
break;
case D2U_L2R:
regval|=(0<<5)|(1<<4)|(1<<3);
break;
case D2U_R2L:
regval|=(0<<5)|(0<<4)|(1<<3);
break;
}
if(lcddev.id==0x8989)//8989 IC
{
dirreg=0X11;
regval|=0X6040;
}else
{
dirreg=0X03;
regval|=1<<12;
}
LCD_WriteReg(dirreg,regval);
}
}
void LCD_DrawPoint(u16 x,u16 y)
{
LCD_SetCursor(x,y);
LCD_WriteRAM_Prepare();
LCD->LCD_RAM=POINT_COLOR;
}
void LCD_Fast_DrawPoint(u16 x,u16 y,u16 color)
{
if(lcddev.id==0X9341||lcddev.id==0X6804)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(x>>8);
LCD_WR_DATA(x&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(y>>8);
LCD_WR_DATA(y&0XFF);
}else
{
if(lcddev.dir==1)x=lcddev.width-1-x;
LCD_WriteReg(lcddev.setxcmd,x);
LCD_WriteReg(lcddev.setycmd,y);
}
LCD->LCD_REG=lcddev.wramcmd;
LCD->LCD_RAM=color;
}
void LCD_Display_Dir(u8 dir)
{
if(dir==0)
{
lcddev.dir=0;
lcddev.width=240;
lcddev.height=320;
if(lcddev.id==0X9341||lcddev.id==0X6804)
{
lcddev.wramcmd=0X2C;
lcddev.setxcmd=0X2A;
lcddev.setycmd=0X2B;
if(lcddev.id==0X6804)
{
lcddev.width=320;
lcddev.height=480;
}
}else if(lcddev.id==0X8989)
{
lcddev.wramcmd=R34;
lcddev.setxcmd=0X4E;
lcddev.setycmd=0X4F;
}else
{
lcddev.wramcmd=R34;
lcddev.setxcmd=R32;
lcddev.setycmd=R33;
}
}else if(lcddev.id!=0X6804)
{
lcddev.dir=1;//ºáÆÁ
lcddev.width=320;
lcddev.height=240;
if(lcddev.id==0X9341)
{
lcddev.wramcmd=0X2C;
lcddev.setxcmd=0X2A;
lcddev.setycmd=0X2B;
}else if(lcddev.id==0X8989)
{
lcddev.wramcmd=R34;
lcddev.setxcmd=0X4F;
lcddev.setycmd=0X4E;
}else
{
lcddev.wramcmd=R34;
lcddev.setxcmd=R33;
lcddev.setycmd=R32;
}
}
LCD_Scan_Dir(DFT_SCAN_DIR);
}
void LCD_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
FSMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOG|RCC_APB2Periph_AFIO,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
readWriteTiming.FSMC_AddressSetupTime = 0xa0;
readWriteTiming.FSMC_AddressHoldTime = 0x00;
readWriteTiming.FSMC_DataSetupTime = 0x7f;
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;
writeTiming.FSMC_AddressSetupTime = 0xa0;
writeTiming.FSMC_AddressHoldTime = 0x00;
writeTiming.FSMC_DataSetupTime = 0x07;
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; //SRAM
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
delay_ms(50);
LCD_WriteReg(0x0000,0x0001);
delay_ms(50);
lcddev.id = LCD_ReadReg(0x0000);
if(lcddev.id<0XFF||lcddev.id==0XFFFF||lcddev.id==0X9300)
{
LCD_WR_REG(0XD3);
LCD_RD_DATA();
LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
if(lcddev.id!=0X9341)
{
LCD_WR_REG(0XBF);
LCD_RD_DATA();
LCD_RD_DATA();
LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
}
if(lcddev.id!=0X9341&&lcddev.id!=0X6804)lcddev.id=0x9341;
}
printf(" LCD ID:%x\r\n",lcddev.id);
if(lcddev.id==0X9341)
{
LCD_WR_REG(0xCF);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0xC1);
LCD_WR_DATA(0X30);
LCD_WR_REG(0xED);
LCD_WR_DATA(0x64);
LCD_WR_DATA(0x03);
LCD_WR_DATA(0X12);
LCD_WR_DATA(0X81);
LCD_WR_REG(0xE8);
LCD_WR_DATA(0x85);
LCD_WR_DATA(0x10);
LCD_WR_DATA(0x7A);
LCD_WR_REG(0xCB);
LCD_WR_DATA(0x39);
LCD_WR_DATA(0x2C);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x34);
LCD_WR_DATA(0x02);
LCD_WR_REG(0xF7);
LCD_WR_DATA(0x20);
LCD_WR_REG(0xEA);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_REG(0xC0);
LCD_WR_DATA(0x1B);
LCD_WR_REG(0xC1);
LCD_WR_DATA(0x01);
LCD_WR_REG(0xC5);
LCD_WR_DATA(0x30);
LCD_WR_DATA(0x30);
LCD_WR_REG(0xC7);
LCD_WR_DATA(0XB7);
LCD_WR_REG(0x36);
LCD_WR_DATA(0x48);
LCD_WR_REG(0x3A);
LCD_WR_DATA(0x55);
LCD_WR_REG(0xB1);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x1A);
LCD_WR_REG(0xB6);
LCD_WR_DATA(0x0A);
LCD_WR_DATA(0xA2);
LCD_WR_REG(0xF2);
LCD_WR_DATA(0x00);
LCD_WR_REG(0x26);
LCD_WR_DATA(0x01);
LCD_WR_REG(0xE0);
LCD_WR_DATA(0x0F);
LCD_WR_DATA(0x2A);
LCD_WR_DATA(0x28);
LCD_WR_DATA(0x08);
LCD_WR_DATA(0x0E);
LCD_WR_DATA(0x08);
LCD_WR_DATA(0x54);
LCD_WR_DATA(0XA9);
LCD_WR_DATA(0x43);
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);
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);
LCD_WR_REG(0x2A);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0xef);
LCD_WR_REG(0x11);
delay_ms(120);
LCD_WR_REG(0x29);
}else if(lcddev.id==0x6804)
{
LCD_WR_REG(0X11);
delay_ms(20);
LCD_WR_REG(0XD0);
LCD_WR_DATA(0X07);
LCD_WR_DATA(0X42);
LCD_WR_DATA(0X1D);
LCD_WR_REG(0XD1);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X1a);
LCD_WR_DATA(0X09);
LCD_WR_REG(0XD2);
LCD_WR_DATA(0X01);
LCD_WR_DATA(0X22);
LCD_WR_REG(0XC0);
LCD_WR_DATA(0X10);
LCD_WR_DATA(0X3B);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X02);
LCD_WR_DATA(0X11);
LCD_WR_REG(0XC5);
LCD_WR_DATA(0X03);
LCD_WR_REG(0XC8);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X25);
LCD_WR_DATA(0X21);
LCD_WR_DATA(0X05);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X0a);
LCD_WR_DATA(0X65);
LCD_WR_DATA(0X25);
LCD_WR_DATA(0X77);
LCD_WR_DATA(0X50);
LCD_WR_DATA(0X0f);
LCD_WR_DATA(0X00);
LCD_WR_REG(0XF8);
LCD_WR_DATA(0X01);
LCD_WR_REG(0XFE);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X02);
LCD_WR_REG(0X20);
LCD_WR_REG(0X36);
LCD_WR_DATA(0X08);
LCD_WR_REG(0X3A);
LCD_WR_DATA(0X55);
LCD_WR_REG(0X2B);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X01);
LCD_WR_DATA(0X3F);
LCD_WR_REG(0X2A);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X00);
LCD_WR_DATA(0X01);
LCD_WR_DATA(0XDF);
delay_ms(120);
LCD_WR_REG(0X29);
}else if(lcddev.id==0x9325)//9325
{
LCD_WriteReg(0x00E5,0x78F0);
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700);
LCD_WriteReg(0x0003,0x1030);
LCD_WriteReg(0x0004,0x0000);
LCD_WriteReg(0x0008,0x0202);
LCD_WriteReg(0x0009,0x0000);
LCD_WriteReg(0x000A,0x0000);
LCD_WriteReg(0x000C,0x0000);
LCD_WriteReg(0x000D,0x0000);
LCD_WriteReg(0x000F,0x0000);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x0007);
LCD_WriteReg(0x0012,0x0000);
LCD_WriteReg(0x0013,0x0000);
LCD_WriteReg(0x0007,0x0000);
LCD_WriteReg(0x0010,0x1690);
LCD_WriteReg(0x0011,0x0227);
LCD_WriteReg(0x0012,0x009D);
LCD_WriteReg(0x0013,0x1900);
LCD_WriteReg(0x0029,0x0025);
LCD_WriteReg(0x002B,0x000D);
LCD_WriteReg(0x0030,0x0007);
LCD_WriteReg(0x0031,0x0303);
LCD_WriteReg(0x0032,0x0003);// 0006
LCD_WriteReg(0x0035,0x0206);
LCD_WriteReg(0x0036,0x0008);
LCD_WriteReg(0x0037,0x0406);
LCD_WriteReg(0x0038,0x0304);
LCD_WriteReg(0x0039,0x0007);
LCD_WriteReg(0x003C,0x0602);
LCD_WriteReg(0x003D,0x0008);
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00EF);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013F);
LCD_WriteReg(0x0060,0xA700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x006A,0x0000);
LCD_WriteReg(0x0080,0x0000);
LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0082,0x0000);
LCD_WriteReg(0x0083,0x0000);
LCD_WriteReg(0x0084,0x0000);
LCD_WriteReg(0x0085,0x0000);
LCD_WriteReg(0x0090,0x0010);
LCD_WriteReg(0x0092,0x0600);
LCD_WriteReg(0x0007,0x0133);
LCD_WriteReg(0x00,0x0022);
}else if(lcddev.id==0x9328)
{
LCD_WriteReg(0x00EC,0x108F);
LCD_WriteReg(0x00EF,0x1234);
//LCD_WriteReg(0x00e7,0x0010);
//LCD_WriteReg(0x0000,0x0001);
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700);
LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(0<<3) );
LCD_WriteReg(0x0004,0x0000);
LCD_WriteReg(0x0008,0x0202);
LCD_WriteReg(0x0009,0x0000);
LCD_WriteReg(0x000a,0x0000);
LCD_WriteReg(0x000c,0x0001);
LCD_WriteReg(0x000d,0x0000);
LCD_WriteReg(0x000f,0x0000);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x0007);
LCD_WriteReg(0x0012,0x0000);
LCD_WriteReg(0x0013,0x0000);
LCD_WriteReg(0x0007,0x0001);
delay_ms(50);
LCD_WriteReg(0x0010,0x1490);
LCD_WriteReg(0x0011,0x0227);
delay_ms(50);
LCD_WriteReg(0x0012,0x008A);
delay_ms(50);
LCD_WriteReg(0x0013,0x1a00);
LCD_WriteReg(0x0029,0x0006);
LCD_WriteReg(0x002b,0x000d);
delay_ms(50);
LCD_WriteReg(0x0020,0x0000);
LCD_WriteReg(0x0021,0x0000);
delay_ms(50);
LCD_WriteReg(0x0030,0x0000);
LCD_WriteReg(0x0031,0x0604);
LCD_WriteReg(0x0032,0x0305);
LCD_WriteReg(0x0035,0x0000);
LCD_WriteReg(0x0036,0x0C09);
LCD_WriteReg(0x0037,0x0204);
LCD_WriteReg(0x0038,0x0301);
LCD_WriteReg(0x0039,0x0707);
LCD_WriteReg(0x003c,0x0000);
LCD_WriteReg(0x003d,0x0a0a);
delay_ms(50);
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00ef);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013f);
LCD_WriteReg(0x0060,0xa700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x006a,0x0000);
LCD_WriteReg(0x0080,0x0000);
LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0082,0x0000);
LCD_WriteReg(0x0083,0x0000);
LCD_WriteReg(0x0084,0x0000);
LCD_WriteReg(0x0085,0x0000);
LCD_WriteReg(0x0090,0x0010);
LCD_WriteReg(0x0092,0x0600);
LCD_WriteReg(0x0007,0x0133);
}else if(lcddev.id==0x9320)
{
LCD_WriteReg(0x00,0x0000);
LCD_WriteReg(0x01,0x0100);
LCD_WriteReg(0x02,0x0700);
LCD_WriteReg(0x03,0x1030);
//LCD_WriteReg(0x03,0x1018);
LCD_WriteReg(0x04,0x0000);
LCD_WriteReg(0x08,0x0202);
LCD_WriteReg(0x09,0x0000);
LCD_WriteReg(0x0a,0x0000);
LCD_WriteReg(0x0c,(1<<0));
LCD_WriteReg(0x0d,0x0000);
LCD_WriteReg(0x0f,0x0000);
delay_ms(50);
LCD_WriteReg(0x07,0x0101);
delay_ms(50);
LCD_WriteReg(0x10,(1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4));
LCD_WriteReg(0x11,0x0007);
LCD_WriteReg(0x12,(1<<8)|(1<<4)|(0<<0));
LCD_WriteReg(0x13,0x0b00);
LCD_WriteReg(0x29,0x0000);
LCD_WriteReg(0x2b,(1<<14)|(1<<4));
LCD_WriteReg(0x50,0);
LCD_WriteReg(0x51,239);
LCD_WriteReg(0x52,0);
LCD_WriteReg(0x53,319);
LCD_WriteReg(0x60,0x2700);
LCD_WriteReg(0x61,0x0001);
LCD_WriteReg(0x6a,0x0000);
LCD_WriteReg(0x80,0x0000);
LCD_WriteReg(0x81,0x0000);
LCD_WriteReg(0x82,0x0000);
LCD_WriteReg(0x83,0x0000);
LCD_WriteReg(0x84,0x0000);
LCD_WriteReg(0x85,0x0000);
LCD_WriteReg(0x90,(0<<7)|(16<<0));
LCD_WriteReg(0x92,0x0000);
LCD_WriteReg(0x93,0x0001);
LCD_WriteReg(0x95,0x0110);
LCD_WriteReg(0x97,(0<<8));
LCD_WriteReg(0x98,0x0000);
LCD_WriteReg(0x07,0x0173);
}else if(lcddev.id==0X9331)
{
LCD_WriteReg(0x00E7, 0x1014);
LCD_WriteReg(0x0001, 0x0100);
LCD_WriteReg(0x0002, 0x0200);
LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(1<<3));
//LCD_WriteReg(0x0003, 0x1030);
LCD_WriteReg(0x0008, 0x0202);
LCD_WriteReg(0x0009, 0x0000);
LCD_WriteReg(0x000A, 0x0000);
LCD_WriteReg(0x000C, 0x0000);
LCD_WriteReg(0x000D, 0x0000);
LCD_WriteReg(0x000F, 0x0000);
LCD_WriteReg(0x0010, 0x0000);
LCD_WriteReg(0x0011, 0x0007);
LCD_WriteReg(0x0012, 0x0000);
LCD_WriteReg(0x0013, 0x0000);
delay_ms(200);
LCD_WriteReg(0x0010, 0x1690);
LCD_WriteReg(0x0011, 0x0227);
delay_ms(50);
LCD_WriteReg(0x0012, 0x000C);
delay_ms(50);
LCD_WriteReg(0x0013, 0x0800);
LCD_WriteReg(0x0029, 0x0011);
LCD_WriteReg(0x002B, 0x000B);
delay_ms(50);
LCD_WriteReg(0x0020, 0x0000);
LCD_WriteReg(0x0021, 0x013f);
LCD_WriteReg(0x0030, 0x0000);
LCD_WriteReg(0x0031, 0x0106);
LCD_WriteReg(0x0032, 0x0000);
LCD_WriteReg(0x0035, 0x0204);
LCD_WriteReg(0x0036, 0x160A);
LCD_WriteReg(0x0037, 0x0707);
LCD_WriteReg(0x0038, 0x0106);
LCD_WriteReg(0x0039, 0x0707);
LCD_WriteReg(0x003C, 0x0402);
LCD_WriteReg(0x003D, 0x0C0F);
LCD_WriteReg(0x0050, 0x0000);
LCD_WriteReg(0x0051, 0x00EF);
LCD_WriteReg(0x0052, 0x0000);
LCD_WriteReg(0x0053, 0x013F);
LCD_WriteReg(0x0060, 0x2700);
LCD_WriteReg(0x0061, 0x0001);
LCD_WriteReg(0x006A, 0x0000);
LCD_WriteReg(0x0080, 0x0000);
LCD_WriteReg(0x0081, 0x0000);
LCD_WriteReg(0x0082, 0x0000);
LCD_WriteReg(0x0083, 0x0000);
LCD_WriteReg(0x0084, 0x0000);
LCD_WriteReg(0x0085, 0x0000);
LCD_WriteReg(0x0090, 0x0010);
LCD_WriteReg(0x0092, 0x0600);
LCD_WriteReg(0x0007, 0x0133);
}else if(lcddev.id==0x5408)
{
LCD_WriteReg(0x01,0x0100);
LCD_WriteReg(0x02,0x0700);
LCD_WriteReg(0x03,0x1030);
LCD_WriteReg(0x04,0x0000);
LCD_WriteReg(0x08,0x0207);
LCD_WriteReg(0x09,0x0000);
LCD_WriteReg(0x0A,0x0000);
LCD_WriteReg(0x0C,0x0000);
LCD_WriteReg(0x0D,0x0000);
LCD_WriteReg(0x0F,0x0000);
delay_ms(20);
LCD_WriteReg(0x10,0x16B0);
LCD_WriteReg(0x11,0x0001);
LCD_WriteReg(0x17,0x0001);
LCD_WriteReg(0x12,0x0138);
LCD_WriteReg(0x13,0x0800);
LCD_WriteReg(0x29,0x0009);
LCD_WriteReg(0x2a,0x0009);
LCD_WriteReg(0xa4,0x0000);
LCD_WriteReg(0x50,0x0000);
LCD_WriteReg(0x51,0x00EF);
LCD_WriteReg(0x52,0x0000);
LCD_WriteReg(0x53,0x013F);
LCD_WriteReg(0x60,0x2700);
LCD_WriteReg(0x61,0x0001);
LCD_WriteReg(0x6A,0x0000);
LCD_WriteReg(0x80,0x0000);
LCD_WriteReg(0x81,0x0000);
LCD_WriteReg(0x82,0x0000);
LCD_WriteReg(0x83,0x0000);
LCD_WriteReg(0x84,0x0000);
LCD_WriteReg(0x85,0x0000);
LCD_WriteReg(0x90,0x0013);
LCD_WriteReg(0x92,0x0000);
LCD_WriteReg(0x93,0x0003);
LCD_WriteReg(0x95,0x0110);
LCD_WriteReg(0x07,0x0173);
delay_ms(50);
}
else if(lcddev.id==0x1505)
{
LCD_WriteReg(0x0007,0x0000);
delay_ms(50);
LCD_WriteReg(0x0012,0x011C);
LCD_WriteReg(0x00A4,0x0001);
LCD_WriteReg(0x0008,0x000F);
LCD_WriteReg(0x000A,0x0008);
LCD_WriteReg(0x000D,0x0008);
LCD_WriteReg(0x0030,0x0707);
LCD_WriteReg(0x0031,0x0007);
LCD_WriteReg(0x0032,0x0603);
LCD_WriteReg(0x0033,0x0700);
LCD_WriteReg(0x0034,0x0202);
LCD_WriteReg(0x0035,0x0002);
LCD_WriteReg(0x0036,0x1F0F);
LCD_WriteReg(0x0037,0x0707);
LCD_WriteReg(0x0038,0x0000);
LCD_WriteReg(0x0039,0x0000);
LCD_WriteReg(0x003A,0x0707);
LCD_WriteReg(0x003B,0x0000);
LCD_WriteReg(0x003C,0x0007);
LCD_WriteReg(0x003D,0x0000);
delay_ms(50);
LCD_WriteReg(0x0007,0x0001);
LCD_WriteReg(0x0017,0x0001);
delay_ms(50);
LCD_WriteReg(0x0010,0x17A0);
LCD_WriteReg(0x0011,0x0217);
LCD_WriteReg(0x0012,0x011E);
LCD_WriteReg(0x0013,0x0F00);
LCD_WriteReg(0x002A,0x0000);
LCD_WriteReg(0x0029,0x000A);
LCD_WriteReg(0x0012,0x013E);
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00EF);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013F);
LCD_WriteReg(0x0060,0x2700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x006A,0x0000);
LCD_WriteReg(0x0080,0x0000);
LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0082,0x0000);
LCD_WriteReg(0x0083,0x0000);
LCD_WriteReg(0x0084,0x0000);
LCD_WriteReg(0x0085,0x0000);
LCD_WriteReg(0x0090,0x0013);
LCD_WriteReg(0x0092,0x0300);
LCD_WriteReg(0x0093,0x0005);
LCD_WriteReg(0x0095,0x0000);
LCD_WriteReg(0x0097,0x0000);
LCD_WriteReg(0x0098,0x0000);
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700);
LCD_WriteReg(0x0003,0x1038);
LCD_WriteReg(0x0004,0x0000);
LCD_WriteReg(0x000C,0x0000);
LCD_WriteReg(0x000F,0x0000);
LCD_WriteReg(0x0020,0x0000);
LCD_WriteReg(0x0021,0x0000);
LCD_WriteReg(0x0007,0x0021);
delay_ms(20);
LCD_WriteReg(0x0007,0x0061);
delay_ms(20);
LCD_WriteReg(0x0007,0x0173);
delay_ms(20);
}else if(lcddev.id==0xB505)
{
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x00a4,0x0001);
delay_ms(20);
LCD_WriteReg(0x0060,0x2700);
LCD_WriteReg(0x0008,0x0202);
LCD_WriteReg(0x0030,0x0214);
LCD_WriteReg(0x0031,0x3715);
LCD_WriteReg(0x0032,0x0604);
LCD_WriteReg(0x0033,0x0e16);
LCD_WriteReg(0x0034,0x2211);
LCD_WriteReg(0x0035,0x1500);
LCD_WriteReg(0x0036,0x8507);
LCD_WriteReg(0x0037,0x1407);
LCD_WriteReg(0x0038,0x1403);
LCD_WriteReg(0x0039,0x0020);
LCD_WriteReg(0x0090,0x001a);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x0007);
LCD_WriteReg(0x0012,0x0000);
LCD_WriteReg(0x0013,0x0000);
delay_ms(20);
LCD_WriteReg(0x0010,0x0730);
LCD_WriteReg(0x0011,0x0137);
delay_ms(20);
LCD_WriteReg(0x0012,0x01b8);
delay_ms(20);
LCD_WriteReg(0x0013,0x0f00);
LCD_WriteReg(0x002a,0x0080);
LCD_WriteReg(0x0029,0x0048);
delay_ms(20);
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700);
LCD_WriteReg(0x0003,0x1038);
LCD_WriteReg(0x0008,0x0202);
LCD_WriteReg(0x000a,0x0000);
LCD_WriteReg(0x000c,0x0000);
LCD_WriteReg(0x000d,0x0000);
LCD_WriteReg(0x000e,0x0030);
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00ef);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013f);
LCD_WriteReg(0x0060,0x2700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x006a,0x0000);
//LCD_WriteReg(0x0080,0x0000);
//LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0090,0X0011);
LCD_WriteReg(0x0092,0x0600);
LCD_WriteReg(0x0093,0x0402);
LCD_WriteReg(0x0094,0x0002);
delay_ms(20);
LCD_WriteReg(0x0007,0x0001);
delay_ms(20);
LCD_WriteReg(0x0007,0x0061);
LCD_WriteReg(0x0007,0x0173);
LCD_WriteReg(0x0020,0x0000);
LCD_WriteReg(0x0021,0x0000);
LCD_WriteReg(0x00,0x22);
}else if(lcddev.id==0xC505)
{
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
delay_ms(20);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x0000,0x0000);
LCD_WriteReg(0x00a4,0x0001);
delay_ms(20);
LCD_WriteReg(0x0060,0x2700);
LCD_WriteReg(0x0008,0x0806);
LCD_WriteReg(0x0030,0x0703);
LCD_WriteReg(0x0031,0x0001);
LCD_WriteReg(0x0032,0x0004);
LCD_WriteReg(0x0033,0x0102);
LCD_WriteReg(0x0034,0x0300);
LCD_WriteReg(0x0035,0x0103);
LCD_WriteReg(0x0036,0x001F);
LCD_WriteReg(0x0037,0x0703);
LCD_WriteReg(0x0038,0x0001);
LCD_WriteReg(0x0039,0x0004);
LCD_WriteReg(0x0090, 0x0015);
LCD_WriteReg(0x0010, 0X0410);
LCD_WriteReg(0x0011,0x0247);
LCD_WriteReg(0x0012, 0x01BC);
LCD_WriteReg(0x0013, 0x0e00);
delay_ms(120);
LCD_WriteReg(0x0001, 0x0100);
LCD_WriteReg(0x0002, 0x0200);
LCD_WriteReg(0x0003, 0x1030);
LCD_WriteReg(0x000A, 0x0008);
LCD_WriteReg(0x000C, 0x0000);
LCD_WriteReg(0x000E, 0x0020);
LCD_WriteReg(0x000F, 0x0000);
LCD_WriteReg(0x0020, 0x0000);
LCD_WriteReg(0x0021, 0x0000);
LCD_WriteReg(0x002A,0x003D);
delay_ms(20);
LCD_WriteReg(0x0029, 0x002d);
LCD_WriteReg(0x0050, 0x0000);
LCD_WriteReg(0x0051, 0xD0EF);
LCD_WriteReg(0x0052, 0x0000);
LCD_WriteReg(0x0053, 0x013F);
LCD_WriteReg(0x0061, 0x0000);
LCD_WriteReg(0x006A, 0x0000);
LCD_WriteReg(0x0092,0x0300);
LCD_WriteReg(0x0093, 0x0005);
LCD_WriteReg(0x0007, 0x0100);
}else if(lcddev.id==0x8989)
{
LCD_WriteReg(0x0000,0x0001);
LCD_WriteReg(0x0003,0xA8A4);
LCD_WriteReg(0x000C,0x0000);
LCD_WriteReg(0x000D,0x080C);
LCD_WriteReg(0x000E,0x2B00);
LCD_WriteReg(0x001E,0x00B0);
LCD_WriteReg(0x0001,0x2B3F);
LCD_WriteReg(0x0002,0x0600);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x6078);
LCD_WriteReg(0x0005,0x0000);
LCD_WriteReg(0x0006,0x0000);
LCD_WriteReg(0x0016,0xEF1C);
LCD_WriteReg(0x0017,0x0003);
LCD_WriteReg(0x0007,0x0233);
LCD_WriteReg(0x000B,0x0000);
LCD_WriteReg(0x000F,0x0000);
LCD_WriteReg(0x0041,0x0000);
LCD_WriteReg(0x0042,0x0000);
LCD_WriteReg(0x0048,0x0000);
LCD_WriteReg(0x0049,0x013F);
LCD_WriteReg(0x004A,0x0000);
LCD_WriteReg(0x004B,0x0000);
LCD_WriteReg(0x0044,0xEF00);
LCD_WriteReg(0x0045,0x0000);
LCD_WriteReg(0x0046,0x013F);
LCD_WriteReg(0x0030,0x0707);
LCD_WriteReg(0x0031,0x0204);
LCD_WriteReg(0x0032,0x0204);
LCD_WriteReg(0x0033,0x0502);
LCD_WriteReg(0x0034,0x0507);
LCD_WriteReg(0x0035,0x0204);
LCD_WriteReg(0x0036,0x0204);
LCD_WriteReg(0x0037,0x0502);
LCD_WriteReg(0x003A,0x0302);
LCD_WriteReg(0x003B,0x0302);
LCD_WriteReg(0x0023,0x0000);
LCD_WriteReg(0x0024,0x0000);
LCD_WriteReg(0x0025,0x8000);
LCD_WriteReg(0x004f,0);
LCD_WriteReg(0x004e,0);
}else if(lcddev.id==0x4531)
{
LCD_WriteReg(0X00,0X0001);
delay_ms(10);
LCD_WriteReg(0X10,0X1628);
LCD_WriteReg(0X12,0X000e);
LCD_WriteReg(0X13,0X0A39);
delay_ms(10);
LCD_WriteReg(0X11,0X0040);
LCD_WriteReg(0X15,0X0050);
delay_ms(10);
LCD_WriteReg(0X12,0X001e);
delay_ms(10);
LCD_WriteReg(0X10,0X1620);
LCD_WriteReg(0X13,0X2A39);
delay_ms(10);
LCD_WriteReg(0X01,0X0100);
LCD_WriteReg(0X02,0X0300);
LCD_WriteReg(0X03,0X1038);
LCD_WriteReg(0X08,0X0202);
LCD_WriteReg(0X0A,0X0008);
LCD_WriteReg(0X30,0X0000);
LCD_WriteReg(0X31,0X0402);
LCD_WriteReg(0X32,0X0106);
LCD_WriteReg(0X33,0X0503);
LCD_WriteReg(0X34,0X0104);
LCD_WriteReg(0X35,0X0301);
LCD_WriteReg(0X36,0X0707);
LCD_WriteReg(0X37,0X0305);
LCD_WriteReg(0X38,0X0208);
LCD_WriteReg(0X39,0X0F0B);
LCD_WriteReg(0X41,0X0002);
LCD_WriteReg(0X60,0X2700);
LCD_WriteReg(0X61,0X0001);
LCD_WriteReg(0X90,0X0210);
LCD_WriteReg(0X92,0X010A);
LCD_WriteReg(0X93,0X0004);
LCD_WriteReg(0XA0,0X0100);
LCD_WriteReg(0X07,0X0001);
LCD_WriteReg(0X07,0X0021);
LCD_WriteReg(0X07,0X0023);
LCD_WriteReg(0X07,0X0033);
LCD_WriteReg(0X07,0X0133);
LCD_WriteReg(0XA0,0X0000);
}else if(lcddev.id==0x4535)
{
LCD_WriteReg(0X15,0X0030);
LCD_WriteReg(0X9A,0X0010);
LCD_WriteReg(0X11,0X0020);
LCD_WriteReg(0X10,0X3428);
LCD_WriteReg(0X12,0X0002);
LCD_WriteReg(0X13,0X1038);
delay_ms(40);
LCD_WriteReg(0X12,0X0012);
delay_ms(40);
LCD_WriteReg(0X10,0X3420);
LCD_WriteReg(0X13,0X3038);
delay_ms(70);
LCD_WriteReg(0X30,0X0000);
LCD_WriteReg(0X31,0X0402);
LCD_WriteReg(0X32,0X0307);
LCD_WriteReg(0X33,0X0304);
LCD_WriteReg(0X34,0X0004);
LCD_WriteReg(0X35,0X0401);
LCD_WriteReg(0X36,0X0707);
LCD_WriteReg(0X37,0X0305);
LCD_WriteReg(0X38,0X0610);
LCD_WriteReg(0X39,0X0610);
LCD_WriteReg(0X01,0X0100);
LCD_WriteReg(0X02,0X0300);
LCD_WriteReg(0X03,0X1030);
LCD_WriteReg(0X08,0X0808);
LCD_WriteReg(0X0A,0X0008);
LCD_WriteReg(0X60,0X2700);
LCD_WriteReg(0X61,0X0001);
LCD_WriteReg(0X90,0X013E);
LCD_WriteReg(0X92,0X0100);
LCD_WriteReg(0X93,0X0100);
LCD_WriteReg(0XA0,0X3000);
LCD_WriteReg(0XA3,0X0010);
LCD_WriteReg(0X07,0X0001);
LCD_WriteReg(0X07,0X0021);
LCD_WriteReg(0X07,0X0023);
LCD_WriteReg(0X07,0X0033);
LCD_WriteReg(0X07,0X0133);
}
LCD_Display_Dir(1);
LCD_LED=1;
LCD_Clear(WHITE);
}
void LCD_Clear(u16 color)
{
u32 index=0;
u32 totalpoint=lcddev.width;
totalpoint*=lcddev.height;
LCD_SetCursor(0x00,0x0000);
LCD_WriteRAM_Prepare();
for(index=0;index<totalpoint;index++)
{
LCD->LCD_RAM=color;
}
}
void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color)
{
u16 i,j;
u16 xlen=0;
xlen=ex-sx+1;
for(i=sy;i<=ey;i++)
{
LCD_SetCursor(sx,i);
LCD_WriteRAM_Prepare();
for(j=0;j<xlen;j++)LCD_WR_DATA(color);
}
}
void LCD_Color_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 *color)
{
u16 height,width;
u16 i,j;
width=ex-sx+1;
height=ey-sy+1;
for(i=0;i<height;i++)
{
LCD_SetCursor(sx,sy+i);
LCD_WriteRAM_Prepare();
for(j=0;j<width;j++)LCD->LCD_RAM=color[i*height+j];
}
}
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2)
{
u16 t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy,uRow,uCol;
delta_x=x2-x1;
delta_y=y2-y1;
uRow=x1;
uCol=y1;
if(delta_x>0)incx=1;
else if(delta_x==0)incx=0;
else {incx=-1;delta_x=-delta_x;}
if(delta_y>0)incy=1;
else if(delta_y==0)incy=0;
else{incy=-1;delta_y=-delta_y;}
if( delta_x>delta_y)distance=delta_x;
else distance=delta_y;
for(t=0;t<=distance+1;t++ )
{
LCD_DrawPoint(uRow,uCol);
xerr+=delta_x ;
yerr+=delta_y ;
if(xerr>distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr>distance)
{
yerr-=distance;
uCol+=incy;
}
}
}
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2)
{
LCD_DrawLine(x1,y1,x2,y1);
LCD_DrawLine(x1,y1,x1,y2);
LCD_DrawLine(x1,y2,x2,y2);
LCD_DrawLine(x2,y1,x2,y2);
}
void Draw_Circle(u16 x0,u16 y0,u8 r)
{
int a,b;
int di;
a=0;b=r;
di=3-(r<<1);
while(a<=b)
{
LCD_DrawPoint(x0+a,y0-b);
LCD_DrawPoint(x0+b,y0-a);
LCD_DrawPoint(x0+b,y0+a);
LCD_DrawPoint(x0+a,y0+b);
LCD_DrawPoint(x0-a,y0+b);
LCD_DrawPoint(x0-b,y0+a);
LCD_DrawPoint(x0-a,y0-b);
LCD_DrawPoint(x0-b,y0-a);
a++;
if(di<0)di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
}
}
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode)
{
u8 temp,t1,t;
u16 y0=y;
u16 colortemp=POINT_COLOR;
num=num-' ';
if(!mode)
{
for(t=0;t<size;t++)
{
if(size==12)temp=asc2_1206[num][t];
else temp=asc2_1608[num][t];
for(t1=0;t1<8;t1++)
{
if(temp&0x80)POINT_COLOR=colortemp;
else POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x,y);
temp<<=1;
y++;
if(x>=lcddev.width){POINT_COLOR=colortemp;return;}
if((y-y0)==size)
{
y=y0;
x++;
if(x>=lcddev.width){POINT_COLOR=colortemp;return;}
break;
}
}
}
}else
{
for(t=0;t<size;t++)
{
if(size==12)temp=asc2_1206[num][t];
else temp=asc2_1608[num][t];
for(t1=0;t1<8;t1++)
{
if(temp&0x80)LCD_DrawPoint(x,y);
temp<<=1;
y++;
if(x>=lcddev.height){POINT_COLOR=colortemp;return;}
if((y-y0)==size)
{
y=y0;
x++;
if(x>=lcddev.width){POINT_COLOR=colortemp;return;}
break;
}
}
}
}
POINT_COLOR=colortemp;
}
u32 LCD_Pow(u8 m,u8 n)
{
u32 result=1;
while(n--)result*=m;
return result;
}
void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size)
{
u8 t,temp;
u8 enshow=0;
for(t=0;t<len;t++)
{
temp=(num/LCD_Pow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
LCD_ShowChar(x+(size/2)*t,y,' ',size,0);
continue;
}else enshow=1;
}
LCD_ShowChar(x+(size/2)*t,y,temp+'0',size,0);
}
}
void LCD_ShowxNum(u16 x,u16 y,u32 num,u8 len,u8 size,u8 mode)
{
u8 t,temp;
u8 enshow=0;
for(t=0;t<len;t++)
{
temp=(num/LCD_Pow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
if(mode&0X80)LCD_ShowChar(x+(size/2)*t,y,'0',size,mode&0X01);
else LCD_ShowChar(x+(size/2)*t,y,' ',size,mode&0X01);
continue;
}else enshow=1;
}
LCD_ShowChar(x+(size/2)*t,y,temp+'0',size,mode&0X01);
}
}
void LCD_ShowString(u16 x,u16 y,u16 width,u16 height,u8 size,u8 *p)
{
u8 x0=x;
width+=x;
height+=y;
while((*p<='~')&&(*p>=' '))
{
if(x>=width){x=x0;y+=size;}
if(y>=height)break;
LCD_ShowChar(x,y,*p,size,0);
x+=size/2;
p++;
}
} |
|