?? qudong.c
字號:
#include <reg51.h>
/**********************控制端口定義*********************
sbit rst p2^5
sbit cd p2^6
sbit ce p2^7
sbit wr p3^6
sbit rd p3^7
/*************定義標志位****************/
#define ture 1
#define flase 0
/*********定義通道地址***********/
#define code1 0x8100 /*****指令通道地址****/
#define data1 0x8000 /*****數據通道地址****/
/***************狀態字檢測***************/
CheckState()
{
unsigned char dat;
if((code&0x03)==0x03)
return ture;
else
return flase;
}
/***********指令參數設置**************/
void OutPortData(unsigned char para)
{
CheckState(); //狀態檢查
cd=0; //寫數據
wr=0;
data1=para;
wr=1;
cd=1;
}
/**************寫沒有參數的指令**************/
void OutPortCom(unsigned char command)
{
CheckState(); //狀態檢查
wr=0; //寫指令
code1=command;
wr=1;
cd=1;
}
/***************寫有一個參數的指令***************/
void OutPortCom1(unsigned char dat, unsigned char command)
{
OutPortData(dat);
OutPortCom(command);
}
/******************寫兩個參數的指令***************/
void OutPortCom2(unsigned char d1, unsigned char d2, unsigned char command)
{
OutPortData(d1);
OutPortData(d2);
OutPortCom(command);
}
/*********************清屏*******************/
void ClearScreen()
{
unsigned int i;
OutPortCom2(0x00, 0x00, 0x24); //設置地址指令,RAM地址0x0000
OutPortCom(0xb0); //自動寫指令
for(i=0;i<0x2000;i++)
{
OutPortData(0x00); //data=0
}
OutPortCom(0xb2); //自動寫結束指令
}
/******************延時函數*****************/
void delay()
{
int x=2000;
do
{ x=x-1;
}
while(x>1);
}
/**************LCD初始化*************/
void initlcd()
{
delay();
OutPortCom2(0x00, 0x00, 0x42); //設置圖形顯示區域首地址
OutPortCom2(0x20, 0x00, 0x43); //文本顯示區域寬度32字節
outportcom2(0x00,0x00,0x40); //設定文本顯示區域首地址
outportcom2(0x20,0x00,0x41); //文本顯示區域寬度32字節
OutPortCom(0xa7); //設置光標形狀
OutPortCom(0x80); //設置顯示方式:
OutPortCom(0x98); //設置顯示開關
ClearScreen();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -