单片机驱动LCD完整代码

#include “global.h”

#include “lcd.h”

#define cLcdCharStartIndex 0
#define cLcdCharCnt 52

#define COM0 0x08 // 0x01
#define COM1 0x04 //0x02
#define COM2 0x02 //0x04
#define COM3 0x01 //0x08

enum Pin5{T1=COM0,T2=COM1,T3=COM2,T4=COM3};
enum Pin6{A7=COM0,F7=COM1,E7=COM2,D7=COM3};
enum Pin7{T8=COM0,B7=COM1,G7=COM2,C7=COM3};
enum Pin8{A8=COM0,F8=COM1,E8=COM2,D8=COM3};
enum Pin9{B8=COM0,G8=COM1,C8=COM2,T9=COM3};
enum Pin10{A9=COM0,F9=COM1,E9=COM2,D9=COM3};
enum Pin11{B9=COM0,G9=COM1,C9=COM2,T10=COM3};
enum Pin12{S2=COM0,S3=COM1,S4=COM2,S5=COM3};
enum Pin13{A10=COM0,F10=COM1,E10=COM2,D10=COM3};
enum Pin14{T11=COM0,B10=COM1,G10=COM2,C10=COM3};
enum Pin15{A11=COM0,F11=COM1,E11=COM2,D11=COM3};
enum Pin16{B11=COM0,G11=COM1,C11=COM2,T12=COM3};
enum Pin17{S1=COM0,S10=COM1,S9=COM2,S8=COM3};
enum Pin18{A16=COM0,F16=COM1,E16=COM2,D16=COM3};
enum Pin19{T15=COM0,B16=COM1,G16=COM2,C16=COM3};
enum Pin20{A17=COM0,F17=COM1,E17=COM2,D17=COM3};
enum Pin21{B17=COM0,G17=COM1,C17=COM2,T16=COM3};
enum Pin22{A18=COM0,F18=COM1,E18=COM2,D18=COM3};
enum Pin23{B18=COM0,G18=COM1,C18=COM2,T17=COM3};
enum Pin24{N241=COM0,N242=COM1,T23=COM2,T24=COM3};
enum Pin25{T20=COM0,T21=COM1,T22=COM2,T25=COM3};
enum Pin30{B21=COM0,G21=COM1,C21=COM2,T18=COM3};
enum Pin31{A21=COM0,F21=COM1,E21=COM2,D21=COM3};
enum Pin32{B20=COM0,G20=COM1,C20=COM2,N321=COM3};
enum Pin33{A20=COM0,F20=COM1,E20=COM2,D20=COM3};
enum Pin34{B19=COM0,G19=COM1,C19=COM2,N341=COM3};
enum Pin35{A19=COM0,F19=COM1,E19=COM2,D19=COM3};
enum Pin36{B23=COM0,G23=COM1,C23=COM2,T19=COM3};
enum Pin37{A23=COM0,F23=COM1,E23=COM2,D23=COM3};
enum Pin38{B22=COM0,G22=COM1,C22=COM2,N381=COM3};
enum Pin39{A22=COM0,F22=COM1,E22=COM2,D22=COM3};
enum Pin40{B15=COM0,G15=COM1,C15=COM2,T14=COM3};
enum Pin41{A15=COM0,F15=COM1,E15=COM2,D15=COM3};
enum Pin42{B14=COM0,G14=COM1,C14=COM2,S6=COM3};
enum Pin43{A14=COM0,F14=COM1,E14=COM2,D14=COM3};
enum Pin44{B13=COM0,G13=COM1,C13=COM2,S7=COM3};
enum Pin45{A13=COM0,F13=COM1,E13=COM2,D13=COM3};
enum Pin46{T13=COM0,B12=COM1,G12=COM2,C12=COM3};
enum Pin47{A12=COM0,F12=COM1,E12=COM2,D12=COM3};
enum Pin48{B6=COM0,G6=COM1,C6=COM2,T7=COM3};
enum Pin49{A6=COM0,F6=COM1,E6=COM2,D6=COM3};
enum Pin50{B5=COM0,G5=COM1,C5=COM2,N501=COM3};
enum Pin51{A5=COM0,F5=COM1,E5=COM2,D5=COM3};
enum Pin52{B4=COM0,G4=COM1,C4=COM2,N521=COM3};
enum Pin53{A4=COM0,F4=COM1,E4=COM2,D4=COM3};
enum Pin54{T6=COM0,B3=COM1,G3=COM2,C3=COM3};
enum Pin55{A3=COM0,F3=COM1,E3=COM2,D3=COM3};
enum Pin56{B2=COM0,G2=COM1,C2=COM2,N561=COM3};
enum Pin57{A2=COM0,F2=COM1,E2=COM2,D2=COM3};
enum Pin58{B1=COM0,G1=COM1,C1=COM2,T5=COM3};
enum Pin59{A1=COM0,F1=COM1,E1=COM2,D1=COM3};

#define SEG_TYPE1 A1,B1,C1,D1,E1,F1,G1 //B.G,C
#define SEG_TYPE2 A7,B7,C7,D7,E7,F7,G7

typedef struct
{
uint8_t Pin; //SEG0 typedef 相当于X
uint8_t Dat; //相当于Y
}Seg[cLcdCharCnt];

typedef union
{

	uint8_t 	SegBuf[cLcdCharCnt];
struct{uint8_t	PIN8; 	//SEG0  typedefuint8_t	PIN7;   //1uint8_t	PIN6;   //2uint8_t	PIN5;   //3uint8_t	PIN59;  //4uint8_t	PIN58; 	//5uint8_t	PIN57; 	//6uint8_t	PIN56; 	//7uint8_t	PIN55; 	//8uint8_t	PIN54; 	//	9uint8_t	PIN53; 	//10uint8_t	PIN52; 	//11uint8_t	PIN47;  //12uint8_t	PIN46;  //13uint8_t	PIN45;  //14uint8_t	PIN44;  //15uint8_t	PIN43;  //16uint8_t	PIN42;  //17uint8_t	PIN41;  //18uint8_t	PIN40;  //19uint8_t	PIN39;  //20uint8_t	PIN38;  //21uint8_t	PIN60;   //空22uint8_t	PIN37; 	//23uint8_t	PIN32;	//24uint8_t	PIN31; //25uint8_t	PIN30; //26uint8_t	PIN25; //27uint8_t	PIN24; //28uint8_t	PIN23; //29uint8_t	PIN22; //30uint8_t	PIN21; //31uint8_t	PIN20; //32uint8_t	PIN19; //33uint8_t	PIN18; //34uint8_t	PIN17; //35uint8_t	PIN16; //36uint8_t	PIN15;	//37uint8_t	PIN14; //38uint8_t	PIN13; //39uint8_t	PIN12; //40uint8_t	PIN11; //41uint8_t	PIN10; 	//	42uint8_t	PIN9; 	//43uint8_t	PIN51; //44uint8_t	PIN50; //45uint8_t	PIN49; //46uint8_t	PIN48; //47uint8_t	PIN36; //48uint8_t	PIN35; //49uint8_t	PIN34; //50uint8_t	PIN33; //51}Seg;}lcdFlag;lcdFlag  	  LCD_SEG;

#define LCD_DATE LCD_SEG.Seg

uint8_t LCDSegBuf[cLcdCharCnt];

/*
void SEG_Test()
{uint16_t i;for(i=0;i<2*cLcdCharCnt;i++){LCD_SEG.SegBuf[i];}}
*/void Up_lcd(void)
{uint16_t i,k=0;uint8_t  buf;for(i=0;i<cLcdCharCnt;i++){if((i%2)==0)  							//0 2 4 ....{k=i/2;buf=LCD_SEG.SegBuf[i]&0x0f;buf=buf<<4;LCDSegBuf[k]=buf;  //}else       //1 /3 /5{LCDSegBuf[k]|=LCD_SEG.SegBuf[i];  //0 ,1 ,2 低位}}tm1729_disp(LCDSegBuf,cLcdCharCnt/2);
}

void Test_LCD(void)
{

	LCD_DATE.PIN60=0x00;SolaSymbol(1);TypeCInSymbol(1);FanSymbol(1);AcInSymbol(1);DcOutSymbol(1);TypeCOutSymbol(1);InSymbol(1);OutSymbol(1);TempColSymbol(1);UsbOutSymbol(1);AcOutSymbol(1);TempHotSymbol(1);//ErrorCode(Test_buf,1);PerNum(Test_buf, 1);PerGird(Test_buf3, 1);InputNum(Test_buf1,1);OutputNum(Test_buf1,1);HZNum(Test_buf,1);VolNum(Test_buf1,1);ChgTime(Test_buf2);DisTime(Test_buf2);

}

void SegClr(uint8_t *dat)
{uint16_t i;for(i=0;i<cLcdCharCnt;i++)	{//LCD_SEG.SegBuf[i]=0;*dat=0;dat++;}}

void SegSet(uint8_t *dat)
{
uint16_t i;
for(i=0;i<cLcdCharCnt;i++)
{
// LCD_SEG.SegBuf[i]=0xff;
*dat=0xff;
dat++;

	}

}

void ClrDat(void)
{

//SegClr(LCDSegBuf);
//SegClr(LCD_SEG.SegBuf);memset(LCDSegBuf, 0X00, cLcdCharCnt);  //
memset(LCD_SEG.SegBuf, 0X00, cLcdCharCnt);

}

//enum SEG_D{a=0x01,b=0x02,c=0x04,d=0x08};

//enum Pin0{COM0,COM1,COM2,COM3};

//enum aaa{a=,b,c,d};

/*
typedef enum {
COM0=0x01,COM1=0x02,COM2=0x04,COM3=0x08,
} SEG_D;
*/

void InitHT162X(void)
{

/*
GPIO_LCD();
SendCmd(0x01); //sys EN
SendCmd(0X03); //LCD ON
SendCmd(0X18); //RC 256
SendCmd(0X29); //1/3 Bias,1/4 Duty
SendCmd(0X0F);
Clr_1621();
*/
}

/***************************
void ShowEN(uint8_t en,uint8_t *p)

函数名:void ShowEN(uint8_t en,uint8_t *p)
功能:显示与否
*********************************/
void ShowEn(uint8_t en,uint16_t *p)
{
if(en==0)
{
*p=10;
}
}

void DigitHandel(Digit_Type *p)
{

 Digit_Num(p->data,p->LB,p->HB,p->a,p->b,p->c,p->d,p->e,p->f,p->g);

}

void CallInPut(uint16_t dat)
{

Digit_Type Dit;//Dit.LCD_DATE.PIN11;// dot=&LCD_DATE.PIN9;
/*d1A=&LCD_DATE.PIN6;d1B=&LCD_DATE.PIN7;d2A=&LCD_DATE.PIN8;d2B=&LCD_DATE.PIN9;d3A=&LCD_DATE.PIN10;d3B=&LCD_DATE.PIN11;
*/DigitHandel(&Dit);

}

void Digit_Num(uint8_t data,uint8_t *LB,uint8_t *HB,uint8_t a,uint8_t b,uint8_t c,uint8_t d,uint8_t e,uint8_t f,uint8_t g)
{
switch(data)
{
case 0:
{

		(*LB)|=a; //A (*HB)|=b; //B*(*HB)|=c;  //C (*LB)|=d; //D*(*LB)|=e; //E  *(*LB)|=f; //F  *(*HB)&=~g; //G};break;case 1:{(*LB)&=~a; //A(*HB)|=b; //B(*HB)|=c;  //C(*LB)&=~d; //D(*LB)&=~e; //E(*LB)&=~f; //F(*HB)&=~g; //G};break;case 2:{(*LB)|=a; //A(*HB)|=b; //B(*HB)&=~c;  //C(*LB)|=d; //D(*LB)|=e; //E(*LB)&=~f; //F(*HB)|=g; //G};break;case 3:{(*LB)|=a; //A(*HB)|=b; //B(*HB)|=c;  //C(*LB)|=d; //D(*LB)&=~e; //E(*LB)&=~f; //F(*HB)|=g; //G};break;case 4:{(*LB)&=~a; //A(*HB)|=b; //B(*HB)|=c;  //C(*LB)&=~d; //D(*LB)&=~e; //E(*LB)|=f; //F(*HB)|=g; //G};break;case 5:{(*LB)|=a; //A(*HB)&=~b; //B(*HB)|=c;  //C(*LB)|=d; //D(*LB)&=~e; //E(*LB)|=f; //F(*HB)|=g; //G};break;case 6:{(*LB)|=a; //A(*HB)&=~b; //B(*HB)|=c;  //C(*LB)|=d; //D(*LB)|=e; //E(*LB)|=f; //F(*HB)|=g; //G};break;case 7:{(*LB)|=a; //A(*HB)|=b; //B(*HB)|=c; //C(*LB)&=~d; //D(*LB)&=~e; //E(*LB)&=~f; //F(*HB)&=~g; //G};break;case 8:{(*LB)|=a; //A(*HB)|=b; //B(*HB)|=c;  //C(*LB)|=d; //D(*LB)|=e; //E(*LB)|=f; //F(*HB)|=g; //G};break;case 9:{(*LB)|=a; //A(*HB)|=b; //B(*HB)|=c;  //C(*LB)|=d; //D(*LB)&=~e; //E(*LB)|=f; //F(*HB)|=g; //G};break;default:{(*LB)&=~a; //A(*HB)&=~b; //B(*HB)&=~c;  //C(*LB)&=~d; //D(*LB)&=~e; //E(*LB)&=~f; //F(*HB)&=~g; //G}break;

}

}

/*********************
void InputNum(uint16_t dat)
显示输入4位数码管

***********************/

void InputNum(uint16_t dat,uint8_t en)
{
uint16_t buf;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN49,&LCD_DATE.PIN48,SEG_TYPE1); // Digit_Num(buf,&LCD_DATE.PIN55,&LCD_DATE.PIN54,SEG_TYPE2); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN51,&LCD_DATE.PIN50,SEG_TYPE1); // Digit_Num(buf,&LCD_DATE.PIN53,&LCD_DATE.PIN52,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN53,&LCD_DATE.PIN52,SEG_TYPE1); //Digit_Num(buf,&LCD_DATE.PIN51,&LCD_DATE.PIN50,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN55,&LCD_DATE.PIN54,SEG_TYPE2); //Digit_Num(buf,&LCD_DATE.PIN49,&LCD_DATE.PIN48,SEG_TYPE1); //

 SetSymbol(&LCD_DATE.PIN48,T7,en);SetSymbol(&LCD_DATE.PIN54,T6,en);/*

if(en==0)
{
LCD_DATE.PIN48&=~T7; //W
LCD_DATE.PIN54&=~T6; //input
}
else
{
LCD_DATE.PIN48|=T7; //W
LCD_DATE.PIN54|=T6; //input
}

*/

}

void InputNum_Clr(void)
{
uint16_t buf;
buf=10;
Digit_Num(buf,&LCD_DATE.PIN55,&LCD_DATE.PIN54,SEG_TYPE2); //
Digit_Num(buf,&LCD_DATE.PIN53,&LCD_DATE.PIN52,SEG_TYPE1); //
Digit_Num(buf,&LCD_DATE.PIN51,&LCD_DATE.PIN50,SEG_TYPE1); //
Digit_Num(buf,&LCD_DATE.PIN49,&LCD_DATE.PIN48,SEG_TYPE1); //
LCD_DATE.PIN48&=~T7;
LCD_DATE.PIN54&=~T6; //input

}

/****************************
函数名:void OutputNum(uint16_t dat)
功能:显示输出4位数码管

****************************/
void OutputNum(uint16_t dat,uint8_t en)
{
uint16_t buf;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN41,&LCD_DATE.PIN40,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN43,&LCD_DATE.PIN42,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN45,&LCD_DATE.PIN44,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN47,&LCD_DATE.PIN46,SEG_TYPE2); //

SetSymbol(&LCD_DATE.PIN40,T14,en);   //W
SetSymbol(&LCD_DATE.PIN46,T13,en);  //input
/*if(en==0){LCD_DATE.PIN40&=~T14;   //WLCD_DATE.PIN46&=~T13; //input}else{LCD_DATE.PIN40|=T14;   //WLCD_DATE.PIN46|=T13; //input}*/

}

void OutputNum_Clr(void)
{
uint16_t buf;
buf=10;
Digit_Num(buf,&LCD_DATE.PIN47,&LCD_DATE.PIN46,SEG_TYPE2); //
Digit_Num(buf,&LCD_DATE.PIN45,&LCD_DATE.PIN44,SEG_TYPE1); //
Digit_Num(buf,&LCD_DATE.PIN43,&LCD_DATE.PIN42,SEG_TYPE2); //
Digit_Num(buf,&LCD_DATE.PIN41,&LCD_DATE.PIN40,SEG_TYPE1); //
LCD_DATE.PIN40&=~T14;
LCD_DATE.PIN46&=~T13; //input

}

/***********************************

	if(RemainTime>=60){if(RemainTime>=600){TimeHour(RemainTime/60,0);}else{TimeHour(RemainTime/6,1);}}else{TimeMin(RemainTime);}

***************************************/
void TimeHour(uint16_t dat,uint16_t chn,uint8_t en)
{

//	uint16_t hour,min;uint16_t buf,buf1;uint8_t *dot,*d1A,*d2A,*d3A,*d1B,*d2B,*d3B,*H;if(chn==0){H=&LCD_DATE.PIN11;dot=&LCD_DATE.PIN9;d1A=&LCD_DATE.PIN6;//高位d1B=&LCD_DATE.PIN7;d2A=&LCD_DATE.PIN8;d2B=&LCD_DATE.PIN9;d3A=&LCD_DATE.PIN10;d3B=&LCD_DATE.PIN11;}else{H=&LCD_DATE.PIN23;dot=&LCD_DATE.PIN21;d1A=&LCD_DATE.PIN18;d1B=&LCD_DATE.PIN19;d2A=&LCD_DATE.PIN20;d2B=&LCD_DATE.PIN21;d3A=&LCD_DATE.PIN22;d3B=&LCD_DATE.PIN23;}*H|=T10;   //显示H图标if(en==0){buf=10;Digit_Num(buf,d1A,d1B,SEG_TYPE2);  //Digit_Num(buf,d2A,d2B,SEG_TYPE1);  //Digit_Num(buf,d3A,d3B,SEG_TYPE1);  //*H&=~T10;*dot&=~T9;   //不显示小数点}else if(dat>=6000){dat=dat/60;*dot&=~T9;   //不显示小数点buf=dat%10;Digit_Num(buf,d3A,d3B,SEG_TYPE1);  //dat=dat/10;buf=dat%10;Digit_Num(buf,d2A,d2B,SEG_TYPE1);  //dat=dat/10;buf=dat%10;Digit_Num(buf,d1A,d1B,SEG_TYPE2);  //}else{*dot|=T9;   //显示小数点buf1=dat%60;   //小数点buf1=buf1/6;// 0.1=6MIN进制Digit_Num(buf1,d3A,d3B,SEG_TYPE1);  //小数点dat=dat/60; //转换到60MIN=1hbuf=dat%10;Digit_Num(buf,d2A,d2B,SEG_TYPE1);  //dat=dat/10;buf=dat%10;Digit_Num(buf,d1A,d1B,SEG_TYPE2);  //}

}

/*******************
函数名:void PerNum(uint16_t dat)
功能:显示百分比数值

***********************/
void PerNum(uint16_t dat,uint8_t en)
{

uint16_t buf;
uint8_t *d1A,*d2A,*d3A,*d1B,*d2B,*d3B;//*H=LCD_DATE.PIN11;
// *dot=LCD_DATE.PIN15;
d1A=&LCD_DATE.PIN15;
d1B=&LCD_DATE.PIN16;
d2A=&LCD_DATE.PIN13;
d2B=&LCD_DATE.PIN14;
d3A=&LCD_DATE.PIN14;  //100
d3B=&LCD_DATE.PIN16;   //%buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,d1A,d1B,SEG_TYPE1);  ///*
if(dat<10)
{buf=10;
}
else
{dat=dat/10;buf=dat%10;
}
*/dat=dat/10;buf=dat%10;ShowEn(en,&buf);
Digit_Num(buf,d2A,d2B,SEG_TYPE2);  //dat=dat/10;
buf=dat%10;if(buf==1)   //100
{*d3A|=T11;    
}
else
{*d3A&=~T11;
}SetSymbol(d3B,T12,en);/*
if(en==0)
{*d3B&=~T12;
}
else
*d3B|=T12;
*/// Digit_Num(buf,&LCD.PIN6,&LCD.PIN5,A1,B1,C1,D1,E1,F1,G1);  //

}

/*********************************
函数名:void PerGird(uint16_t dat)
功能:百分比格数

**********************************/

void PerGird(uint16_t dat,uint8_t en)
{
uint16_t buf;
uint8_t *A1,*A2,*A3,*A4,*A5,*A6,*A7,*A8,*A9,*A10;

A1=&LCD_DATE.PIN17;
A2=&LCD_DATE.PIN12;
A3=&LCD_DATE.PIN12;
A4=&LCD_DATE.PIN12;
A5=&LCD_DATE.PIN12;
A6=&LCD_DATE.PIN42;
A7=&LCD_DATE.PIN44;
A8=&LCD_DATE.PIN17;
A9=&LCD_DATE.PIN17;
A10=&LCD_DATE.PIN17;

buf=dat;

if(en==0)
{buf=10;
}switch (buf)

{
case 0:
{
//S1|=LCD_DATE.PIN16
*A1&=~S1;
*A2&=~S2;
*A3&=~S3;
*A4&=~S4;
*A5&=~S5;
*A6&=~S6;
*A7&=~S7;
*A8&=~S8;
*A9&=~S9;
*A10&=~S10;

	}break;
case 1:{*A1|=S1;*A2&=~S2;*A3&=~S3;*A4&=~S4;*A5&=~S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 2:{*A1|=S1;*A2|=S2;*A3&=~S3;*A4&=~S4;*A5&=~S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 3:{*A1|=S1;*A2|=S2;*A3|=S3;*A4&=~S4;*A5&=~S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 4:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5&=~S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 5:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 6:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6|=S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 7:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6|=S6;*A7|=S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;case 8:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6|=S6;*A7|=S7;*A8|=S8;*A9&=~S9;*A10&=~S10;}break;case 9:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6|=S6;*A7|=S7;*A8|=S8;*A9|=S9;*A10&=~S10;}break;case 10:{*A1|=S1;*A2|=S2;*A3|=S3;*A4|=S4;*A5|=S5;*A6|=S6;*A7|=S7;*A8|=S8;*A9|=S9;*A10|=S10;}break;
default:{*A1&=~S1;*A2&=~S2;*A3&=~S3;*A4&=~S4;*A5&=~S5;*A6&=~S6;*A7&=~S7;*A8&=~S8;*A9&=~S9;*A10&=~S10;}break;

}
}

/***************************
函数名:void ErrorCode(uint16_t dat)
功能:故障代码显示

*************************/
void ErrorCode(uint16_t dat,uint8_t en)
{

	uint16_t buf;uint8_t *d1A,*d2A,*d1B,*d2B,*d3B;d1A=&LCD_DATE.PIN59;d1B=&LCD_DATE.PIN58;d2A=&LCD_DATE.PIN57;d2B=&LCD_DATE.PIN56;//*d3A=LCD_DATE.PIN14;  //100d3B=&LCD_DATE.PIN5;   //%SetSymbol(d3B,T1,en);if(en==0){Digit_Num(10,d1A,d1B,SEG_TYPE1);  //Digit_Num(10,d2A,d2B,SEG_TYPE1);  //// *d3B&=~T1;}else{buf=dat%10;Digit_Num(buf,d2A,d2B,SEG_TYPE1);  //dat=dat/10;buf=dat%10;if(buf!=0)Digit_Num(buf,d1A,d1B,SEG_TYPE1);  //elseDigit_Num(10,d1A,d1B,SEG_TYPE1);//*d3B|=T1;}

}

/****************************
函数名:void OutputNum(uint16_t dat)
功能:显示输出4位数码管
位置 19 20 21
****************************/
void VolNum(uint16_t dat,uint8_t en)
{
uint16_t buf;

 buf=dat%10;ShowEn(en,&buf);Digit_Num(buf,&LCD_DATE.PIN31,&LCD_DATE.PIN30,SEG_TYPE1);  //dat=dat/10;buf=dat%10;

ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN33,&LCD_DATE.PIN32,SEG_TYPE1); //
dat=dat/10;
buf=dat%10;
ShowEn(en,&buf);
Digit_Num(buf,&LCD_DATE.PIN35,&LCD_DATE.PIN34,SEG_TYPE1); //

 SetSymbol(&LCD_DATE.PIN30,T18,en);
/*
if(en==0)
{LCD_DATE.PIN30&=~T18;   //V
}
else
{LCD_DATE.PIN30|=T18;   //V
}
*/

}

/****************************
函数名:void OutputNum(uint16_t dat)
功能:显示输出4位数码管
位置 22 23
****************************/
void HZNum(uint16_t dat,uint8_t en)
{
uint16_t buf;

 buf=dat%10;ShowEn(en,&buf);Digit_Num(buf,&LCD_DATE.PIN37,&LCD_DATE.PIN36,SEG_TYPE1);  //dat=dat/10;buf=dat%10;ShowEn(en,&buf);Digit_Num(buf,&LCD_DATE.PIN39,&LCD_DATE.PIN38,SEG_TYPE1);  //SetSymbol(&LCD_DATE.PIN36,T19,en);/*if(en==0){LCD_DATE.PIN36&=~T19;   //HZ}else{LCD_DATE.PIN36|=T19;   //HZ//LCD_DATE.PIN46|=T13; //input}*/

}

//LCD_SEG.Seg.PIN8|=T8;

void SetSymbol(uint8_t *pin,uint8_t t,uint8_t en)
{

//*pin|=t;
if(en==1)
{(*pin)|=t;
}
else
{(*pin)&=~t;
}

}

/*************************

函数名:void AcIN(uint8_t en)
功能:AC符号
**************************/
void AcInSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN5,T2,en);
}

/*******************************

函数名:void FanSymbol(uint8_t en)
功能:风扇符号
******************************/
void FanSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN5,T3,en);
}

/*************************
函数名:void TypeCInSymbol(uint8_t en)
功能:TYPE充电符号

**********************/
void TypeCInSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN5,T4,en);
}

/********************************
函数名:void SolaSymbol(uint8_t en)
功能:太阳能充电符号

*****************************/
void SolaSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN58,T5,en);
}

/*****************************
函数名:void InSymbol(uint8_t en)
功能:充电中符号

LCD_SEG.Seg.PIN8|=T8;
********************************/
void InSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN7,T8,en);
//LCD_SEG.Seg.PIN8|=T8;

}

void OutSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN19,T15,en);
}

void AcOutSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN25,T20,en);
}

void UsbOutSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN25,T21,en);
}
void TypeCOutSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN25,T22,en);
}
void DcOutSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN24,T23,en);
}

void TempHotSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN24,T24,en);
}

void TempColSymbol(uint8_t en)
{
SetSymbol(&LCD_DATE.PIN25,T25,en);
}

/**************************

函数名:void DisTime(uint16_t dat)
功能:放电时间
*************************/
void DisTime(uint16_t dat)
{
TimeHour(dat,1,1);
}

/***************************
函数名:void ChgTime(uint16_t dat)
功能:充电时间

*****************************/

void ChgTime(uint16_t dat)
{
TimeHour(dat,0,1);
}

/************************************
函数名:void Disp_Num(uint16_t dat,void(*fun)(uint16_t))
功能:调用显示函数

*************************************/
void Disp_Num(uint16_t dat,void(*fun)(uint16_t,uint8_t))
{
(*fun)(dat,1);
}

Published by

风君子

独自遨游何稽首 揭天掀地慰生平