24寸TFT彩屏 430例程 GUI函数部分Word格式文档下载.docx
《24寸TFT彩屏 430例程 GUI函数部分Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《24寸TFT彩屏 430例程 GUI函数部分Word格式文档下载.docx(48页珍藏版)》请在冰点文库上搜索。
//显示1位16进制数
voidGUI_HLine(ucharx,uinty,ucharlength,uintcolor);
//画横线
voidGUI_RLine(ucharx,uinty,uinthigh,uintcolor);
//画竖线
voidGUI_line(uintx1,uinty1,uintx2,uinty2,uintcolor);
//画直线
voidGUI_DisPicture(ucharx,uinty,ucharlength,uinthigh);
//显示图片(图标)
voidGUI_sprintf_char(ucharx,uinty,ucharc,uintcolor,uintb_color);
//显示英文或数字字符
voidGUI_sprintf_string(ucharx,uinty,char*s,uintcolor,uintb_color);
//显示英文字符串
voidGUI_sprintf_HZ(ucharx,uinty,uintcolor,uintb_color);
//显示预定义汉字字符串
voidGUI_box(ucharsx,uintsy,ucharex,uintey,uintcolor);
//画实心矩形
voidGUI_rectangle(ucharsx,uintsy,ucharex,uintey,uintcolor);
//画空心矩形
voidGUI_wrul(ucharx,uinty,unsignedlongnum,uintcolor,uintb_color);
//以十进制形式显示无符号长整型数
voidGUI_wrlval(ucharx,uinty,unsignedlongnum,ucharbits,uchardp,uintcolor,uintb_color);
//以十进制形式显示长变量
uintRGB(ucharR,ucharG,ucharB);
//RGB颜色混合
/*定义常用颜色的颜色码*/
#defineRED0xf800//红
#defineYELLOW0xffe0//黄
#defineGREEN0x07e0//绿
#defineCYAN0x07ff//青
#defineBLUE0x001f//蓝
#definePURPLE0xf81f//紫
#defineBLACK0x0000//黑
#defineWHITE0xffff//白
#defineGRAY0x7bef//灰
GUI函数程序.c文件GUI.c
#include"
gui.h"
16x8.h"
chinese.h"
bmp.h"
/************************************
清屏
入口参数:
b_color是背景颜色。
出口参数:
无
说明:
使用背景颜色清除TFT模块屏幕的全部显示内容。
*************************************/
voidGUI_clearscreen(uintb_color)
{
uinti,j;
LCD_CS_L;
//打开片选使能
Address_set(0,0,239,319);
for(i=0;
i<
320;
i++)
{
for(j=0;
j<
240;
j++)
write_data_u16(b_color);
}
}
/*********************************************
画点
(x,y)是点的坐标,color是点的颜色。
用指定的颜色在指定的坐标位置上画出一个点。
**********************************************/
voidGUI_Point(ucharx,uinty,uintcolor)
//打开片选使能
LCD_setxy(x,y);
write_data_u16(color);
/**********************************************************
无符号字符型数以二进制形式显示
(x,y)是显示内容的左上角坐标,color是显示字符的颜色,
无符号字符型数用指定的颜色和背景颜色在指定的坐标位置上
以二进制形式显示出来。
************************************************************/
voidGUI_sprintf_chartobit(ucharx,uinty,uchardat,uintcolor,uintb_color)
{
uchari;
for(i=0;
8;
if((dat&
(0x80>
>
i))==(0x80>
i))
{
GUI_sprintf_nu(x,y,1,color,b_color);
}
else
GUI_sprintf_nu(x,y,0,color,b_color);
x+=8;
无符号字符型数以十六进制形式显示
(x,y)是显示内容的左上角坐标,dat是欲显示的无符号字符型数,
color是显示字符的颜色,b_color是背景颜色。
以十六进制形式显示出来。
voidGUI_sprintf_chartohex(ucharx,uinty,uchardat,uintcolor,uintb_color)
GUI_sprintf_nu(x,y,dat>
4,color,b_color);
x+=8;
GUI_sprintf_nu(x,y,dat&
0x0f,color,b_color);
无符号字符型数以十进制形式显示
(x,y)是显示内容的左上角坐标,dat是欲显示的无符号字符型数,
以十进制形式显示出来。
voidGUI_sprintf_chartodec(ucharx,uinty,uchardat,uintcolor,uintb_color)
GUI_sprintf_char(x,y,dat/100+'
0'
color,b_color);
GUI_sprintf_char(x+8,y,dat/10%10+'
GUI_sprintf_char(x+16,y,dat%10+'
显示1位16进制数
(x,y)是显示内容的左上角坐标,c:
欲显示的1位16进制数,color:
颜色,b_color:
背景颜色。
用指定位置上显示1位16进制数。
/*voidGUI_sprintf_nu(ucharx,uinty,ucharnu,uintcolor,uintb_color)
uchars_x=0,s_y=0,temp=0;
uintj;
if(nu>
9)
{nu=nu+7;
}
nu=nu+16;
for(s_y=0;
s_y<
16;
s_y++)
if(s_y+y<
320)
j=nu;
j=j*16+s_y;
temp=font16x8[j];
//temp=font16x8[nu*16+s_y];
for(s_x=0;
s_x<
8;
s_x++)
if(x+s_x<
240)
if((temp&
(s_x)))==(0x80>
(s_x)))
{
GUI_Point(x+s_x,y+s_y,color);
}
else
GUI_Point(x+s_x,y+s_y,b_color);
}
*/
画横线
(x,y)是横线起点坐标,length是横线长度,color是横线颜色。
用指定的颜色在指定位置上画出指定长度的一条横线。
voidGUI_HLine(ucharx,uinty,ucharlength,uintcolor)
Address_set(x,y,x+length-1,y);
do
{
write_data_u16(color);
//逐点显示,描出水平线
length--;
while(length);
画竖线
(x,y)是竖线起点坐标,high竖线高度,color是竖线颜色。
用指定的颜色在指定位置上画出指定长度的一条竖线。
voidGUI_RLine(ucharx,uinty,uinthigh,uintcolor)
Address_set(x,y,x,y+high-1);
//逐点显示,描出垂直线
high--;
while(high);
/********************************************************************
画直线(可以画任意方向直线,包括横线、竖线、斜线)。
(x1,y1)起点,(x2,y2)终点,color颜色。
用指定的颜色在指定的两点间画出一条直线。
***********************************************************************/
voidGUI_line(uintx1,uinty1,uintx2,uinty2,uintcolor)
uintt;
intxerr=0,yerr=0,delta_x,delta_y,distance;
intincx,incy;
uintrow,col;
delta_x=x2-x1;
//计算坐标增量
delta_y=y2-y1;
col=x1;
row=y1;
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;
if(delta_y==0)incy=0;
//水平线
else{incy=-1;
delta_y=-delta_y;
delta_y)distance=delta_x;
//选取基本增量坐标轴
elsedistance=delta_y;
for(t=0;
t<
=distance+1;
t++)
{//画线输出
GUI_Point(col,row,color);
xerr+=delta_x;
yerr+=delta_y;
if(xerr>
distance)
xerr-=distance;
col+=incx;
if(yerr>
yerr-=distance;
row+=incy;
显示图片(图标)
(x,y)是开始点的坐标,length是图片长度,high是图片高度。
//pic图片数组的指针
用指定位置上显示事先定义的图片。
要显示的图片事先定义在bmp.h中的pic[]数组中,
如果想修改图片大小、内容,请修改bmp.h中的pic[]数组,
建议用Image2Lcd软件将你要显示的图象自动转换为数组数据。
//voidGUI_DisPicture(ucharx,uinty,ucharlength,uinthigh,constuchar*pic)
voidGUI_DisPicture(ucharx,uinty,ucharlength,uinthigh)
uinttemp=0,tmp=0,num=0;
Address_set(x,y,x+length-1,y+high-1);
num=length*high*2;
//temp=pic[tmp]|(pic[tmp+1]<
<
8);
temp=pic[tmp+1];
temp=temp<
temp=temp|pic[tmp];
write_data_u16(temp);
//逐点显示
tmp+=2;
}while(tmp<
num);
显示英文或数字字符
(x,y)是显示内容的左上角坐标,c:
显示的英文字符,
color:
用指定位置上显示单个英文字符或数字字符。
voidGUI_sprintf_char(ucharx,uinty,ucharc,uintcolor,uintb_color)
uchars_x,s_y,temp;
c-=32;
for(s_y=0;
s_y<
16;
s_y++)
j=c;
//temp=font16x8[c*16+s_y];
显示英文字符串
(x,y)是显示内容的左上角坐标,*s:
英文字符串指针,
在指定位置上显示英文字符串。
voidGUI_sprintf_string(ucharx,uinty,char*s,uintcolor,uintb_color)
for(;
*s!
='
\0'
;
s++)
GUI_sprintf_char(x,y,*s,color,b_color);
x=x+8;
//while(*s)
//{
//GUI_sprintf_char(x,y,*s,color,b_color);
//s++;
//x=x+8;
//}
显示预定义汉字字符串
(x,y)是显示内容的左上角坐标,color:
在指定位置上显示预定义的中文字符串。
要显示的中文字符串事先定义在chinese.h中的china_char[]数组中,
如果想修改中文字符串长度、内容,请修改chinese.h中的
china_char[]数组,建议用字模提取软件zimoV2.2将你要显示的
中文字符串自动转换为数组数据。
voidGUI_sprintf_HZ(ucharx,uinty,uintcolor,uintb_color)
uchars_x=0,s_y=0,temp=0;
ucharn;
uintj,words;
words=sizeof(china_char)/32;
for(n=0;
n<
words;
n++)
16;
s_x++)
if(s_x+x<
j=n;
j=j*32+s_x;
temp=china_char[j];
//temp=china_char[n*32+s_x];
for(s_y=0;
s_y<
if(y+s_y<
if((temp&
(s_y)))==(0x80>
(s_y)))