標題: lcd12864(st7565)要怎樣顯示溫度,求大佬幫忙 [打印本頁]

作者: yrw123123    時間: 2020-2-6 13:43
標題: lcd12864(st7565)要怎樣顯示溫度,求大佬幫忙
//--定時使用的IO口--//
#define DATA_PORT P0
sbit LCD12864_CS   = P3^2;
sbit LCD12864_RSET = P3^3;
sbit LCD12864_RS   = P2^6;
sbit LCD12864_RW   = P2^7;
sbit LCD12864_RD   = P2^5;
uchar Lcd12864_Write16CnCHAR(uchar x, uchar y, uchar *cn)
{
        uchar j, x1, x2, wordNum;

        //--Y的坐標只能從0到7,大于則直接返回--//
        if(y > 7)
        {
                return 0;
        }

        //--X的坐標只能從0到128,大于則直接返回--//
        if(x > 128)
        {
                return 0;
        }
        y += 0xB0;           //求取Y坐標的值
        //--設置Y坐標--//
        LcdSt7565_WriteCmd(y);
        while ( *cn != '\0')         //在C語言中字符串結束以‘\0’結尾
        {       
       
                //--設置Y坐標--//
                LcdSt7565_WriteCmd(y);

                x1 = (x >> 4) & 0x0F;   //由于X坐標要兩句命令,分高低4位,所以這里先取出高4位
                x2 = x & 0x0F;          //去低四位
                //--設置X坐標--//
                LcdSt7565_WriteCmd(0x10 + x1);   //高4位
                LcdSt7565_WriteCmd(0x04 + x2);        //低4位

                for (wordNum=0; wordNum<50; wordNum++)
                {
                    //--查詢要寫的字在字庫中的位置--//
                        if ((CN16CHAR[wordNum].Index[0] == *cn)
                             &&(CN16CHAR[wordNum].Index[1] == *(cn+1)))
                        {
                                for (j=0; j<32; j++) //寫一個字
                                {               
                                        if (j == 16)         //由于16X16用到兩個Y坐標,當大于等于16時,切換坐標
                                        {
                                                //--設置Y坐標--//
                                                   LcdSt7565_WriteCmd(y + 1);
                       
                                                //--設置X坐標--//
                                                LcdSt7565_WriteCmd(0x10 + x1);   //高4位
                                                LcdSt7565_WriteCmd(0x04 + x2);        //低4位
                                        }
                                        LcdSt7565_WriteData(CN16CHAR[wordNum].Msk[j]);
                                }
                                x += 16;
                        }//if查到字結束               
                } //for查字結束       
                cn += 2;
        }        //while結束
        return 1;
}

#endif






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1