void LCD_WR_DATA8(char VH,char VL) //·¢ËÍÊý¾Ý-8λ²ÎÊý
{
SetLCDRS(); //RS=1;
delayms(1);
LCD_Writ_Bus(VH,VL);
}
void LCD_WR_DATA(int16_t da)
{
SetLCDRS();
delayms(1);
LCD_Writ_Bus(da>>8,da);
}
void LCD_WR_REG(int16_t da)
{
ResetLCDRS();
delayms(1);
LCD_Writ_Bus(da>>8,da);
}
void LCD_WR_REG_DATA(int16_t reg,int16_t da)
{
LCD_WR_REG(reg);
LCD_WR_DATA(da);
}
void Address_set(uint16_t startx,uint16_t starty,uint16_t endx,uint16_t endy)
{
// LCD_WR_REG_DATA(0x0044,x2+(y2<<8));
uint16_t temp=(endx<<8)|startx;
LCD_WR_REG_DATA(0x0044,temp);
// LCD_WR_REG_DATA(0x0044,0x2878);
LCD_WR_REG_DATA(0x0045,starty);
LCD_WR_REG_DATA(0x0046,endy);
SetCursor(startx,starty);
LCD_WR_REG(0x0022);
}
void Lcd_Init(void)
{
uint8_t tempdata;
SetCS();
/*tempdata=GPIO_Read_bit(GPIOC,GPIO_Pin_9); //Ð轫PC9 ÉèÖóÉÊäÈëģʽ
if(tempdata==0)
{
LCD_WR_REG_DATA(0,0);
LCD_ShowString(0,0," ");
LCD_ShowNum(0,0,0,0);
LCD_Show2Num(0,0,0,0);
LCD_DrawPoint_big(0,0);
LCD_DrawRectangle(0,0,0,0);
Draw_Circle(0,0,0);
}*/
// delayms(5);
Set();
delayms(5);
Reset(); //LCD_Reset=0;
delayms(5);
// delayms(5);
Set(); //LCD_Reset=1;
SetCS();
SetRD();
SetLCDWR();
Delay(5);
ResetCS();
/*Reset(); //LCD_Reset=0;
delayms(50);
Set(); //LCD_Reset=1;
delayms(50);
SetCS();
SetRD();
SetLCDWR();*/
ResetCS();
LCD_WR_REG_DATA(0x0000,0x0001); delayms(1); //´ò¿ª¾§Õñ
LCD_WR_REG_DATA(0x0003,0xA8A4); delayms(1); //0xA8A4
LCD_WR_REG_DATA(0x000C,0x0000); delayms(1);
LCD_WR_REG_DATA(0x000D,0x080C); delayms(1);
LCD_WR_REG_DATA(0x000E,0x2B00); delayms(1);
LCD_WR_REG_DATA(0x001E,0x00B7); delayms(1);
LCD_WR_REG_DATA(0x0001,0x2B3F); delayms(1); //Çý¶¯Êä³ö¿ØÖÆ320*240 0x6B3F
LCD_WR_REG_DATA(0x0002,0x0600); delayms(1);
LCD_WR_REG_DATA(0x0010,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0011,0x6070); delayms(1); //0x4030 //¶¨ÒåÊý¾Ý¸ñʽ 16λɫ
LCD_WR_REG_DATA(0x0005,0x0000); delayms(1); ;
LCD_WR_REG_DATA(0x0006,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0016,0xEF1C); delayms(1);
LCD_WR_REG_DATA(0x0017,0x0003); delayms(1);
LCD_WR_REG_DATA(0x0007,0x0233); delayms(1); //0x0233
LCD_WR_REG_DATA(0x000B,0x0000); delayms(1);
LCD_WR_REG_DATA(0x000F,0x0000); delayms(1); //ɨÃ迪ʼµØÖ·
LCD_WR_REG_DATA(0x0041,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0042,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0048,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0049,0x013F); delayms(1);
LCD_WR_REG_DATA(0x004A,0x0000); delayms(1);
LCD_WR_REG_DATA(0x004B,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0044,0xEF00); delayms(1);
LCD_WR_REG_DATA(0x0045,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0046,0x013F); delayms(1);
LCD_WR_REG_DATA(0x0030,0x0707); delayms(1);
LCD_WR_REG_DATA(0x0031,0x0204); delayms(1);
LCD_WR_REG_DATA(0x0032,0x0204); delayms(1);
LCD_WR_REG_DATA(0x0033,0x0502); delayms(1);
LCD_WR_REG_DATA(0x0034,0x0507); delayms(1);
LCD_WR_REG_DATA(0x0035,0x0204); delayms(1);
LCD_WR_REG_DATA(0x0036,0x0204); delayms(1);
LCD_WR_REG_DATA(0x0037,0x0502); delayms(1);
LCD_WR_REG_DATA(0x003A,0x0302); delayms(1);
LCD_WR_REG_DATA(0x003B,0x0302); delayms(1);
LCD_WR_REG_DATA(0x0023,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0024,0x0000); delayms(1);
LCD_WR_REG_DATA(0x0025,0x8000); delayms(1);
LCD_WR_REG_DATA(0x004f,0); //ÐÐÊ×Ö·0
LCD_WR_REG_DATA(0x004e,0); //ÁÐÊ×Ö·0
LCD_WR_REG(0x0022);
}
void SetCursor(uint16_t x,uint16_t y)
{
LCD_WR_REG_DATA(0x004e,y); //ÁÐÐÊ×µØÖ·
LCD_WR_REG_DATA(0x004f,x); //ÐÐÊ×µØÖ·
}
//ÇåÆÁº¯Êý
//Color:ÒªÇåÆÁµÄÌî³äÉ«
void LCD_Clear(uint16_t Color)
{
uint8_t VH,VL;
uint16_t i,j;
VH=Color>>8;
VL=Color;
// Address_set(80,120,80,240); //startx starty endx endy ÎÞÏÖÏó
// Address_set(0,120,0,240); //startx starty endx endy ÎÞÃ÷ÏÔÏÖÏó
// Address_set(0,80,0,80); //startx starty endx endy ÎÞÃ÷ÏÔÏÖÏó
// Address_set(0,0,239,319); //startx starty endx endy °ëÆÁË¢³ö
// Address_set(0,0,80,80); //startx starty endx endy ´Ó00 ¿ªÊ¼ Ë¢³ö80*80µÄ·½ÐÎ
// Address_set(0,0,140,80); //startx starty endx endy ֻˢ³ö×ó²àÒ»µã ´óÔ¼20*80
// Address_set(0,0,120,80); //startx starty endx endy ´Ó0 0¿ªÊ¼Ë¢³ö120*80
// Address_set(0,0,128,80); //×ó²àË¢³ö8*80µÄС±ß¿ò
Address_set(0,0,239,319); //startx starty endx endy °ëÆÁË¢³ö
for(i=0;i<240;i++)
{
for (j=0;j<320;j++)
{
LCD_WR_DATA8(VH,VL);
// Delay(100);
}
}
}
//ÔÚÖ¸¶¨Î»ÖÃÏÔʾһ¸öºº×Ö(32*33´óС)
//dcolorΪÄÚÈÝÑÕÉ«£¬gbcolorΪ±³¾²ÑÕÉ«
void showhanzi(uint16_t x,uint16_t y,uint16_t index)
{
uint8_t i,j;
uint8_t *temp=hanzi;
Address_set(x,y,x+31,y+31); //ÉèÖÃÇøÓò
temp+=index*128;
for(j=0;j<128;j++)
{
for(i=0;i<8;i++)
{
if((*temp&(1<<i))!=0)
{
LCD_WR_DATA(POINT_COLOR);
}
else
{
LCD_WR_DATA(BACK_COLOR);
}
}
temp++;
}
}