📄 lcd.txt
字号:
#define LCDDELAY 1
#define LCDCMDTURNON 0x3f
#define LCDCMDTURNOFF 0x3e
#define LCDCMDSTARTLINE 0xc0
#define LCDCMDPAGE 0xb8
#define LCDCMDVERADDRESS 0x40
#define REGISTERCLKMD (*(unsigned int *)0x58)
#define WAITSTATUS (*(unsigned int *)0x28)
ioport unsigned int port8000;
ioport unsigned int port8001;
ioport unsigned int port8002;
ioport unsigned int port8003;
ioport unsigned int port8004;
ioport unsigned int port8007;
void Delay1(unsigned int nTime); // 延时子程序
void TurnOnLCD(); // 打开显示
void LCDCLS(); // 清除屏幕显示内容
void display16();
unsigned char ledkey[1][32]=
{
0x00, 0x01, 0x00, 0x01, 0x3f, 0x01, 0xa0, 0x7f, 0xa1, 0x20, 0x52, 0x12, 0x14, 0x02, 0x08, 0x02,
0x18, 0x02, 0x18, 0x06, 0x24, 0x05, 0x24, 0x09, 0x82, 0x18, 0x61, 0x70, 0x1c, 0x20, 0x00, 0x00
};
main()
{
TurnOnLCD();
LCDCLS();
display16( 0,0,1,ledkey);
}
void Delay1(unsigned int nDelay)
{
int ii,jj,kk=0;
for ( ii=0;ii<nDelay;ii++ )
{
for ( jj=0;jj<1024;jj++ )
{
kk++;
}
}
}
void TurnOnLCD()
{
port8001=LCDCMDTURNON;
Delay1(LCDDELAY);
port8002=0;
Delay1(1024);
port8001=LCDCMDSTARTLINE;
Delay1(LCDDELAY);
port8002=0;
Delay1(LCDDELAY);
}
void display16( int page,int line,int number,unsigned char (*pos)[32])
{
int i,n,p,m;
for(n=0;n<number;n++) /*8个字的依次显示*/
{
p=0;
for(m=0;m<2;m++)/*每个字需要显示2个页*/
{
port8001=LCDCMDPAGE+m+page; /*设置操作页=m+1*/
port8002=0;
Delay1(LCDDELAY);
port8001=LCDCMDVERADDRESS+n*16+line; /* 起始列=n*16+8 */
port8002=0;
Delay1(LCDDELAY);
for ( i=0;i<16;i++,p++ )
{
if((n*16+line+i)<64)
{
port8003=pos[n][p]; /* 屏幕左侧第1至32行第i列赋值*/ port8002=0; /* (赋值后当前操作列自动加1,所以不需设置)*/
port8002=0;
Delay1(LCDDELAY);
}
else
{
port8001=LCDCMDVERADDRESS+n*16+line+i-64;
port8002=0;
port8004=pos[n][p]; /*屏幕左侧第1至32行第i列赋值*/ port8002=0; /*赋值后当前操作列自动加1,所以不需设置*/
port8002=0;
Delay1(LCDDELAY);
}
}
}
}
}
void LCDCLS() /*清除LCD显示器缓存*/
{
int i,j;
port8001=LCDCMDSTARTLINE;
port8002=0;
Delay1(LCDDELAY);
for ( i=0;i<8;i++ )
{
port8001=LCDCMDPAGE+i;
port8002=0;
Delay1(LCDDELAY);
port8001=LCDCMDVERADDRESS;
port8002=0;
Delay1(LCDDELAY);
for ( j=0;j<64;j++ )
{
port8003=0;
Delay1(LCDDELAY);
port8002=0;
Delay1(LCDDELAY);
}
port8001=LCDCMDPAGE+i;
Delay1(LCDDELAY);
port8002=0;
Delay1(LCDDELAY);
port8001=LCDCMDVERADDRESS;
port8002=0;
Delay1(LCDDELAY);
for ( j=0;j<64;j++ )
{
port8004=0;
Delay1(LCDDELAY);
port8002=0;
Delay1(LCDDELAY);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -