#include"gui.h"
9 l7 E( K% `( @4 W' g
//---汉字的字库头文件---//
#include"charcode.h"
1 q5 r7 ]+ ?" e0 l
//---如果要显示图片就添加这个头文件---//
#ifdef PICTURE_SHOW
7 i+ w; S# {- O
#include"picture.h"
: r# O) M& ~1 A, s5 l( i% m& f
#endif
1 k' x1 J+ @) n3 P6 s8 O" @' u# N
/****************************************************************************
*函数名:GUI_Dot
*输 入:x:点的X坐标;
* * y:点的Y坐标
* * color:点的颜色
*输 出:
*功 能:给单个像素涂上颜色。
****************************************************************************/
8 T6 }* ?2 ?9 o; \( J6 q H0 _
void GUI_Dot(uint x, uint y, uint color)
{
uchar i;
$ B9 [! {) J, }5 d+ E8 l6 r6 A
TFT_SetWindow(x-1, y, x+2, y+2); //单个像素
! K6 \" D- Y9 F1 V* o$ F
for(i=0; i<16; i++)
{
TFT_WriteColorData(color) ;
//TFT_WriteData(color);
}
}
! g' M8 N) ^% B4 g. @
///****************************************************************************
//*函数名:GUI_Box
//*输 入:sx:起始X坐标, sy:其实Y坐标,
//* * ex:终止X坐标, ey:终止Y坐标,
//* * color:方框的颜色
//*输 出:
//*功 能:给一个区域涂上颜色。
//****************************************************************************/
//void GUI_Box(uint sx, uint sy, uchar ex, uint ey, uint color)
//{
// uint temp;
// TFT_SetWindow(sx, sy, ex, ey);
// sx = ex - sx + 1;
// sy = ey - sy + 1;
// while (sx--)
// {
// temp = sy;
// while (temp--)
// {
// TFT_WriteData(color);
// }
// }
//}
' `* m. n1 h- r3 M
/****************************************************************************
*函数名:GUI_Line
*输 入:xStart:线的起始X坐标,
* * yStart:线的其实Y坐标,
* * xEnd:线的终止X坐标,
* * yEnd:线的终止Y坐标,
* * color:线条的颜色
*输 出:
*功 能:画一条直线
****************************************************************************/
9 }, I$ i7 v0 c+ E
void GUI_Line(uint xStart, uint yStart, uchar xEnd, uint yEnd, uint color)
{
uint t;
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
int incx, incy;
uint row, col;
delta_x = xEnd - xStart;//计算坐标增量
delta_y = yEnd - yStart;
col = xStart;
row = yStart;
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++)
{ //画线输出
GUI_Dot(col, row, color);
xerr += delta_x;
yerr += delta_y;
if(xerr > distance)
{
xerr -= distance;
col += incx;
}
if(yerr > distance)
{
yerr -= distance;
row += incy;
}
}
}
: P. o; E- Q( `8 e/ ~
/****************************************************************************
*函数名:GUI_WriteCnChar
*输 入:x:显示起始X坐标
* * y:显示起始Y坐标
* * *cn:要显示的字符串
* * wordColor:字体的颜色
* * backColor:背景颜色
*输 出:
*功 能:写二号楷体汉字
****************************************************************************/
( T3 |, v1 S& L* i+ G5 i( B- ^
#ifdef CHAR32_SHOW
0 w; [' s% e4 m8 c. ]
void GUI_Write32CnChar(uint x, uint y, uchar *cn, uint wordColor, uint backColor)
: h# J3 W1 V L* e& O
…………限于本文篇幅 余下代码请下载附件…………
: d& r( m8 `) P" L0 O
' _& L. w6 q5 W c- N! C