?? lcdinf.c
字號(hào):
#include <avr/io.h>
#define uch unsigned char
#define uint unsigned int
#define s_b(sfr,bit) (sfr|=(1<<bit))
#define c_b(sfr,bit) (sfr&=~(1<<bit))
#define test_b(sfr,bit) (sfr&(1<<bit))
#define NOP() __asm__ __volatile__ ("nop" ::)
#define DATA_i PINC //數(shù)據(jù)輸入
#define DATA_o PORTC//數(shù)據(jù)輸出
#define DATA DDRC
#define cont PORTB//控制端口\
#define RS 0
#define RW 2
#define ES 1
char xy_ch[2][8];//顯示緩存
uch ascii_s(uch x){
if(x<10)return x+0x30;
else return (x-9)+0x40;
}
void dlay(){ //短延時(shí)
NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();
}
void dlay2(uch x){ //短延時(shí)
for(;x!=0;x--){NOP();NOP();NOP();NOP();NOP();}
}
void w_by(uch x){//寫數(shù)據(jù)
s_b(cont,RS);
c_b(cont,RW);
NOP();
NOP();
NOP();
NOP();
s_b(cont,ES);NOP();NOP();
DATA_o=x;NOP();NOP();NOP();
c_b(cont,ES);
dlay();
}
void w_com(uch x){//寫指令
c_b(cont,RS);
c_b(cont,RW);
NOP();
NOP();
NOP();
NOP();
s_b(cont,ES);NOP();NOP();
DATA_o=x;NOP();NOP();NOP();
c_b(cont,ES);
dlay();
}
void xini(uch x){
if(x>7)x+=0x38;
w_com(x|0x80);}
void lcdini(void){
uch x;
for(x=250;x!=0;x--)dlay2(250);
w_com(0x1);//清顯示
for(x=10;x!=0;x--)dlay2(250);
w_com(0x38);//顯示設(shè)置
dlay2(80);
w_com(0x6);//顯示設(shè)置
dlay2(80);
w_com(0xc);//清顯示
dlay2(80);
for(x=200;x!=0;x--)dlay2(250);
//w_com(0xc0);//清顯示
w_com(0x40);
/*
dlay2(80);
w_by(0x40);
dlay2(80);
w_by(0xff);
dlay2(80);
w_by(0);
dlay2(80);
w_by(0xff);
dlay2(80);
w_by(0);
dlay2(80);
w_by(0xff);
dlay2(80);
w_by(0);
dlay2(80);
w_by(0xff);
*/
for(x=200;x!=0;x--)dlay2(250);
}
void dis_chs(char *ch,uch a)
{
uch i;
for(i=0;i<8;i++){
xy_ch[a][i]=*ch;
ch++;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -