完好的代码下载地址:http://www.51hei.com/bbs/dpj-20611-1.html
下面是ILI9235的驱动程序部分预览
#include “mylib.h”
/*******************************************************************************
函数称号:void ClearScreen(uint Color)
函数功用:刷屏使得全屏显现单一的色彩
进口参数:Clolr:屏幕布景的色彩(直接写入色彩的英文,在.h中有界说)
出口参数:无
备 注:
********************************************************************************/
void ClearScreen(uint Color)
{
uint i,j;
LCD_SetPos(0,320,0,240); //设置开始地址为(0,0) ~(320,240)
for (i=0;i<325;i++)
{
for (j=0;j<240;j++)
{
Write_Data_U16(Color);
}
}
}
/*******************************************************************************
函数称号:void Show_RGB (uint x0,uint x1,uint y0,uint y1,uint Color)
函数功用:在屏幕的(x0,y0)到(x1,y1)区域显现某一种色彩
进口参数:(x0,y0)和(x1,y1)表明方位;
Color :显现区域的色彩
出口参数:无
备 注:能够完成画点和画水平缓笔直的直线
显现时输入的参数x:0-320,y:0-240(横向)
*******************************************************************************/
void Show_RGB (uint x0,uint x1,uint y0,uint y1,uint Color)
{
uint i,j;
i=x0;x0=y0;y0=i;
i=x1;x1=y1;y1=i;
i = y0;
y0 = 320-y1;
y1 = 320-i;
LCD_SetPos(x0,x1,y0,y1);
for (i=y0;i<=y1;i++)
{
for (j=x0;j<=x1;j++)
{
Write_Data_U16(Color);
}
}
}
/*******************************************************************************
函数称号:void DrawCoord(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
函数功用:在屏幕上画坐标,屏幕是横放的
进口参数:(x0,y0)和(x1,y1)表明方位;
Color :显现区域的色彩
Line_Width:坐标轴的线宽
出口参数:无
备 注:无
*******************************************************************************/
void DrawCoord(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
{
LineWidth = LineWidth-1;
Show_RGB (x0,x0+LineWidth,y0,y1,Color); //竖
Show_RGB (x0,x1,y1-LineWidth,y1,Color); //横
}
/*******************************************************************************
函数称号:void Show_Xmark(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
函数功用:在屏幕上画横线,屏幕是横放的
进口参数:(x0,y0)和(x1,y1)表明方位;
Color :显现区域的色彩
Line_Width:坐标轴的线宽
出口参数:无
备 注:无
*******************************************************************************/
void Show_Xmark(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
{
LineWidth = LineWidth-1;
Show_RGB (x0,x0+LineWidth,y0,y1,Color); //竖
}
/*******************************************************************************
函数称号:void Show_Xmark(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
函数功用:在屏幕上画竖线,屏幕是横放的
进口参数:(x0,y0)和(x1,y1)表明方位;
Color :显现区域的色彩
Line_Width:坐标轴的线宽
出口参数:无
备 注:无
*******************************************************************************/
void Show_Ymark (uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
{
LineWidth = LineWidth-1;
Show_RGB (x0,x1,y0,y0+LineWidth,Color);
}
/*******************************************************************************
函数称号:void Init_data (uchar x,uint y)
函数功用:些数据到寄存器
进口参数:x,y 需求写入的数据
出口参数:无
备 注:无
*******************************************************************************/
void Init_data (uchar x,uint y)
{
uchar m,n;
m=y>>8;
n=y;
Write_Cmd(0x00,x);
Write_Data(m,n);
}
/*******************************************************************************
函数称号:void Write_Data_U16(uint y)
函数功用:写入色彩
进口参数:y 色彩数据
出口参数:无
备 注:无
*******************************************************************************/
void Write_Data_U16(uint y)
{
uchar m,n;
m=y>>8;
n=y;
Write_Data(m,n);
}
/*******************************************************************************
函数称号:void Write_Cmd(uchar DH,uchar DL)
函数功用:写指令
进口参数:DH 高8位数据 DL 低8位数据
出口参数:无
备 注:无
*******************************************************************************/
void Write_Cmd(uchar DH,uchar DL)
{
CS0
RS0
P4DIR = 0xff;
P4OUT = DH;
RW0
RW1
P4OUT = DL;
RW0
RW1
CS1
}
/*******************************************************************************
函数称号:void Write_Data(uchar DH,uchar DL)
函数功用:写数据
进口参数:DH 高8位数据 DL 低8位数据
出口参数:无
备 注:无
*******************************************************************************/
void Write_Data(uchar DH,uchar DL)
{
CS0
RS1
P4DIR = 0xff;
P4OUT=DH;
RW0
RW1
P4OUT=DL;
RW0
RW1
CS1
}