📄 muen_240128_function.c
字号:
#include <AT89X51.H>
#include <intrins.h>
#include <math.h>
#define DATA_PORT P0
sbit WR_PORT=P2^0 ;
sbit RD_PORT=P2^1 ;
sbit CE_PORT=P2^2 ;
sbit CD_PORT=P2^3 ;
//-------------delay the time---------//
//50us
void delay(unsigned int a)
{
unsigned int i,j ;
for(i=0;i<a;i++)
for(j=0;j<6;j++);
}
//--------- LGD Read the Appearance from the lGD-------------//
unsigned char read_Appearance(void)
{
unsigned char temp ;
CE_PORT=1 ;
DATA_PORT=0XFF ;
CE_PORT=0 ;
CD_PORT=1 ;
//READ CODE
RD_PORT=0 ;
temp=DATA_PORT ;
RD_PORT=1 ;
CE_PORT=1 ;
//del the Total line
return temp ;
}
//--------LGD STA0-STA1--------//
bit st00_st01(void)
{
unsigned char temp ;
temp=read_Appearance();
temp=temp&0x03 ;
if(temp==0x03)return 1 ;
return 0 ;
}
//----------LGD STA3--------//
bit st03(void)
{
unsigned char temp ;
temp=read_Appearance();
temp=temp&0x08 ;
if(temp==0x08)return 1 ;
return 0 ;
}
/*
//----------LGD STA2--------//
bit st02(void)
{
unsigned char temp;
temp=read_Appearance();
temp=temp&0x04;
if(temp==0x04)return 1;
return 0;
}
//---------LGD STA5--------//
bit st05(void)
{
unsigned char temp;
temp=read_Appearance();
temp=temp&0x20;
if(temp==0x20)return 1;
return 0;
}
//--------LGD STA6--------//
bit st06(void)
{unsigned char temp;
temp=read_Appearance();
temp=temp&0x40;
if(temp==0x40)return 1;
return 0;
}
//--------LGD STA7-------//
bit st07(void)
{
unsigned char temp;
temp=read_Appearance();
temp=temp&0x80;
if(temp==0x80)return 1;
return 0;
}
*/
//---------read data from the lgd--------//
unsigned char read_from(void)
{unsigned char temp;
while(st00_st01()==0);
CE_PORT=0;
CD_PORT=0;//data
RD_PORT=0;
//temp1=DATA_PORT;
temp=DATA_PORT;
RD_PORT=1;
CE_PORT=1;
return temp;
}
//------- Write 2 Number and 1 CODE to LCM ---------//
void write_2_code(unsigned char a,unsigned char b,unsigned char c)
{
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=0 ;
//data
DATA_PORT=a ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=0 ;
//data
DATA_PORT=b ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=1 ;
//code
DATA_PORT=c ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
}
//---------write 1 data and 1 code to the Lcm------//
void write_1_code(unsigned char a,unsigned char c)
{
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=0 ;
//data
DATA_PORT=a ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=1 ;
//code
DATA_PORT=c ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
}
//---------write 1 code to Lcm--------//
void write_code(unsigned char c)
{
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=1 ;
//code
DATA_PORT=c ;
WR_PORT=0 ;
_nop_();
WR_PORT=1 ;
CE_PORT=1 ;
}
//-----------write data to lgd---------//
void write_to(unsigned char a)
{
while(st00_st01()==0);
CE_PORT=0 ;
CD_PORT=0 ;
//data
DATA_PORT=a ;
WR_PORT=0 ;
WR_PORT=1 ;
CE_PORT=1 ;
}
//---------- START THE LGD-----------//
void lcm_start(void)
{
//----setting the text head addr--------//
write_2_code(0x00,0x00,0x21);
//the light mark start
write_2_code(0x00,0x00,0x40);
//text start
write_2_code(0x1e,0x00,0x41);
//text with
write_2_code(0x00,0x00,0x42);
//graph start
write_2_code(0x1e,0x00,0x43);
//graph with
write_code(0xa1);
//the light mark look like
write_code(0x80);
// the text or graph
write_code(0x98);
//the show like
}
//--------------CLS THE LCM-----------------//
void cls_lcm(void)
{
unsigned int i ;
write_2_code(0x00,0x00,0x24);
write_code(0xb0);
for(i=0;i<5888;i++)
{
while(st03()==0);
write_to(0x00);
}
write_code(0xb2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -