微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > arm之TFT

arm之TFT

时间:11-26 来源:互联网 点击:

LCD_DisplayPoint(Xpos + CurY, Ypos + CurX, TextColor);
LCD_DisplayPoint(Xpos + CurY, Ypos - CurX, TextColor);
LCD_DisplayPoint(Xpos - CurY, Ypos + CurX, TextColor);
LCD_DisplayPoint(Xpos - CurY, Ypos - CurX, TextColor);

if (D < 0)
{
D += (CurX < 2) + 6;
}
else
{
D += ((CurX - CurY) < 2) + 10;
CurY--;
}
CurX++;
}
}

void LCD_DrawLine(u8 Xpos, u16 Ypos, u16 Length, u8 Direction)
{
u32 i = 0;

//LCD_Display_Color(BackColor);

if(Direction == Horizontal)
{
for(i = 0; i < Length; i++)
{
LCD_DisplayPoint(Xpos+i, Ypos, TextColor);
}
}
else
{
for(i = 0; i < Length; i++)
{
LCD_DisplayPoint(Xpos, Ypos+i, TextColor);
}
}
}

void LCD_DrawRect(u8 Xpos, u16 Ypos, u8 Height, u16 Width)
{
LCD_DrawLine(Xpos, Ypos, Width, Horizontal);
LCD_DrawLine(Xpos , (Ypos + Height), Width, Horizontal);

LCD_DrawLine(Xpos, Ypos, Height, Vertical);
LCD_DrawLine((Xpos + Width), Ypos, Height, Vertical);
}

void LCD_DrawPict(const u8 *Pict)
{
u32 index = 0, i = 0;
const u8 *pu8Temp = Pict;

LCD_SelectRegion(0, 0, 0x7f, 0xff);

for(index = 0; index < 160; index++)
{
for(i = 0; i < 128; i++)
{
LCD_WriteDat(*(pu8Temp+1));
LCD_WriteDat(*pu8Temp);
pu8Temp += 2;
}
}

}

void LCD_DrawBarGraph(int pos_x, int pos_y, int value)
{

int i,j;

int iPosX = pos_x*XPIXES;
int iPosY = pos_y*YPIXES;

LCD_ClearLine(pos_y);

//value 0 ~ 16*8
for (i = 0; i < 26; i++)//26 * 5 ~ 128
{
if (value > 5)
{
//lcd_putchar (0x05);
LCD_SelectRegion(iPosX, iPosY, iPosX+4 ,iPosY + YPIXES-1);
for(j=0; j{
LCD_WriteDat(TextColor>>8);
LCD_WriteDat(TextColor&0xff);
}
iPosX += 8;
value -= 8;//5;
}
else
{
if(value < 0)
{
break;
}
LCD_SelectRegion(iPosX, iPosY, iPosX+value-1 ,iPosY + YPIXES);
for(j=0; j{
LCD_WriteDat(TextColor>>8);
LCD_WriteDat(TextColor&0xff);
}
break;
}
}

}

void Lcd_DspHz16(u8 Line, u8 Column, u8 *Pu8FontStr)
{
u16 i,j,k,x,y,xx,iOffStr;
u8 qm,wm,x0,y0;
u32 ulOffset;
u8 hzbuf[72],u8Mode;

x0 = Column*16;//x coordinate of start point
y0 = Line*16;//y coordinate of start point

for(iOffStr = 0; iOffStr < strlen((const char*)Pu8FontStr); )
{
x0 = iOffStr*8;
if(((u8)(*(Pu8FontStr+iOffStr))) < 161)//?? ascii coding ?
{
if ( (u8)(*(Pu8FontStr+iOffStr)) > 127 )
{
break;
}
LCD_DisplayChar(y0, x0, *(Pu8FontStr+iOffStr));
iOffStr++;//ascii only occupy one byte
}
else
{
//get the zone and the position.
qm = *(Pu8FontStr+iOffStr) - 160;//161;
wm = *(Pu8FontStr+iOffStr+1) - 160;
ulOffset = (u32)((qm-1)*94 + wm-1) * 32;

//count the offset in spi flash . then read one 32 Byte from spi flash, put info into hzbuf
SPI_FLASH_BufferRead(hzbuf, HZAdsInSpiFlash+ulOffset, HZbuffsize);

//diaplay all the info.
for(i=0; i<16; i++)
{
for(j=0; j<2; j++)
{
u8Mode = hzbuf[i*2+j];//get the FONT mode
for(k=0; k<8; k++)
{
if( u8Mode & (0x80>>k))
{
LCD_DisplayPoint(x0+j*8+k, y0+i, TextColor);
}
}
}
}
iOffStr += 2;
}
}
}
//显示一个变量的值,variate的值可发生变化
void Display_variate(u8 Line, u8 Column, u16 variate)
{
int cnt,reg[4];
reg[3]=variate;
reg[2]=variate/10;
reg[1]=variate/100;
reg[0]=variate/1000;
LCD_DisplayChar(Line,Column+8*cnt,1);
for(cnt=0;cnt<=3;cnt++)
{if(cnt==1)
{
LCD_DisplayChar(Line,Column+8,.);
}
if(cnt==0)
switch(reg[cnt])
{
case 1:LCD_DisplayChar(Line,Column,1); break;
case 2:LCD_DisplayChar(Line,Column,2); break;
case 3:LCD_DisplayChar(Line,Column,3); break;
case 4:LCD_DisplayChar(Line,Column,4); break;
case 5:LCD_DisplayChar(Line,Column,5); break;
case 6:LCD_DisplayChar(Line,Column,6); break;
case 7:LCD_DisplayChar(Line,Column,7); break;
case 8:LCD_DisplayChar(Line,Column,8); break;
case 9:LCD_DisplayChar(Line,Column,9); break;
case 0:LCD_DisplayChar(Line,Column,0); break;
default: break;
}
else
switch(reg[cnt])
{
case 1:LCD_DisplayChar(Line,Column+8*(cnt+1),1); break;
case 2:LCD_DisplayChar(Line,Column+8*(cnt+1),2); break;
case 3:LCD_DisplayChar(Line,Column+8*(cnt+1),3); break;
case 4:LCD_DisplayChar(Line,Column+8*(cnt+1),4); break;
case 5:LCD_DisplayChar(Line,Column+8*(cnt+1),5); break;
case 6:LCD_DisplayChar(Line,Column+8*(cnt+1),6); break;
case 7:LCD_DisplayChar(Line,Column+8*(cnt+1),7); break;
case 8:LCD_DisplayChar(Line,Column+8*(cnt+1),8); break;
case 9:LCD_DisplayChar(Line,Column+8*(cnt+1),9); break;
case 0:LCD_DisplayChar(Line,Column+8*(cnt+1),0); break;
default: break;
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top