?? lcdforadc.h
字號(hào):
#include <msp430x22x4.h>
unsigned char number[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
void WriteCommandLCM(unsigned char lcmcmd,unsigned char busy);//寫(xiě)指令
void WriteDataLCM(unsigned char lcmdata);//寫(xiě)數(shù)據(jù)
void ReadStatusLCM();//讀狀態(tài)字
//=============================================
void Delay(int v)
{
while(v!=0)v--;
}
//=============================================
void LcmCls()//清屏
{
WriteCommandLCM(0x01,1);
}
//=============================================
void WriteCommandLCM(unsigned char lcmcmd,unsigned char busy)//寫(xiě)指令
{
if(busy) ReadStatusLCM(); //根據(jù)需要檢測(cè)忙
P3DIR|=0x3c;
P4OUT&=~BIT0;//RS=0
P4OUT&=~BIT1;//RW=0
P3OUT&=0xc3;//清高四位
P3OUT|=(lcmcmd>>2)&0x3c;//輸出高四位
P4OUT|=BIT2;//E=1
P4OUT&=~BIT2;//E=0
P3OUT&=0xc3;
P3OUT|=(lcmcmd<<2)&0x3c;//輸出低四位
P4OUT|=BIT2;//E=1
P4OUT&=~BIT2;//E=0
}
//=============================================
void WriteDataLCM(unsigned char lcmdata)//寫(xiě)數(shù)據(jù)
{
ReadStatusLCM();
P3DIR|=0x3c;
P4OUT|=BIT0;//RS=1
P4OUT&=~BIT1;//RW=0
P3OUT&=0xc3;
P3OUT|=(lcmdata>>2)&0x3c;//輸出高四位
P4OUT|=BIT2;//E=1
P4OUT&=~BIT2;//E=0
P3OUT&=0xc3;
P3OUT|=(lcmdata<<2)&0x3c;//輸出低四位
P4OUT|=BIT2;//E=1
P4OUT&=~BIT2;//E=0
}
//=============================================
void ReadStatusLCM()//讀狀態(tài)字
{
unsigned char LCMStatus;
P3DIR&=0xc3;
P4OUT&=~BIT0;//RS=0
P4OUT|=BIT1;//RW=1
P4OUT|=BIT2;//E=1
do{LCMStatus=P3IN&0x20;}
while(LCMStatus);//檢測(cè)忙信號(hào)
P3DIR|=0x3c;
P3OUT&=0xc3;
P4OUT&=~BIT2;//E=0
}
//=============================================
//按指定位置顯示一個(gè)字符
void DisplayOneChar(unsigned char x, unsigned char y, unsigned char DData)
{
y&=0x1;
x&=0xf;//限制x不能大于15,y不能大于1
if(y) x|=0x40;//當(dāng)要顯示第二行時(shí)地址碼+0x40;
x|=0x80;//算出指令碼
WriteCommandLCM(x,1);//發(fā)命令字,定位光標(biāo)
WriteDataLCM(DData);//發(fā)數(shù)據(jù)
}
//=============================================
//按指定位置顯示一串字符
void DisplayListChar(unsigned char x, unsigned char y, unsigned char *DData)
{
unsigned char ListLength=0;
y&=0x1;
x&=0xf; //限制x不能大于15,y不能大于1
while (DData[ListLength]>0x19) //若到達(dá)字串尾則退出
{
if(x<=0xf)
{
DisplayOneChar(x,y,DData[ListLength]); //顯示單個(gè)字符
x++;
}
ListLength++;
}
}
//=============================================
void InitLcd()//初始化lcd
{
P3DIR|=0x3c;//P3為L(zhǎng)CD輸出
P4DIR|=0x07;//RS=p4.0,RW=P4.1,E=P4.2
P3OUT&=0xc3;
Delay(3000);
WriteCommandLCM(0x38,0); //三次顯示模式設(shè)置,不檢測(cè)忙信號(hào)
Delay(300);
WriteCommandLCM(0x38,0);
Delay(300);
WriteCommandLCM(0x28,0);
Delay(300);
WriteCommandLCM(0x28,1); //顯示模式設(shè)置,開(kāi)始要求每次檢測(cè)忙信號(hào)
WriteCommandLCM(0x01,1); //顯示清屏
WriteCommandLCM(0x06,1); //顯示光標(biāo)移動(dòng)設(shè)置
WriteCommandLCM(0x0c,1); //顯示開(kāi)及光標(biāo)設(shè)置
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -