#include"gui.h"
) y% h u1 c0 i. P
//---汉字的字库头文件---//
#include"charcode.h"
% N+ T* F+ ~5 ]$ r% i7 {" \* {% j$ g. I
//---如果要显示图片就添加这个头文件---//
#ifdef PICTURE_SHOW
! B7 d+ c8 ?5 d( U* m
#include"picture.h"
% q0 F( V! i' r
#endif
' E1 A! e( O! v
/****************************************************************************
*函数名:GUI_Dot
*输 入:x:点的X坐标;
* * y:点的Y坐标
* * color:点的颜色
*输 出:
*功 能:给单个像素涂上颜色。
****************************************************************************/
! S3 t7 B7 ~ h4 f4 d5 K7 L) b
void GUI_Dot(uint x, uint y, uint color)
{
uchar i;
$ ]3 K2 J% {2 }1 i* W2 H
TFT_SetWindow(x-1, y, x+2, y+2); //单个像素
! M/ n. M; c: M A; p
for(i=0; i<16; i++)
{
TFT_WriteColorData(color) ;
//TFT_WriteData(color);
}
}
" Y$ ^4 Z* V! d* I
///****************************************************************************
//*函数名: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);
// }
// }
//}
! R1 G8 d3 w3 P0 _0 k. h
/****************************************************************************
*函数名:GUI_Line
*输 入:xStart:线的起始X坐标,
* * yStart:线的其实Y坐标,
* * xEnd:线的终止X坐标,
* * yEnd:线的终止Y坐标,
* * color:线条的颜色
*输 出:
*功 能:画一条直线
****************************************************************************/
# k: x4 L4 @& U- V( l( T3 k# `/ @! O
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;
}
}
}
. O: ?; p, J0 a* l* r5 n
/****************************************************************************
*函数名:GUI_WriteCnChar
*输 入:x:显示起始X坐标
* * y:显示起始Y坐标
* * *cn:要显示的字符串
* * wordColor:字体的颜色
* * backColor:背景颜色
*输 出:
*功 能:写二号楷体汉字
****************************************************************************/
; i5 f. ~ T( D R) {1 M; h5 e
#ifdef CHAR32_SHOW
9 @* s& w# J( \
void GUI_Write32CnChar(uint x, uint y, uchar *cn, uint wordColor, uint backColor)
) B1 |; G4 B; Y2 A
…………限于本文篇幅 余下代码请下载附件…………
7 {/ E; }" s% E; |! @" y
6 A# q7 u# J, c) Y( X; M0 B; e