#i nclude <GLOBAL.h>
#i nclude <stdlib.h>
#i nclude <stdbool.h>
#i nclude <msp430x41x.h>
//*========================================================
//*========================================================
void ClrLcd(void)
{
unsigned int i;
for(i=0;i<17;i++)
{
LCDMEM[i]=0;;
}
}
void InitLcd(void)
{
LCDCTL = LCD4MUX + LCDP1;
P5SEL = 0xFF;
BTCTL |= BTFRFQ0;
ClrLcd();
}
void OpenLcd(void)
{
LCDCTL|=LCDON;
LcdRunData=0;
LcdShowNum=0;
LcdParseEn=1;
}
void DispLay(unsigned char Station,unsigned char Num)
{
const unsigned char LcdTable[11]={0x7d,0x60,0x3e,0x7a,0x63,0x5b,0x5f,0x70,0x7f,0x7b,0x00};
LCDMEM[Station]=LcdTable[Num];
}
void LcdDataFull(unsigned char MemShowStr,unsigned char ShowFg)
{
unsigned char i,k;
//GloBuf[0]-GloBuf[3]--->原始数据
//GloBuf[4]-GloBuf[11]-->分解后的数据
for(i=0;i<4;i++)
{
k=GloBuf[i] & 0xf0;
k=k>>4;
GloBuf[11-(i+i+1)]=k;
k=GloBuf[i] & 0x0f;
GloBuf[11-(i+i)]=k;
}
for(i=MemShowStr;i<8;i++)
{
DispLay(i,GloBuf[4+i]);
}
LCDMEM[0]|=0x01;
if(ShowBit[0]&0x01){LCDMEM[8]|=0x04;}else{LCDMEM[8]&=0xfb;}//--->M
if(ShowBit[0]&0x02){LCDMEM[0]|=0x02;}else{LCDMEM[0]&=0xfd;}//--->累计
if(ShowBit[0]&0x04){LCDMEM[0]|=0x04;}else{LCDMEM[0]&=0xfb;}//--->购水
if(ShowBit[0]&0x08){LCDMEM[0]|=0x08;}else{LCDMEM[0]&=0xf7;}//--->剩余
if(ValveOpenSt){LCDMEM[0]|=0x20;}else{LCDMEM[0]&=0xdf;}//--->开
if(ValveClosSt){LCDMEM[0]|=0x40;}else{LCDMEM[0]&=0xbf;}//--->关
if(ShowBit[1]&0x01){LCDMEM[5]|=0x80;}else{LCDMEM[5]&=0x7f;}//--->.
if(DisturbFg){LCDMEM[3]|=0x80;}else{LCDMEM[3]&=0x7f;}//--->干扰
if(CardErr){LCDMEM[7]|=0x80;}else{LCDMEM[7]&=0x7f;}//--->卡错
if(PowerLowFg){LCDMEM[8]|=0x08;}else{LCDMEM[8]&=0xf7;}//--->低压
if(ShowBuy){LCDMEM[6]|=0x80;}else{LCDMEM[6]&=0x7f;}//--->速购
}
void LcdParse(void)
{
if(LcdParseEn)
{
if(SecondsConn&0x04)
{
if(LcdRunData>3)
{
LcdRunData=0;
LcdShowNum++;
}
else
{
LcdRunData++;
}
ClrLcd();
ShowBit[0]=0;
ShowBit[1]=0;
ShowBit[1]|=0x01;
switch(LcdShowNum)
{
case 0x00 ://第03种显示方式数据提取到显示缓冲区---累计使用量
ShowBit[0]|=0x03;
RamCopy(GloBuf,Overal,4);
LcdDataFull(1,1);
break;
case 0x01 ://第01种显示方式数据提取到显示缓冲区---最新购买量
ShowBit[0]|=0x05;
RamCopy(GloBuf,BuyData,4);
LcdDataFull(1,1);
break;
case 0x02 ://第02种显示方式数据提取到显示缓冲区---当前剩余量
ShowBit[0]|=0x09;
if(OverdraftSt)
{
RamCopy(GloBuf,OverData,4);
LcdDataFull(2,1);
LCDMEM[1]=0x02;
}
else
{
RamCopy(GloBuf,Residual,4);
LcdDataFull(1,1);
}
break;
case 0x03 ://第01种显示方式数据提取到显示缓冲区---版本号1107
ShowBit[0]=0;
ShowBit[1]=0;
ShowBit[1]|=0x01;
LCDMEM[0]=0;
LCDMEM[1]=0x75;//----N
LCDMEM[2]=0x4e;//----0
LCDMEM[3]=0x02;//-----
LCDMEM[4]=0x60;//----1
DispLay(5,0x02);//---2
LCDMEM[6]=0x7d;//----0
DispLay(7,0x02);//---2
LCDMEM[8]=0;
break;
default:
LcdShowEn=1;
if(!PowerLowFg)
{
LcdShowEn=0;
LCDCTL&=~LCDON;;
}
LcdRunData=0;
LcdShowNum=0;
LcdParseEn=0;
break;
}
SecondsConn&=0xfb;
}
}
} |