?? lcd1602.h
字號:
//void delay(int i) 延時
//void wcmd(uchar c) 寫控制字
//void showchar(uchar pos,uchar c) 顯示單個字符(在pos位置上)
//void display(uchar pos,uchar *dispbuf) 顯示字符串(在pos位置上,以`結束)
//void load0() 顯示初始化(每次顯示前必用,否則結果失真)
//void loadchar(uchar *str) 加載字符
//void clr() 清屏
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
sbit RS=P2^2;
sbit RW=P2^0;
sbit EN=P2^1;
char code table[]={" THE RESULT IS \0"};
char code table2[]={"input passwords:\0"};
char code table3[]={"oh yeah!that is\0"};
char code table4[]={" incorrect!!!\0"};
void delay(int i)
{
while(i--);
}
void wcmd(uchar c)
{
P0=c;
EN=0;
RS=0;
RW=0;
delay(255);
EN=1;
}
void writedata(uchar c)
{
P0=c;
RS=1;
EN=0;
RW=0;
delay(255);
EN=1;
}
void showchar(uchar pos,uchar c)
{
uchar p;
if(pos>=0x10)
p=pos+0xb0;
else
p=pos+0x80;
wcmd(p);
writedata(c);
}
void loadchar(uchar *str)
{
uchar p,i;
p=0x40;
wcmd(p);
for(i=0;i<32;i++)
writedata(str[i]);
}
void display(uchar pos,uchar *dispbuf)
{
uchar i=0;
while(dispbuf[i]!=0)
{
wcmd(0x80+i);
showchar(pos+i,dispbuf[i]);
i++;
}
}
void clr()
{
wcmd(1);}
void load0()
{
delay(255);
wcmd(0x38);
wcmd(0x38);
wcmd(0x0c);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -