|
12864液晶顯示
#include "lcd12864.h"
#include "reg51.h"
void delay_ms(unsigned char nms)
{
unsigned int i, j;
for(i = nms; i > 0; i--)
for(j = 110; j > 0; j--);
}
void lcd_sendbyte(unsigned char byte)
{
unsigned char i;
for(i = 0; i < 8; i++)
{
SCLK = 0;
delay_ms(2);
SID = (bit)(byte&0x80);
SCLK = 1;
byte = byte << 1;
}
}
void write_cmd(unsigned char cmd)
{
CS = 1;
lcd_sendbyte(0xf8);
lcd_sendbyte(0xf0&cmd);
lcd_sendbyte(0xf0&(cmd << 4));
CS = 0;
delay_ms(10);
}
void write_dat(unsigned char dat)
{
CS = 1;
lcd_sendbyte(0xfa);
lcd_sendbyte(0xf0&dat);
lcd_sendbyte(0xf0&(dat << 4));
CS = 0;
delay_ms(10);
}
void lcd_pos(unsigned char x, unsigned char y)
{
unsigned char pos;
switch(x)
{
case 0: x = 0x80; break;
case 1: x = 0x90; break;
case 2: x = 0x88; break;
case 3: x = 0x98; break;
}
pos = x + y;
write_cmd(pos);
}
void lcd12864_init()
{
PSB = 0;
write_cmd(0x30);
delay_ms(5);
write_cmd(0x0c);
delay_ms(5);
write_cmd(0x01);
delay_ms(5);
}
void lcd_display(unsigned char line, unsigned char column, char *str)
{
lcd_pos(line, column);
while(*str)
{
write_dat(*str++);
}
}
|
-
-
1.串行驅(qū)動顯示.rar
2018-12-26 20:49 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
39.63 KB, 下載次數(shù): 12, 下載積分: 黑幣 -5
12864顯示
|