#include"gui.h"
0 H/ {! L% C; a+ r& v" {
//---汉字的字库头文件---//
#include"charcode.h"
. @# R1 ^$ E! d# Z) f, j
//---如果要显示图片就添加这个头文件---//
#ifdef PICTURE_SHOW
; L- q0 d) c) ]1 k+ R7 T2 e
#include"picture.h"
e: i' N- I4 y& v7 Q- I
#endif
5 D5 D" x/ u: G4 g& ]7 _/ ^
/****************************************************************************
*函数名:GUI_Dot
*输 入:x:点的X坐标;
* * y:点的Y坐标
* * color:点的颜色
*输 出:
*功 能:给单个像素涂上颜色。
****************************************************************************/
6 d) t: Y* s9 b( D$ s- v
void GUI_Dot(uint x, uint y, uint color)
{
uchar i;
7 k/ I( R, Z7 R3 m
TFT_SetWindow(x-1, y, x+2, y+2); //单个像素
2 |' u: ^" ]2 ]
for(i=0; i<16; i++)
{
TFT_WriteColorData(color) ;
//TFT_WriteData(color);
}
}
9 j% T! q/ F/ c
///****************************************************************************
//*函数名: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);
// }
// }
//}
7 c$ r! n( ~/ j' O7 X* Z' @
/****************************************************************************
*函数名:GUI_Line
*输 入:xStart:线的起始X坐标,
* * yStart:线的其实Y坐标,
* * xEnd:线的终止X坐标,
* * yEnd:线的终止Y坐标,
* * color:线条的颜色
*输 出:
*功 能:画一条直线
****************************************************************************/
( D: Y0 X. f2 ]; s% f% N- n p
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;
}
}
}
8 x, @3 G/ D: C1 r5 Z: O( J, u
/****************************************************************************
*函数名:GUI_WriteCnChar
*输 入:x:显示起始X坐标
* * y:显示起始Y坐标
* * *cn:要显示的字符串
* * wordColor:字体的颜色
* * backColor:背景颜色
*输 出:
*功 能:写二号楷体汉字
****************************************************************************/
; |+ W8 a) g, P% Z8 {) n
#ifdef CHAR32_SHOW
! J: s- F1 R- [* D
void GUI_Write32CnChar(uint x, uint y, uchar *cn, uint wordColor, uint backColor)
+ W u1 Q/ F$ B) @, c3 o& c
…………限于本文篇幅 余下代码请下载附件…………
' O S" ?. i2 a. O' r' O
, @& }9 N% F. P) @5 n; C