LCD_Write_COM(0x00,0x29);LCD_Write_DATA(0x00,0x27);//0x0012//001aSetVCM[5:0]forVCOMH//0x00250034
LCD_Write_COM(0x00,0x2B);LCD_Write_DATA(0x00,0x0D);//SetFrameRate000C
delayms(50);//Delay50ms
LCD_Write_COM(0x00,0x20);LCD_Write_DATA(0x00,0x00);//GRAMhorizontalAddress
LCD_Write_COM(0x00,0x21);LCD_Write_DATA(0x00,0x00);//GRAMVerticalAddress
//-----------AdjusttheGammaCurve----------//
LCD_Write_COM(0x00,0x30);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x31);LCD_Write_DATA(0x07,0x07);
LCD_Write_COM(0x00,0x32);LCD_Write_DATA(0x03,0x07);
LCD_Write_COM(0x00,0x35);LCD_Write_DATA(0x02,0x00);
LCD_Write_COM(0x00,0x36);LCD_Write_DATA(0x00,0x08);//0207
LCD_Write_COM(0x00,0x37);LCD_Write_DATA(0x00,0x04);//0306
LCD_Write_COM(0x00,0x38);LCD_Write_DATA(0x00,0x00);//0102
LCD_Write_COM(0x00,0x39);LCD_Write_DATA(0x07,0x07);//0707
LCD_Write_COM(0x00,0x3C);LCD_Write_DATA(0x00,0x02);//0702
LCD_Write_COM(0x00,0x3D);LCD_Write_DATA(0x1D,0x04);//1604
//------------------SetGRAMarea---------------//
LCD_Write_COM(0x00,0x50);LCD_Write_DATA(0x00,0x00);//HorizontalGRAMStartAddress
LCD_Write_COM(0x00,0x51);LCD_Write_DATA(0x00,0xEF);//HorizontalGRAMEndAddress
LCD_Write_COM(0x00,0x52);LCD_Write_DATA(0x00,0x00);//VerticalGRAMStartAddress
LCD_Write_COM(0x00,0x53);LCD_Write_DATA(0x01,0x3F);//VerticalGRAMStartAddress
LCD_Write_COM(0x00,0x60);LCD_Write_DATA(0xA7,0x00);//GateScanLine
LCD_Write_COM(0x00,0x61);LCD_Write_DATA(0x00,0x01);//NDL,VLE,REV
LCD_Write_COM(0x00,0x6A);LCD_Write_DATA(0x00,0x00);//setscrollingline
//--------------PartialDisplayControl---------//
LCD_Write_COM(0x00,0x80);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x81);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x82);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x83);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x84);LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x85);LCD_Write_DATA(0x00,0x00);
//--------------PanelControl-------------------//
LCD_Write_COM(0x00,0x90);LCD_Write_DATA(0x00,0x10);
LCD_Write_COM(0x00,0x92);LCD_Write_DATA(0x06,0x00);
LCD_Write_COM(0x00,0x07);LCD_Write_DATA(0x01,0x33);//262KcoloranddisplayON
LCD_cs(1);//关闭片选使能
}
voiddelayms(intcount)//
{
inti,j;
for(i=0;ifor(j=0;j<100;j++);
}
#ifdefBus_16//条件编译-16位数据模式
voidLCD_Writ_Bus(uintVH,uintVL)//并行数据写入函数
{
//LCD_DataPortH=VH;//高位P1口
//屏蔽高8位将数据送到PA0-PA7
GPIOA->BSRR=VH&0x00ff;
GPIOA->BRR=(~VH)&0x00ff;
//GPIO_SetBits(GPIOA,VH&0x00ff);
//GPIO_ResetBits(GPIOA,(~VH&0x00ff));
//LCD_DataPortL=VL;//低位P0口
//屏蔽低8位将数据送到PB8-PB15
GPIOB->BSRR=(VL)<8&0xff00;
GPIOB->BRR=((~VL)<8)&0xff00;
LCD_wr(0);
LCD_wr(1);
}
#else//条件编译-8位数据模式
voidLCD_Writ_Bus(charVH,charVL)//并行数据写入函数
{
//LCD_DataPortH=VH;//八位模式都用P0口送数据
//LCD_wr(0);
//LCD_wr(1);
//LCD_DataPortH=VL;//八位模式都用P0口送数据
//LCD_wr(0);
//LCD_wr(1);
}
#endif
voidLCD_Write_COM(charVH,charVL)//发送命令
{
LCD_rs(0);
LCD_Writ_Bus(VH,VL);
}
voidLCD_Write_DATA(charVH,charVL)//发送数据
{
LCD_rs(1);
LCD_Writ_Bus(VH,VL);
}
voidPant(charVH,charVL)//涂满全屏函数
{
inti,j;
LCD_cs(0);//打开片选使能
Address_set(0,0,239,319);
for(i=0;i<320;i++)
{
for(j=0;j<240;j++)
{
LCD_Write_DATA(VH,VL);
}
}
LCD_cs(1);//关闭片选使能
}
voidAddress_set(unsignedintx1,unsignedinty1,unsignedintx2,unsignedinty2)//设置地址范围函数
{
LCD_Write_COM(0x00,0x20);LCD_Write_DATA(x1>>8,x1);//设置X坐标位置
LCD_Write_COM(0x00,0x21);LCD_Write_DATA(y1>>8,y1);//设置Y坐标位置
LCD_Write_COM(0x00,0x50);LCD_Write_DATA(x1>>8,x1);//开始X
LCD_Write_COM(0x00,0x52);LCD_Write_DATA(y1>>8,y1);//开始Y
LCD_Write_COM(0x00,0x51);LCD_Write_DATA(x2>>8,x2);//结束X
LCD_Write_COM(0x00,0x53);LCD_Write_DATA(y2>>8,y2);//结束Y
LCD_Write_COM(0x00,0x22);
}
voidpic_play(uintStart_X,uintEnd_X,uintStart_Y,uintEnd_Y)
{
uintm;
//LCD_CS=0;