|
|
本帖最后由 電路板 于 2019-5-3 23:51 編輯
/************* 上面是底層時序函數(shù),下面是高層時序函數(shù) ***************/
/*********************************************************************
* 函 數(shù) 名 : Lcd12864Init
* 函數(shù)功能 : 按照LCD12864低層時序進行初始化序列
* 參數(shù)列表 : 無
* 函數(shù)輸出 : 無
*********************************************************************/
void Lcd12864Init(void)
{
//gLcd12864_PSB = 1; // 選定8位并行模式
// 發(fā)送初始化序列
Lcd12864WriteCmd(0x30); // 0x30為基本指令集
Lcd12864WriteCmd(0x02);
Lcd12864WriteCmd(0x0c); // 整體顯示、游標(biāo)關(guān)閉
Lcd12864WriteCmd(0x01); // 0x01為清屏指令
Lcd12864WriteCmd(0x80); // 地址自動加1
}
/*********************************************************************
* 函 數(shù) 名 : Lcd12864ShowStr
* 函數(shù)功能 : 從坐標(biāo)(x, y)開始顯示字符串str,注意這個函數(shù)不能跨行
* 顯示,因為顯存地址是不連續(xù)的。
* 參數(shù)列表 : x - 橫向坐標(biāo),范圍是0-7
* y - 縱向坐標(biāo),范圍是0-3
* pStr - 指向待顯示的字符串的指針
* 函數(shù)輸出 : 無
*********************************************************************/
void Lcd12864ShowStr(u8 x, u8 y, u8 *pStr) //顯示字符串
{
switch (y)
{
case 0:
x |= 0x80; break; // 第一行
case 1:
x |= 0x90; break; // 第二行
case 2:
x |= 0x88; break; // 第三行
case 3:
x |= 0x98; break; // 第四行
default:
break;
}
Lcd12864WriteCmd(x); // 發(fā)送地址碼
while (*pStr != '\0') // 若到達字串尾則退出
{
Lcd12864WriteData(*pStr); //
pStr++;
delay_1ms(5);
}
}
/*********************************************************************
* 函 數(shù) 名 : Lcd12864heng()
* 函數(shù)功能 : 顯示圖片
* 參數(shù)列表 : *pData
* 函數(shù)輸出 : 無
*********************************************************************/
void Lcd12864heng()
{
u8 x = 0, y = 0, i = 0,k;
for(i=0;i<9;i=i+8)
for(y=0;y<32;y++)
{
if((y%8)==1)k=0xff;
else k=0;
for(x=0;x<8;x++)
{
Lcd12864WriteCmd(0x36);
Lcd12864WriteCmd(0x80+y);
Lcd12864WriteCmd(0x80+x+i);
Lcd12864WriteData(k);
Lcd12864WriteData(k);
Lcd12864WriteCmd(0x30);
}
}
}
|
-
-
-
-
LCD12864串行.zip
2019-5-3 23:42 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
52.24 KB, 下載次數(shù): 23, 下載積分: 黑幣 -5
LCD12864串行
評分
-
查看全部評分
|