新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > ILI9235的51單片機驅動程序-推箱子游戲

        ILI9235的51單片機驅動程序-推箱子游戲

        作者: 時間:2016-11-30 來源:網(wǎng)絡 收藏

        完整的代碼下載地址:http://www.51hei.com/bbs/dpj-20611-1.html
        下面是ILI9235的驅動程序部分預覽
        #include "mylib.h"

        本文引用地址:http://www.104case.com/article/201611/323809.htm


        /*******************************************************************************
        函數(shù)名稱:void ClearScreen(uint Color)
        函數(shù)功能:刷屏使得全屏顯示單一的顏色
        入口參數(shù):Clolr:屏幕背景的顏色(直接寫入顏色的英文,在.h中有定義)
        出口參數(shù):無
        備 注:
        ********************************************************************************/
        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);
        }
        }
        }


        /*******************************************************************************
        函數(shù)名稱:void Show_RGB (uint x0,uint x1,uint y0,uint y1,uint Color)
        函數(shù)功能:在屏幕的(x0,y0)到(x1,y1)區(qū)域顯示某一種顏色
        入口參數(shù):(x0,y0)和(x1,y1)表示位置;
        Color :顯示區(qū)域的顏色
        出口參數(shù):無
        備 注:可以實現(xiàn)畫點和畫水平和垂直的直線
        顯示時輸入的參數(shù)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);
        }
        }
        }

        /*******************************************************************************
        函數(shù)名稱:void DrawCoord(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
        函數(shù)功能:在屏幕上畫坐標,屏幕是橫放的
        入口參數(shù):(x0,y0)和(x1,y1)表示位置;
        Color :顯示區(qū)域的顏色
        Line_Width:坐標軸的線寬
        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        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); //橫
        }

        /*******************************************************************************
        函數(shù)名稱:void Show_Xmark(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
        函數(shù)功能:在屏幕上畫橫線,屏幕是橫放的
        入口參數(shù):(x0,y0)和(x1,y1)表示位置;
        Color :顯示區(qū)域的顏色
        Line_Width:坐標軸的線寬

        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        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); //豎
        }


        /*******************************************************************************
        函數(shù)名稱:void Show_Xmark(uint x0,uint x1, uint y0, uint y1, uint LineWidth, uint Color)
        函數(shù)功能:在屏幕上畫豎線,屏幕是橫放的
        入口參數(shù):(x0,y0)和(x1,y1)表示位置;
        Color :顯示區(qū)域的顏色
        Line_Width:坐標軸的線寬

        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        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);
        }

        /*******************************************************************************
        函數(shù)名稱:void Init_data (uchar x,uint y)
        函數(shù)功能:些數(shù)據(jù)到寄存器
        入口參數(shù):x,y 需要寫入的數(shù)據(jù)
        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        void Init_data (uchar x,uint y)
        {
        uchar m,n;
        m=y>>8;
        n=y;
        Write_Cmd(0x00,x);
        Write_Data(m,n);
        }


        /*******************************************************************************
        函數(shù)名稱:void Write_Data_U16(uint y)
        函數(shù)功能:寫入顏色
        入口參數(shù):y 顏色數(shù)據(jù)
        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        void Write_Data_U16(uint y)
        {
        uchar m,n;
        m=y>>8;
        n=y;
        Write_Data(m,n);
        }


        /*******************************************************************************
        函數(shù)名稱:void Write_Cmd(uchar DH,uchar DL)
        函數(shù)功能:寫指令
        入口參數(shù):DH 高8位數(shù)據(jù) DL 低8位數(shù)據(jù)
        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        void Write_Cmd(uchar DH,uchar DL)
        {
        CS0
        RS0
        P4DIR = 0xff;
        P4OUT = DH;
        RW0
        RW1
        P4OUT = DL;
        RW0
        RW1
        CS1
        }


        /*******************************************************************************
        函數(shù)名稱:void Write_Data(uchar DH,uchar DL)
        函數(shù)功能:寫數(shù)據(jù)
        入口參數(shù):DH 高8位數(shù)據(jù) DL 低8位數(shù)據(jù)
        出口參數(shù):無
        備 注:無
        *******************************************************************************/
        void Write_Data(uchar DH,uchar DL)
        {
        CS0
        RS1
        P4DIR = 0xff;
        P4OUT=DH;
        RW0
        RW1
        P4OUT=DL;
        RW0
        RW1
        CS1
        }


        上一頁 1 2 下一頁

        評論


        技術專區(qū)

        關閉
        主站蜘蛛池模板: 木兰县| 罗江县| 翁牛特旗| 南皮县| 上蔡县| 崇阳县| 靖安县| 晋中市| 舞阳县| 开鲁县| 阿尔山市| 定安县| 内黄县| 股票| 即墨市| 元谋县| 木兰县| 绵阳市| 若羌县| 池州市| 绥中县| 蓝山县| 达拉特旗| 车险| 华亭县| 囊谦县| 延川县| 蓬安县| 青州市| 汪清县| 新源县| 大埔县| 蒙阴县| 吴桥县| 江口县| 突泉县| 米易县| 壶关县| 临湘市| 喀喇沁旗| 襄樊市|