?? shishi.c
字號:
#include <reg51.h> /*液晶屏中央顯示 e 的程序*/
#include <math.h>
#include <absacc.h>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
#define send XBYTE[0xdfff] /*地址定義*/
TABLE1[5]={0x33,0x49,0x00,0x24,0x41};
TABLE2[4]={0x1e,0x11,0x15,0x2e};
sbit ACC_0=ACC^0; /*定義標準位*/
sbit ACC_1=ACC^1;
sbit ACC_2=ACC^2;
sbit ACC_3=ACC^3;
sbit ACC_5=ACC^5;
sbit P1_4=P1^4;
uint com,dat1,dat2; /*定義變量*/
void sta01() /*狀態位寫指令和寫數據的準備判斷*/
{
P1_4=1;
do
{
ACC=send;
}
while(ACC_0==0||ACC_1==0||ACC_5==0);
}
void sta3() /*自動寫數據的狀態位判斷*/
{
P1_4=1;
do
{
ACC=send;
}
while(ACC_3==0||ACC_5==0);
}
void write1() /*無參數指令寫入*/
{
sta01();
send=com;
P1_4=1;
}
void write2() /*單字節參數指令寫入*/
{
sta01();
P1_4=0;
send=dat2;
write1();
}
void write3() /*雙字節參數指令寫入*/
{
sta01();
P1_4=0;
send=dat1;
write2();
}
void chushihua() /*初始化*/
{
dat1=0x00; /*設文本顯示區域首地址*/
dat2=0x00;
com=0x40;
write3();
dat1=0x28; /*設文本顯示區域寬度*/
dat2=0x00;
com=0x41;
write3();
dat1=0x00; /*設圖形顯示區域寬度*/
dat2=0x08;
com=0x42;
write3();
dat1=0x28; /*設圖形顯示區域寬度*/
dat2=0x00;
com=0x43;
write3();
com=0x80; /*顯示方式設置*/
write1();
com=0x9c; /*顯示開關設置*/
write1();
}
void clear() /*清顯示屏*/
{
uint i;
dat1=0x00;
dat2=0x00;
com=0x24; /*設置顯示地址*/
write3();
com=0xb0; /*設置自動寫方式*/
write1();
for(i=0;i<8200;i++) /*清屏8200個點陣字符*/
{
sta3();
P1_4=0;
send=0x00;
}
com=0xb2; /*結束自動寫方式*/
write1();
}
void display33() /*定義顯示函數*/
{
dat1=0x8C;
dat2=0x00;
com=0x24; /*設置顯示位置*/
write3();
dat2=0x45;
com=0xc0; /*寫數據*/
write2();
}
void main() /*主函數*/
{
chushihua();
clear();
display33();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -