⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_display.c

📁 本公司的单相CPU卡表的源程序代码
💻 C
字号:
/*
************************************************************************
* LCDDisplay.c :
* 
********************************************************************
*/

#include "include\macro.h"  
#include "include\HardConfig.h"
#include "include\SysConfig.h"
#include "include\SubConfig.h"
#include "include\data.h"
#include "include\bitdef.h"

#include "include\FunAnnounce.h"


const char NumSeg[16] = {
	DS_Chr_0, DS_Chr_1, DS_Chr_2, DS_Chr_3,
	DS_Chr_4, DS_Chr_5, DS_Chr_6, DS_Chr_7,
	DS_Chr_8, DS_Chr_9, DS_Chr_A, DS_Chr_b, 
	DS_Chr_C, DS_Chr_d, DS_Chr_E, DS_Chr_F
};


void LCDDisplay(void)
{
 //char ptr_display;
 uchar unit_dis;
 uchar tmp_dis[6];
 uchar DisBuff[DS_Unit];
 
    Flag.even &= ~bitDisT;             //
    rest_LCDBUFF(0, &DisBuff[0]);      //显示缓冲区清零。     
     
    switch(LcdDis.ptr)
    {   
    	case DSPTR_RST:                              // all display 
            rest_LCDBUFF(1, &DisBuff[0]);      
            break;
                 

            
        case DSPTR_TEN:                              // total energy display 
            MEM_Read(E2P_TENINT ,&tmp_dis[0] ,4);  
            tmp_dis[0] =  Sram.T_ENdec;  
            DspNum( &tmp_dis[0], 4, &DisBuff[8] );
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[2] |= DS_Chr_ZONG;
            DisBuff[9] |= DS_Chr_ENG;
            DisBuff[9] |= DS_Chr_P2;
            break;

        case DSPTR_AMD:                              // Active  average demand 
            DspNum( &MDLoad.mpower[0],3, &DisBuff[8] );
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[10] |= DS_Chr_PW;
            DisBuff[10] |= DS_Chr_P1;
            break;
            
        case DSPTR_IDH:                              // meter id HIGH 
            MEM_Read(E2P_ID ,&tmp_dis[0] ,6);  
            DspNum( &tmp_dis[3], 3, &DisBuff[8] );
            DisBuff[1] |= DS_Chr_H;
            DisBuff[2] |= DS_Chr_J;
            break;          

        case DSPTR_IDL:                              // meter id LOW
            MEM_Read(E2P_ID ,&tmp_dis[0] ,6);  
            DspNum( &tmp_dis[0], 3, &DisBuff[8] );
            DisBuff[1] |= DS_Chr_L;
            DisBuff[2] |= DS_Chr_J;
            break;  

        case DSPTR_AM1:                              // ARML1  
            MEM_Read(E2P_ARML1 ,&tmp_dis[0] ,4);  
            DspNum( &tmp_dis[1], 2, &DisBuff[8] );
            DisBuff[1] |= DS_Chr_b;
            DisBuff[2] |= DS_Chr_1;
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[9] |= DS_Chr_ENG;
            break; 

        case DSPTR_AM2:                              // ARML2 
            MEM_Read(E2P_ARML2 ,&tmp_dis[0] ,4);  
            DspNum( &tmp_dis[1], 2, &DisBuff[8] );
            DisBuff[1] = DS_Chr_b;
            DisBuff[2] = DS_Chr_2;
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[9] |= DS_Chr_ENG;            
            break; 
            
        case DSPTR_OPW:                              //  over pw
            MEM_Read(E2P_LIMITMD ,&tmp_dis[0] ,3);  
            DspNum( &tmp_dis[0], 3, &DisBuff[8] );
            DisBuff[1] |= DS_Chr_C;
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[10] |= DS_Chr_PW;
            DisBuff[10] |= DS_Chr_P1;
            break; 

        case DSPTR_BUY:                              //  last time buy energy
            MEM_Read(E2P_BUY1 ,&tmp_dis[0] ,4);  
            DspNum( &tmp_dis[0], 4, &DisBuff[8] );
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[5] |= DS_Chr_BUY;
            DisBuff[9] |= DS_Chr_ENG;
            DisBuff[9] |= DS_Chr_P2;            
            break; 

        case DSPTR_ZEN:                              //  criedt energy
            MEM_Read(E2P_ZENINT ,&tmp_dis[0] ,4); 
            tmp_dis[0] =  Sram.Z_ENdec;
            DspNum( &tmp_dis[0], 4, &DisBuff[8] );
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[7] |= DS_Chr_qian;
            DisBuff[9] |= DS_Chr_ENG;
            DisBuff[9] |= DS_Chr_P2;               
            break;

        case DSPTR_RIC:                              //  IC CARD READING
            DisBuff[8] |= DS_Chr_J;  
            DisBuff[7] |= DS_Chr_J; 
            DisBuff[6] |= DS_Chr_J; 
            DisBuff[5] |= DS_Chr_J; 
            DisBuff[4] |= DS_Chr_J; 
            DisBuff[3] |= DS_Chr_J; 
            DisBuff[2] |= DS_Chr_J; 
            DisBuff[1] |= DS_Chr_J; 
            break;
                                                
        case DSPTR_TIC:                              //  IC CARD READING OK
            DisBuff[8] |= DS_Chr_J;  
            DisBuff[7] |= DS_Chr_J; 
            DisBuff[6] |= DS_Chr_d;  
            DisBuff[5] |= DS_Chr_o; 
            DisBuff[4] |= DS_Chr_o; 
            DisBuff[3] |= DS_Chr_9;
            DisBuff[2] |= DS_Chr_J; 
            DisBuff[1] |= DS_Chr_J; 
            break;

        case DSPTR_FIC:                              //  IC CARD READING ERR
            tmp_dis[0] = Card.Err_status;
            DspNum( &tmp_dis[0], 1, &DisBuff[8] ); 
            DisBuff[6] |= DS_Chr_J; 
            DisBuff[5] |= DS_Chr_C; 
            DisBuff[4] |= DS_Chr_1; 
            break;

        case DSPTR_SYS:                              //  System ERR
            tmp_dis[0] = Sram.SYSErr_status;
            DspNum( &tmp_dis[0], 1, &DisBuff[8] ); 
            DisBuff[6] |= DS_Chr_J; 
            DisBuff[5] |= DS_Chr_r; 
            DisBuff[4] |= DS_Chr_r; 
            DisBuff[3] |= DS_Chr_E; 
            break;   
                 
        case DSPTR_LEN:                              // leave energy display 
        default:    
            MEM_Read(E2P_LENINT ,&tmp_dis[0] ,4);  
            tmp_dis[0] =  Sram.L_ENdec;  
            DspNum( &tmp_dis[0], 4, &DisBuff[8] );
            DisBuff[9] |= DS_Chr_kW;
            DisBuff[9] |= DS_Chr_h;
            DisBuff[9] |= DS_Chr_Leave;
            DisBuff[9] |= DS_Chr_ENG;
            DisBuff[9] |= DS_Chr_P2;               
            break;
              
    }   // End  " switch(ptr_display)"

    // special  symbol display judge
    if(Flag.even & bitPGKen)     DisBuff[11] |= DS_Chr_Pkey;
    if(Flag.run & bitR_REV)      DisBuff[11] |= DS_Chr_Erev;
     if(pin_CKUSER == 0)         DisBuff[9] |= DS_Chr_duan;
     
    Write_HL6024(&DisBuff[0]);     //写入液晶数据
        
}

//*****************************************************************
//  Function:                  
//  Description:                                         
//  Others:           
//***************************************************************
void rest_LCDBUFF(uchar mod, uchar* ptr)
{
 char tmp;
 char i;
 
        tmp=0XFF;
        if(mod == 0)  tmp=0;
        for(i=0; i<=DS_BDig; i++)
        {
                *ptr=tmp;
                ptr++;        
        }          
}


//*****************************************************************
//  Function:       DspNum( char *Addr, char Lenth, char *SegPtr )             
//  Description:    获取液晶显示的数字部分的BUFF值                                         
//  Others:           
//***************************************************************
void DspNum( uchar *Addr, uchar Lenth, uchar *SegPtr )
{
    if( Lenth > 4) return;
	while( Lenth>0 )
    {
		*SegPtr-- |= NumSeg[(*Addr) & 0x0F];
		*SegPtr-- |= NumSeg[*Addr>>4 & 0x0F] ;
		Addr++;
		Lenth--;
    }

}



//*****************************************************************
//  Function:                  
//  Description:                                         
//  Others:           
//***************************************************************
void LCDStatus_Trig(uchar mod)
{
 
    switch(mod)
    {
    	case DISTG_RESERT:
    	    LcdDis.staus = (DIS_STU_RST<<4);  
    	    LcdDis.ptr = DSPTR_RST; 
    	    LcdDis.tmrMd = DSTMR_RST;
    	    break;

    	case DISTG_AUTO:
    	    LcdTmr_autodec();    	    
    	    break;    	    

    	case DISTG_KEY:
    	    LcdTmr_KeyTg();    	    
    	    break; 

    	case DISTG_CARDIN:
    	    LcdDis.staus = (DIS_STU_IC0<<4)+ DISSUBIC0_COM;
    	    LcdDis.ptr = DSPTR_RIC; 
    	    LcdDis.tmrMd =DSTMR_IC;    	    
    	    break; 
    	    
    	default:
    	    FstCycDis_int(); 
    	    break;   	        	        	        	     
    }       
}



//*****************************************************************
// LCD_display time dec
//***************************************************************/
void LcdTmr_autodec(void)
{ 	
    LcdDis.tmrMd--;
    if(LcdDis.tmrMd ==0)
    {
        switch(LcdDis.staus&0xf0)
        {
            case DIS_STU_RST<<4:
                LcdDis.staus = (DIS_STU_CYC<<4) + DISSUBCYC_LEN;
                FstCycDis_int();
                break;
                   
            case DIS_STU_CYC<<4:
                LcdDis.staus++;
                LcdDis.tmrMd =DSTMR_ATO; 
                if((LcdDis.staus&0x0f) > DISSUBCYC_SYS)  LcdDis.staus = (DIS_STU_CYC<<4)+DISSUBCYC_LEN;             
                if((LcdDis.staus&0x0f) ==DISSUBCYC_LEN)  FstCycDis_int();  
                if((LcdDis.staus&0x0f) ==DISSUBCYC_TEN)  LcdDis.ptr = DSPTR_TEN;          //
                if((LcdDis.staus&0x0f) ==DISSUBCYC_CMD)  LcdDis.ptr = DSPTR_AMD;          //
                if((LcdDis.staus&0x0f) ==DISSUBCYC_SYS)  
                {
                    if(Sram.SYSErr_status != SYSERR_OK)
                    {
                    	 LcdDis.ptr = DSPTR_SYS;
                    }
                    else
                    {
                    	FstCycDis_int();
                    }
                } 
                        
                break;
                

            case DIS_STU_IC0<<4:
                LcdDis.staus++;
                if((LcdDis.staus&0x0f) == DISSUBIC0_OK)
                {
                    if(Sram.IcErr_status != ERR_IC_OK)
                    {   
                    	LcdDis.tmrMd =DSTMR_IC;
                        LcdDis.ptr = DSPTR_FIC;    //fail
                    }
                    else
                    {   
                        LcdDis.tmrMd =DSTMR_IC;     
                        LcdDis.ptr = DSPTR_TIC;    //succeed                  
                    }				
                }
                
                if((LcdDis.staus&0x0f) == DISSUBIC0_BUY)
                {
                    if(Flag.prepay & bitP_buy)
                    {
                        LcdDis.tmrMd =DSTMR_ATO; 	
                        LcdDis.ptr = DSPTR_BUY;                     
                    }
                    else
                    {
                    	Flag.prepay &= ~bitP_buy;
                        if(pin_ICKEY == 0)                   //have IC card
                        {
                            LcdDis.tmrMd =DSTMR_ATO;	
                            LcdDis.staus = (DIS_STU_IC1<<4) +DISSUBIC1_IDH;     // change status.
                            LcdDis.ptr = DSPTR_IDH;
                        }
                        else                                      //no IC card
                        {
                            FstCycDis_int();	                
                        }
                    }
                }
                
                if((LcdDis.staus&0x0f) >DISSUBIC0_BUY)
                {
                    LcdDis.tmrMd =DSTMR_ATO;	
                    LcdDis.staus = (DIS_STU_IC1<<4) +DISSUBIC1_IDH;     // change status.
                    LcdDis.ptr = DSPTR_IDH;
                }
                break;

            case DIS_STU_IC1<<4:                                 //have IC card
                LcdDis.staus++;                 
                LcdDis.tmrMd =DSTMR_ATO;  	
                if((LcdDis.staus&0x0f)==DISSUBIC1_IDH)  LcdDis.ptr = DSPTR_IDH;
                if((LcdDis.staus&0x0f)==DISSUBIC1_IDL)   LcdDis.ptr = DSPTR_IDL;
                if((LcdDis.staus&0x0f)==DISSUBIC1_BAM1)  LcdDis.ptr = DSPTR_AM1;
                if((LcdDis.staus&0x0f)==DISSUBIC1_BAM2)  LcdDis.ptr = DSPTR_AM2;
                if((LcdDis.staus&0x0f)==DISSUBIC1_OMD)   LcdDis.ptr = DSPTR_OPW;
                if((LcdDis.staus&0x0f) >DISSUBIC1_OMD)  FstCycDis_int();
                break;    
            
            default:
               FstCycDis_int();                                              
        }	 
    }
}

/*******************************************************************
* display key  in effect 
********************************************************************/
void LcdTmr_KeyTg(void)
{
    switch(LcdDis.staus&0xf0)
    {                   
            case DIS_STU_CYC<<4:
                LcdDis.staus++;
                LcdDis.tmrMd =DSTMR_KEY; 
                if((LcdDis.staus&0x0f) > DISSUBCYC_SYS)  LcdDis.staus = (DIS_STU_CYC<<4)+DISSUBCYC_LEN;             
                if((LcdDis.staus&0x0f) ==DISSUBCYC_LEN)  FstCycDis_int();  
                if((LcdDis.staus&0x0f) ==DISSUBCYC_TEN)  LcdDis.ptr = DSPTR_TEN;          //
                if((LcdDis.staus&0x0f) ==DISSUBCYC_CMD)  LcdDis.ptr = DSPTR_AMD;          //
                if((LcdDis.staus&0x0f) ==DISSUBCYC_SYS)  
                {
                    if(Sram.SYSErr_status != SYSERR_OK)
                    {
                    	 LcdDis.ptr = DSPTR_SYS;
                    }
                    else
                    {
                    	FstCycDis_int();
                    }
                } 
                        
                break;
        
            case DIS_STU_IC1<<4:                                 //have IC card
                LcdDis.staus++;                 
                LcdDis.tmrMd =DSTMR_KEY;  	
                if((LcdDis.staus&0x0f)==DISSUBIC1_IDH)  LcdDis.ptr = DSPTR_IDH;
                if((LcdDis.staus&0x0f)==DISSUBIC1_IDL)   LcdDis.ptr = DSPTR_IDL;
                if((LcdDis.staus&0x0f)==DISSUBIC1_BAM1)  LcdDis.ptr = DSPTR_AM1;
                if((LcdDis.staus&0x0f)==DISSUBIC1_BAM2)  LcdDis.ptr = DSPTR_AM2;
                if((LcdDis.staus&0x0f)==DISSUBIC1_OMD)   LcdDis.ptr = DSPTR_OPW;
                if((LcdDis.staus&0x0f) >DISSUBIC1_OMD)  FstCycDis_int();
                break;    
            
            default:
               FstCycDis_int();                                              
    }	 
}

//*****************************************************************
// intlize frist item of cycle display.
//***************************************************************/
void FstCycDis_int(void)
{
  uchar data;
    LcdDis.staus = (DIS_STU_CYC<<4)+DISSUBCYC_LEN;
    LcdDis.tmrMd = (DSTMR_ATO<<1);
    LcdDis.ptr = DSPTR_LEN;
    if(Sram.creditSTU == USE_CREDIT)    LcdDis.ptr = DSPTR_ZEN;   
}





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -