
//****************************************************************************
// @Module        Project Settings
// @Filename     Lcd_Yddc8189.c
// @Project        Sem3000 
//----------------------------------------------------------------------------
// @Controller    SI1010
//
// @Compiler      KEIL uVision V
//
// @ Frequency   Using internal clock MHz
//
// @Codegenerator 0.1
//
// @Description   This file contains the Project voice recoding  function.
//
//----------------------------------------------------------------------------
// @Date          2013-05-28  
//
//****************************************************************************

#define _LCD_HT16C24_C_


#include "PROJECT_INCLUDES.H"


//idata U32 volatile BCD_Code;
//idata U32 volatile Display_Data;
xdata U32 volatile BCD_Code;
xdata U32 volatile Display_Data;
extern U8 SETKEY_LONG;

void Check_Peak_Time_alarm(void) ;
extern void LCD_Display_Today_Graph_PowerData(volatile U8 ID);

/*
*********************************************************************************************************
*                                                                   Converted_to_Numeric
*
* Description:    ASCII Code 문자를  숫자 값으로 변환
*
* Arguments  :   a_Char:  변환을 원하는 ASCII Code 문자 입력 
*                    
*
* Returns    :     Num:  변환된 숫자 값  

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


static UBYTE Converted_to_Numeric(volatile char a_Char)
{
	idata UBYTE volatile Num;

	if(a_Char == '-' ) return CHR_MINUS; 

	if(a_Char == ' ' ) return CHR_BNK;
		
	if(a_Char > '9' )Num = a_Char - 'A' + 10; 
	else Num = a_Char -'0';

	return Num;
}


/*
*********************************************************************************************************
*                                                                   BIN2BCD
*
* Description:    BIN Code 문자를  BCD Code 값으로 변환
*
* Arguments  :   Value:  변환을 원하는 BIN Code 문자 입력 (8bit ~32 bit  Multi )
*                    
*
* Returns    :     Num:  BCD Code  값  (8bit ~32 bit  Multi )

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

#define Max_Converter 5

U32 BIN2BCD(volatile U32 Value)
{
	idata U8   volatile  i;
	
	char NumToTextCnvBuf[5];

	BCD_Code=0;
	
	sprintf(NumToTextCnvBuf,"%05ld", Value);		
	   
	for(i=0;  i < Max_Converter; i++) {
		
		       BCD_Code<<=SHIF_NIBBLE;
			   
			BCD_Code |=Converted_to_Numeric( NumToTextCnvBuf[i]);
	}

	return BCD_Code;
}



/**************************** LCD ROUTINE **************************************/


void LCD_BufferClear(void)
{
	volatile U8 i;

	for(i = 0; i < LCD_BufMax; i++) {
		LCDMap.LCD_ByteCtrl[i]=0; 
		Attribute.LCD_ByteCtrl[i]=LCD_NORMAL_DISPLAY; 
	}
}

void LCD_Blink_Attribute(volatile bit bitAttribute){
	Attribute.LCD_BitCtrl.SEG42_SETING_TIME_2DOT =bitAttribute ;  //1 시계 (:)  깜박임  
}

void LCD_Display_Home_Menu(void)
{
	LCD_BufferClear();
	LCD_Blink_Attribute(LCD_INVERSE_DISPLAY_bit);
	LCD_InverseMask=LCD_NORMAL_DISPLAY;
	// Menu Button Init 
	LCDMap.LCD_BitCtrl.SEG45_BUTTON_CHANGE 		= 1;
	LCDMap.LCD_BitCtrl.SEG45_BUTTON_MENU 		= 1;
	LCDMap.LCD_BitCtrl.SEG52_BUTTON_down_arrow 	= 1;
	LCDMap.LCD_BitCtrl.SEG56_BUTTON_up_arrow 	= 1;

#ifdef SET_ONOFFTIMER
	if(!OnOffTimer_WebSetted)
	{
		if(OnOffTimer.timer_onoff[Display_Channel-1])
		{
			LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON		= 1;
			LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF		= 0;
		}
		else
		{
			LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON		= 0;
			LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF		= 1;
		}
	}
#endif

	if(SETKEY_LONG)
		LCDMap.LCD_BitCtrl.SEG58_BUTTON_SET 			= 1;
	else
		LCDMap.LCD_BitCtrl.SEG57_BUTTON_Channel 		= 1;

	//NOW_COST_UNIT_JAPAN_ON;
	//NOW_COST_Won_ON;
	NOW_COST_Won_OFF;

	LCDMap.LCD_BitCtrl.SEG42_SETING_TIME_2DOT 	= 1;
	NOW_ENG_CONSOMPTION_W_OFF;

	LCD_Write();  


}


void LCD_init(void)
{ 
	PCA8538Init();

	Lcd_Dispaly_Timer = timer_mSecHandleAssign(); 
	Lcd_Blik_Timer=0;

	timer_mSecTimerSet(Lcd_Dispaly_Timer, LCD_DSPLAY_TIME_TIC);  
	//timer_mSecTimerSet(Lcd_Blik_Timer, 	     LCD_BLINK_TIME_TIC);  
	
	LCD_Display_Home_Menu();  // Lcd Display Initialization
	#if 1
	Lcd_Day_Display_Timer = timer_mSecHandleAssign(); 
	timer_mSecTimerSet(Lcd_Day_Display_Timer, LCD_DSPLAY_TIME_TIC*5);  
	#endif
}





void Set_Lcd_Char_Attribute(volatile U8 SetLcdSegmentLocation, volatile bit bitAttribute)
{

	switch(SetLcdSegmentLocation){ 

		    case LCD_Map_Bufer_TRAN_Battery_Base_Index: 	
								//Attribute.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_0=bitAttribute;
								Attribute.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_1=bitAttribute;
								Attribute.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_2=bitAttribute;
								Attribute.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_3 =bitAttribute;
								break;


		case LCD_Map_Bufer_Main_Battery_Base_Index: 	
								Attribute.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_1 =bitAttribute;
								Attribute.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_2 =bitAttribute;	
								Attribute.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_3 =bitAttribute;	
								break;

		case FUNCTION_F: Attribute.LCD_BitCtrl.SEG31_NOW_ENG_F=bitAttribute;  break;
		case TIMER_SLOT_Digit1 : 			
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28A=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28B=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28C=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28D=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28E=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28F=bitAttribute;
								Attribute.LCD_BitCtrl.SEG46_DIGIT1_28G=bitAttribute;
								break;
								
			
	 	case Now_Energy_Digit3:
	 	case Now_Energy_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4A 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4B 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4C 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4D 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4E 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4F 	= bitAttribute; 
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4G 	= bitAttribute; 

    	 		     	Attribute.LCD_BitCtrl.SEG3_DIGIT4_3A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3B 	=  bitAttribute; 
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3C 	=  bitAttribute; 
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3D 	=  bitAttribute; 
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3E 	=  bitAttribute; 
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3F 	=  bitAttribute; 
    	  			Attribute.LCD_BitCtrl.SEG3_DIGIT4_3G 	=  bitAttribute; 
				break;
			
		case SETING_TIME_Hour_Digit1: 
		case SETING_TIME_Hour_Digit2: 

				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30A=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30B=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30C=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30D=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30E=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30F=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG48_DIGIT1_30G=bitAttribute; 

				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29A=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29B=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29C=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29D=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29E=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29F=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG47_DIGIT2_29G=bitAttribute; 
				
				break;

		case SETING_TIME_Minute_Digit1: 
		case SETING_TIME_Minute_Digit2: 

				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32A=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32B=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32C=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32D=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32E=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32F=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG50_DIGIT1_32G=bitAttribute; 

				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31A=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31B=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31C=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31D=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31E=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31F=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG49_DIGIT2_31G=bitAttribute; 
				
				break;

		case Week_Set:
				Attribute.LCD_BitCtrl.SEG43_SETING_TIME_Sun=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG44_SETING_TIME_Mon=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG45_SETING_TIME_Tue=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG37_SETING_TIME_Wed=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG37_SETING_TIME_Thu=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG37_SETING_TIME_Fri=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG37_SETING_TIME_Sat=bitAttribute; 
				break;
		case Cost_Unit_Digit :
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18A=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18B=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18C=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18D=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18E=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18F=bitAttribute; 
				Attribute.LCD_BitCtrl.SEG_DIGIT1_18G=bitAttribute; 
				break;
		case Now_COST_Digit1: 
    	 		     	Attribute.LCD_BitCtrl.SEG17_DIGIT1_11A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11B 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11C 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11D 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11E 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11F 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG17_DIGIT1_11G 	=  bitAttribute;
    				break;
					
	 	case Now_COST_Digit2:
    	 		     	Attribute.LCD_BitCtrl.SEG16_DIGIT2_10A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10B 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10C 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10D 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10E 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10F 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG16_DIGIT2_10G 	=  bitAttribute;
    				break;
					
	 	case Now_COST_Digit3:
    	 		     	Attribute.LCD_BitCtrl.SEG15_DIGIT3_9A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9B 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9C 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9D 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9E 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9F 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG15_DIGIT3_9G 	=  bitAttribute;
    				break;
					
	 	case Now_COST_Digit4:
    	 		     	Attribute.LCD_BitCtrl.SEG14_DIGIT4_8A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8B 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8C 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8D 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8E 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8F 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG14_DIGIT4_8G 	=  bitAttribute;
    			 	break;
					
	 	case Now_COST_Digit5:
    	 		     	Attribute.LCD_BitCtrl.SEG13_DIGIT5_7A 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7B 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7C 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7D 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7E 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7F 	=  bitAttribute;
    	  			Attribute.LCD_BitCtrl.SEG13_DIGIT5_7G 	=  bitAttribute;
    				break;
	 	
	//U8 SEG13_DIGIT5_7A 	:1;  	//8A

		default:   break;
	}
	 
}

void LcdPutChar(volatile U8 SetLcdSegmentLocation, volatile U8 DisplayChr)
{
	 LCDFont.LCDByte = table_fnd[DisplayChr];
	 
	 switch(SetLcdSegmentLocation){ 
	 	
	 	case Cost_Unit_Digit:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG_DIGIT1_18A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG_DIGIT1_18G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case RF_Channel:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG1_DIGIT1_1G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case RF_Channel_Digit2:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG98_DIGIT1_1G 	=  LCDFont.LCDBit.SEG_G;
    				break;
    				 
	 	case Now_Energy_Digit1:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG6_DIGIT1_6G 	=  LCDFont.LCDBit.SEG_G;

			//	printf("\n 1=%d", (U16)DisplayChr);  //, (U16)LCDFont.LCDByte);	
    				break;
					
	 	case Now_Energy_Digit2:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG5_DIGIT2_5G 	=  LCDFont.LCDBit.SEG_G;
			//	printf(" 2=%d",(U16)DisplayChr);  //, (U16)LCDFont.LCDByte);	
    				break;
					 	
	 	case Now_Energy_Digit3:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG4_DIGIT3_4G 	=  LCDFont.LCDBit.SEG_G;
			//	printf(" 3=%d",(U16)DisplayChr);  //, (U16)LCDFont.LCDByte);	
    				break;
					
	 	case Now_Energy_Digit4:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG3_DIGIT4_3G 	=  LCDFont.LCDBit.SEG_G;
			//	printf(" 4=%d", (U16)DisplayChr);  //,(U16)LCDFont.LCDByte);	
    				break;
					
	 	case Now_Energy_Digit5:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG2_DIGIT5_2G 	=  LCDFont.LCDBit.SEG_G;
			//	printf(" 5=%d",(U16)DisplayChr);  //, (U16)LCDFont.LCDByte);	
    				break;
    				 
	 	case POWER_CONSOMPTION_Digit1: 
			
    	 		     	LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG11_DIGIT1_16G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case POWER_CONSOMPTION_Digit2:
			
    	 		     	LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG10_DIGIT2_15G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case POWER_CONSOMPTION_Digit3:
    	 		     	LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG9_DIGIT3_14G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case POWER_CONSOMPTION_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG8_DIGIT4_13G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case POWER_CONSOMPTION_Digit5:
    	 		     	LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG7_DIGIT5_12G 	=  LCDFont.LCDBit.SEG_G;
    				break;
                 
	 	case Now_COST_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG17_DIGIT1_11G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case Now_COST_Digit2:
    	 		     	LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG16_DIGIT2_10G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case Now_COST_Digit3:
    	 		     	LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG15_DIGIT3_9G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case Now_COST_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG14_DIGIT4_8G 	=  LCDFont.LCDBit.SEG_G;
    			 	break;
					
	 	case Now_COST_Digit5:
    	 		     	LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG13_DIGIT5_7G 	=  LCDFont.LCDBit.SEG_G;
    				break;
	 	
	 	case HISTORY_COST_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG24_DIGIT1_26G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_COST_Digit2:
    	 		     	LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG23_DIGIT2_25G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_COST_Digit3:
    	 		     	LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG22_DIGIT3_24G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_COST_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG21_DIGIT4_23G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_COST_Digit5:
    	 		     	LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG20_DIGIT5_22G 	=  LCDFont.LCDBit.SEG_G;
    				break;
    				 
	 	case HISTORY_COST_GRAPH_UNIT_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG25_DIGIT1_27G 	=  LCDFont.LCDBit.SEG_G;
    				break;
	 	
	 	case HISTORY_PWOER_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG36_DIGIT1_21G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_PWOER_Digit2:
    	 		     	LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG35_DIGIT2_20G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_PWOER_Digit3:
    	 		     	LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG34_DIGIT3_19G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_PWOER_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG33_DIGIT4_18G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case HISTORY_PWOER_Digit5:
    	 		     	LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG32_DIGIT5_17G 	=  LCDFont.LCDBit.SEG_G;
    				break;
	  			
	 	case TIMER_SLOT_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG46_DIGIT1_28G 	=  LCDFont.LCDBit.SEG_G;
    				break;
    				 
	 	case SETING_TIME_Hour_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG48_DIGIT1_30G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					 
	 	case SETING_TIME_Hour_Digit2: 
    	 		       LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG47_DIGIT2_29G 	=  LCDFont.LCDBit.SEG_G;
    				break;
    				 
	 	case SETING_TIME_Minute_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG50_DIGIT1_32G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case SETING_TIME_Minute_Digit2: 
    	 		     	LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG49_DIGIT2_31G 	=  LCDFont.LCDBit.SEG_G;
    				break;

	 	case THRESHOLD_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG54_DIGIT1_36G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case THRESHOLD_Digit2:
    	 		     	LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG53_DIGIT2_35G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case THRESHOLD_Digit3:
    	 		     	LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG52_DIGIT3_34G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case THRESHOLD_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33G 	=  LCDFont.LCDBit.SEG_G;
    				break;

	 	case CO2_Digit1: 
    	 		     	LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG59_DIGIT1_41G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case CO2_Digit2:
    	 		     	LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG58_DIGIT2_40G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case CO2_Digit3:
    	 		    	 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39A 	=  LCDFont.LCDBit.SEG_A;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39B 	=  LCDFont.LCDBit.SEG_B;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39C 	=  LCDFont.LCDBit.SEG_C;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39D 	=  LCDFont.LCDBit.SEG_D;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39E 	=  LCDFont.LCDBit.SEG_E;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39F 	=  LCDFont.LCDBit.SEG_F;
    	  			 LCDMap.LCD_BitCtrl.SEG57_DIGIT3_39G 	=  LCDFont.LCDBit.SEG_G;
    				 break;
					 
	 	case CO2_Digit4:
    	 		     	LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG56_DIGIT4_38G 	=  LCDFont.LCDBit.SEG_G;
    				break;
					
	 	case CO2_Digit5:
    	 		     	LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37A 	=  LCDFont.LCDBit.SEG_A;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37B 	=  LCDFont.LCDBit.SEG_B;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37C 	=  LCDFont.LCDBit.SEG_C;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37D 	=  LCDFont.LCDBit.SEG_D;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37E 	=  LCDFont.LCDBit.SEG_E;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37F 	=  LCDFont.LCDBit.SEG_F;
    	  			LCDMap.LCD_BitCtrl.SEG55_DIGIT5_37G 	=  LCDFont.LCDBit.SEG_G;
    				break;
		default: break;
	 }
}




void LcdPut_Digit_1(volatile U8 SetLcdSegmentLocation, volatile U8 DisplayData )
{
	if(DisplayData ==LCD_DEL) {
		
			LcdPutChar(SetLcdSegmentLocation, LCD_DEL);

	}
	else {
			DisplayData=(U8)BIN2BCD(DisplayData);

			LcdPutChar(SetLcdSegmentLocation,  DisplayData & LSB_NIBBLE_MAST);
	}
	
}



                                        
void Lcd_Put_Number(volatile U8 idata SetLcdSegmentLocation, volatile U32 DisplayData, volatile U8 idata  NumLen )
{
	volatile U8 idata  Dsp_Po;
	volatile U8 idata  Dsp_Num;

	Dsp_Po=SetLcdSegmentLocation;

	Display_Data=0;
	
      Display_Data=BIN2BCD(DisplayData);

	if(get_minus_temp())
	LCDMap.LCD_BitCtrl.SEG51_DIGIT4_33G 	=  1;
	
	Dsp_Num=0;
	do
	{		
		if(Dsp_Num==0){ LcdPutChar(Dsp_Po,  (U8)(Display_Data& LSB_NIBBLE_MAST));     
		}
		else {
				if( !Display_Data)LcdPutChar(Dsp_Po,  LCD_DEL);     
			 	else                      LcdPutChar(Dsp_Po,  (U8)(Display_Data& LSB_NIBBLE_MAST)); 
		}
		
		Display_Data >>= SHIF_NIBBLE;  
		Dsp_Po++;
		Dsp_Num++;
		
   	}while(Dsp_Num !=NumLen);

	
}

void Lcd_Put_Number1(volatile U8 idata SetLcdSegmentLocation, volatile U32 DisplayData, volatile U8 idata  NumLen )
{
	volatile U8 idata  Dsp_Po;
	volatile U8 idata  Dsp_Num;

	Dsp_Po=SetLcdSegmentLocation;

	Display_Data=0;
	
      Display_Data=BIN2BCD(DisplayData);
	
	Dsp_Num=0;
	do
	{		
		LcdPutChar(Dsp_Po,  (U8)(Display_Data& LSB_NIBBLE_MAST));     
			
		Display_Data >>= SHIF_NIBBLE;  
		Dsp_Po++;
		Dsp_Num++;
		
   	}while(Dsp_Num !=NumLen);

	
}


                                        
void LcdPutByte(volatile U8 SetLcdSegmentLocation, volatile U8 DisplayData )
{
	volatile U8 PutData;
	
	DisplayData=(U8)BIN2BCD(DisplayData);

	PutData = DisplayData & LSB_NIBBLE_MAST;                         // LSB Byte Display
	LcdPutChar(SetLcdSegmentLocation,  PutData);

												
	PutData = DisplayData >> SHIF_NIBBLE;                                 // MSB Byte Display	
	LcdPutChar(SetLcdSegmentLocation+1 , PutData);    
}






															
void LCD_Dsp_Yesterday_Power(volatile U8 Dsp_Item, volatile U32 Power){

	HISTORY_POWER_THIS_ON;

	HISTORY_POWER_DAY_OFF;
	HISTORY_POWER_WEEK_OFF;
	HISTORY_POWER_MONTH_OFF;
	HISTORY_POWER_Kwh_OFF;

	LCDMap.LCD_BitCtrl.SEG35_HISTORY_POWER_DOT1=0;	
	LCDMap.LCD_BitCtrl.SEG34_HISTORY_POWER_DOT2=0;	

	//Power=18888888;

	//printf("\n Dsp_Item = %d", Dsp_Item );
		
	switch(Dsp_Item ){
		
		case DAY_POWER: HISTORY_POWER_DAY_ON; 			break;
							
		case WEEK_POWER: HISTORY_POWER_WEEK_ON;			break;
							
		case THIS_MONTH_POWER: HISTORY_POWER_MONTH_ON;	break;
		
		case MONTH_POWER: HISTORY_POWER_THIS_OFF; HISTORY_POWER_MONTH_ON; 		break;
		default : break;
	}

		//printf("\n Yesterday_Power = %ld", Power );

	if(Power>=1000000)
	{
		Power /=1000;

		//printf("\n Power_1 = %ld", Power );
		
		HISTORY_POWER_Kwh_ON;    //1 Kwh 표시 ;
		//LCDMap.LCD_BitCtrl.SEG35_HISTORY_POWER_DOT1=0;	
		
	}
	
	else if(100000<=Power&&Power<1000000)
	{
		Power /=100;

		//printf("\n Power_2 = %ld", Power );
		
		HISTORY_POWER_Kwh_ON;    //1 Kwh 표시 ;
		LCDMap.LCD_BitCtrl.SEG35_HISTORY_POWER_DOT1=1;	
			
	}	
	else if(1000<=Power&&Power<100000)
	{
		Power /=10;

		//printf("\n Power_3 = %ld", Power );
		
		HISTORY_POWER_Kwh_ON;    //1 Kwh 표시 ;
		LCDMap.LCD_BitCtrl.SEG34_HISTORY_POWER_DOT2=1;	
			
	}		
	Lcd_Put_Number(HISTORY_PWOER_Digit1, Power,5);

}

                                                                     //Index          0       1        2        3            
                                                          	         //Level           2       3        4        5   
code	U8 Graph_Level_Table    [LCD_Graph_Level_Max-1]={ 0x01, 0x03, 0x07, 0x0f};	// 1, 3, 7, 15

code	U8 Graph_Level_1_Table[LCD_Graph_Level_Max+1]={ 0x40, 0x20, 0x10, 0x08, 0x04,0x02};	//64, 32, 16, 8, 4, 2


#define BIT_MSK 0x0f

void LCD_Set_Graph_Level(volatile U8 Dsp_Item, volatile U8 Dsp_Position, volatile U8 Dsp_Level){

	if(Dsp_Level>5)Dsp_Level=5;

	//printf("\n Dsp_Level = %d ",Dsp_Level);	

     	if(Dsp_Item==TODAY_GRAPH){

			LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_YESTERDAY_Base_Index-Dsp_Position] &= ~BIT_MSK;  // LVEL 2 -- 5  CLEAR
			
			//printf("\n Dsp_Position = %d ", Dsp_Position);
			
			LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_YESTERDAY_Base_Index_Lvel_1] &= ~Graph_Level_1_Table[Dsp_Position];  // LVEL 1  CLEAR

			//printf("\n Graph_Level_1_Table = %d Dsp_Position = %d ",Dsp_Level, Graph_Level_1_Table, Dsp_Position);

			if(Dsp_Level) // LVEL 1  SET
			{
				LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_YESTERDAY_Base_Index_Lvel_1]  |= Graph_Level_1_Table[Dsp_Position];

				//printf("\n 1 Dsp_Level = %d Graph_Level_1_Table = %d Dsp_Position = %d ",Dsp_Level, Graph_Level_1_Table, Dsp_Position);	
			}	
			
			if(Dsp_Level>Level_1) // LVEL 2 -- 5  SET
			{
				LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_YESTERDAY_Base_Index-Dsp_Position] |=Graph_Level_Table[Dsp_Level-Level_2];

				//printf("\n 2 Dsp_Level = %d Graph_Level_Table = %d Dsp_Position = %d ",Dsp_Level, Graph_Level_Table, Dsp_Position);
			}

			//printf("\n Dsp_Item = %d Dsp_Level = %d Graph_Level_Table = %d Dsp_Position = %d ",Dsp_Item, Dsp_Level, Graph_Level_Table, Dsp_Position);
							
     	}
     	
	else {
			LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_Mon_Index-Dsp_Position] &= ~BIT_MSK;  // LVEL 2 -- 5  CLEAR
			if(Dsp_Level) 
			{
					switch(Dsp_Position)
					{
						case Mon_7:  LCDMap.LCD_BitCtrl.SEG39_HISTORY_7_GRAPH_MON_LEVEL1=1;  break;   // LVEL 1  SET 
						case Tue_6:   LCDMap.LCD_BitCtrl.SEG38_HISTORY_7_GRAPH_Tue_LEVEL1=1;  break;   // LVEL 1  SET 
						case Wed_5:  LCDMap.LCD_BitCtrl.SEG26_HISTORY_7_GRAPH_Wed_LEVEL1=1;  break;   // LVEL 1  SET 
						case Thu_4:   LCDMap.LCD_BitCtrl.SEG27_HISTORY_7_GRAPH_Thu_LEVEL1=1;  break;   // LVEL 1  SET 
						case Fri_3:   	LCDMap.LCD_BitCtrl.SEG28_HISTORY_7_GRAPH_Fri_LEVEL1=1;  break;   // LVEL 1  SET 
						case Sat_2:   LCDMap.LCD_BitCtrl.SEG29_HISTORY_7_GRAPH_Sat_LEVEL1=1;  break;   // LVEL 1  SET 
						case Sun_1:  LCDMap.LCD_BitCtrl.SEG30_HISTORY_7_GRAPH_Sun_LEVEL1=1;  break;   // LVEL 1  SET 
						default:    break;
					}
					
					if(Dsp_Level>Level_1)   // LVEL 2 -- 5  SET
					{
						LCDMap.LCD_ByteCtrl [LCD_Map_Bufer_Mon_Index-Dsp_Position] |=Graph_Level_Table[Dsp_Level-Level_2];
					}
						//printf("\n else Dsp_Level = %d Dsp_Position = %d ", Dsp_Level, Dsp_Position);
					
			}	
			else {
					switch(Dsp_Position)
					{
						case Mon_7:  LCDMap.LCD_BitCtrl.SEG39_HISTORY_7_GRAPH_MON_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						case Tue_6:   LCDMap.LCD_BitCtrl.SEG38_HISTORY_7_GRAPH_Tue_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						case Wed_5:  LCDMap.LCD_BitCtrl.SEG26_HISTORY_7_GRAPH_Wed_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						case Thu_4:   LCDMap.LCD_BitCtrl.SEG27_HISTORY_7_GRAPH_Thu_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						case Fri_3:   	LCDMap.LCD_BitCtrl.SEG28_HISTORY_7_GRAPH_Fri_LEVEL1=0;  break;   // LVEL 1  CLEAR
						case Sat_2:   LCDMap.LCD_BitCtrl.SEG29_HISTORY_7_GRAPH_Sat_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						case Sun_1:  LCDMap.LCD_BitCtrl.SEG30_HISTORY_7_GRAPH_Sun_LEVEL1=0;  break;   // LVEL 1  CLEAR 
						default:    break;
					}
			}
						//printf("\n else Dsp_Position = %d ", Dsp_Position);
						
	 }
	 
}

void HISTORY_Week_Graph(U8 value)
{
	LCDMap.LCD_BitCtrl.SEG39_HISTORY_7_GRAPH_MON=value;
	LCDMap.LCD_BitCtrl.SEG38_HISTORY_7_GRAPH_Tue=value;
	LCDMap.LCD_BitCtrl.SEG26_HISTORY_7_GRAPH_Wed=value;
	LCDMap.LCD_BitCtrl.SEG27_HISTORY_7_GRAPH_Thu=value;
	LCDMap.LCD_BitCtrl.SEG28_HISTORY_7_GRAPH_Fri=value;
	LCDMap.LCD_BitCtrl.SEG29_HISTORY_7_GRAPH_Sat=value;
	LCDMap.LCD_BitCtrl.SEG30_HISTORY_7_GRAPH_Sun=value;
}

void LCD_Display_Graph(volatile U8 Dsp_Item)
{
//	U8 volatile  Dsp_Level;
	int State;
//	volatile  U32 Grap_Unit, Grap_Unit1;
//	volatile unsigned long address;
	
	POWR_DATA 	sWeek;
	CPOWERS_AUG Get_Power;
		
	Get_Power.year=   (U8)(event1.years-2000);
	Get_Power.month=		event1.output_month;
	Get_Power.day=   		event1.output_days;
	Get_Power.channel_num=Display_Channel-1;		
	
	Get_Power.hour= event1.hours;

	sWeek.Year=		Get_Power.year;
	sWeek.Month=	Get_Power.month;
	sWeek.Day=		Get_Power.day;
	
	Search_Weekly_SunDay( &sWeek, WEEK_);

	Get_Power.week=sWeek.Week;

	Get_Power.power=0;
	
	switch(Dsp_Item)
	{	  

	   case WEEK_GRAPH:
						#if 0   /// original 
						Grap_Unit=event1.Week_Peak_Power[Display_Channel-1];
						#else  // cmlee
				//		Grap_Unit=event1.Week_Peak_Power[Display_Channel-1];  //summation of 1 week ;;; inconsistency ;;;
				//		Grap_Unit1=event1.Week_Peak_Power[Display_Channel-1];
						#endif
						
						HISTORY_Week_Graph(1);
						
						LCDMap.LCD_BitCtrl.SEG39_HISTORY_7_GRAPH_7=0;
						LCDMap.LCD_BitCtrl.SEG38_HISTORY_7_GRAPH_6=0;
						LCDMap.LCD_BitCtrl.SEG26_HISTORY_7_GRAPH_5=0;
						LCDMap.LCD_BitCtrl.SEG27_HISTORY_7_GRAPH_4=0;
						LCDMap.LCD_BitCtrl.SEG28_HISTORY_7_GRAPH_3=0;
						LCDMap.LCD_BitCtrl.SEG29_HISTORY_7_GRAPH_2=0;
						LCDMap.LCD_BitCtrl.SEG30_HISTORY_7_GRAPH_1=0;

						HISTORY_COST_7_WEEK_ON;
						HISTORY_COST_7_MONTH_OFF;
						HISTORY_COST_7_OFF;
						State=GetEnergyDataOneWeek1( &Get_Power);						
						//LCD_Display_Today_Graph_PowerData(Display_Channel-1);     // 한시 간 단위의  디스플레이를 바로 바로 디스플레이하게: 다른 채널로 옯길대 없애기 위해 
						
						break;
						
	   case MONTH_GRAPH:
						LCDMap.LCD_BitCtrl.SEG39_HISTORY_7_GRAPH_7=0;
						LCDMap.LCD_BitCtrl.SEG38_HISTORY_7_GRAPH_6=0;
						LCDMap.LCD_BitCtrl.SEG26_HISTORY_7_GRAPH_5=0;
						
						LCDMap.LCD_BitCtrl.SEG27_HISTORY_7_GRAPH_4=1;
						LCDMap.LCD_BitCtrl.SEG28_HISTORY_7_GRAPH_3=1;
						LCDMap.LCD_BitCtrl.SEG29_HISTORY_7_GRAPH_2=1;
						LCDMap.LCD_BitCtrl.SEG30_HISTORY_7_GRAPH_1=1;
						
						HISTORY_Week_Graph(0);		
							
						HISTORY_COST_7_MONTH_ON;
						HISTORY_COST_7_WEEK_OFF;
						HISTORY_COST_7_OFF;

						LcdPut_Digit_1(HISTORY_COST_GRAPH_UNIT_Digit1,  LCD_DEL);

						LCD_Set_Graph_Level(Dsp_Item, Mon_7,  0);
						LCD_Set_Graph_Level(Dsp_Item, Tue_6,  0);
						LCD_Set_Graph_Level(Dsp_Item, Wed_5, 0);
						
						LCD_Set_Graph_Level(Dsp_Item, Thu_4,  5);
						LCD_Set_Graph_Level(Dsp_Item, Fri_3,   5);
						LCD_Set_Graph_Level(Dsp_Item, Sat_2,  5);
						LCD_Set_Graph_Level(Dsp_Item, Sun_1, 5);
						break;
		default :             break;
	}			
}



void LCD_Dsp_Bar_Digit5(volatile U8 SetLcdSegmentLocation)
{
	volatile U8 i;
		 
	for(i=0; i<5; i++)LcdPutChar(SetLcdSegmentLocation+i, LCD_BAR);		
			
}



void LCD_Display_Now_Energy( U32 Power ){
	
	NOW_ENG_VOLTAGE_OFF;                          // 아이 콘을 클리어 한다 

	NOW_ENG_TARGET_OFF;
	NOW_ENG_V_OFF;
	NOW_ENG_K_OFF	;
	NOW_ENG_W_OFF;
	NOW_ENG_F_OFF; 

	NOW_ENG_WEEK_OFF;
	NOW_ENG_COST_OFF;
	NOW_ENG_DAY_OFF;

	NOW_ENG_MINUS_OFF	;


	LCDMap.LCD_BitCtrl.SEG19_NOW_ENG_DOT1=0;	
	LCDMap.LCD_BitCtrl.SEG31_NOW_ENG_DOT2=0;	

	NOW_ENG_W_ON;                        // W (watt 표시 )

	//printf("\n   Now Power = %ld  ", Power );
	
	if(Power>=10000)                     // 10,000 이상 은   100의 자리 이하 생략 하고  K 를 표시 
	{
		Power /=10;				// 100 -> 10 변경 140103_원림
		NOW_ENG_K_ON;
		LCDMap.LCD_BitCtrl.SEG31_NOW_ENG_DOT2=1;	//LCD_BitCtrl.SEG19_NOW_ENG_DOT1=0; -> LCD_BitCtrl.SEG31_NOW_ENG_DOT2=0;	 변경  140103_원림
	}
	else if(1000<=Power&&Power<10000)         // 10,000 미만은  10의 자리 이하 생략 하고  K 를 표시 
	{
		Power /=10;
		NOW_ENG_K_ON;
		LCDMap.LCD_BitCtrl.SEG31_NOW_ENG_DOT2=1;	
	
	}

      Lcd_Put_Number(Now_Energy_Digit1, Power,5);	

}

U8 Get_Tier_Level(volatile  U32 Power , volatile U32 * Power_Remainder)  // 단위 Wh
{
	 U32 Temp_Treshold1=0,Temp_Treshold2=0 ,Temp_Treshold3=0,Temp_Treshold4=0, Temp_Treshold5=0,Temp_Treshold6=0, test;
	 Temp_Treshold1=(U32)Cost.Treshold[TIER_1] * 1000;
	 Temp_Treshold2=(U32)Cost.Treshold[TIER_2] * 1000;
	 Temp_Treshold3=(U32)Cost.Treshold[TIER_3] * 1000;
	 Temp_Treshold4=(U32)Cost.Treshold[TIER_4] * 1000;
	 Temp_Treshold5=(U32)Cost.Treshold[TIER_5] * 1000;
	 Temp_Treshold6=(U32)Cost.Treshold[TIER_6] * 1000;

	//printf("\n Get_Tier_Level Power = %d  ", Power );
	
    	if(Power <= Temp_Treshold1 )  // 100    120
	{		
		*Power_Remainder = Power;
			test			=Power_Remainder[0];
		return TIER_1;
    	}
    	else if( Temp_Treshold1 < Power&& (Power <= Temp_Treshold2 ||  Temp_Treshold2 == 0))
	{		
		*Power_Remainder=Power-Temp_Treshold1 ;
			test			=Power_Remainder[0];
		return TIER_2;
    	}
    	else if( Temp_Treshold2 < Power&& (Power<= Temp_Treshold3 ||  Temp_Treshold3 == 0) )
	{		

		 *Power_Remainder= Power -Temp_Treshold2;
			test			=Power_Remainder[0];
		return TIER_3;
    	}
    	else if( Temp_Treshold3 < Power&& (Power<= Temp_Treshold4 ||  Temp_Treshold4 == 0))
	{		
		*Power_Remainder= Power -Temp_Treshold3;
			test			=Power_Remainder[0];
		return TIER_4;
    	}
    	else if(Temp_Treshold4 < Power&& (Power<= Temp_Treshold5 ||  Temp_Treshold5 == 0))
	{		
		*Power_Remainder= Power -Temp_Treshold4;
			test			=Power_Remainder[0];
		return TIER_5;
    	}
	else
	{		
		*Power_Remainder=Power - Temp_Treshold5;
		test			=Power_Remainder[0];
		
		return TIER_6;
    	}
}

U32 Calculation_Display_Cost_One_Month(volatile U8 Cost_Level, volatile U32 Power_Remainder ) 
{
	volatile float Display_Cost=0;
	volatile bit  fMask_Power_Remainder=0;

	if(Power_Remainder<1000) Power_Remainder=1;
	else Power_Remainder /=1000;
	
	fMask_Power_Remainder=0;
	
	//printf("\n 1 Power_Remainder = %d Display_Cost = %f ",Power_Remainder, Display_Cost);
	switch(Cost_Level)
	{
	  case TIER_6:  Display_Cost= Cost.Billing_Rate[TIER_6]* Power_Remainder;	
	  			   fMask_Power_Remainder=1;
				   //printf("\n TIER_6 Display_Cost = %f  Billing_Rate_6 = %f Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_6],Power_Remainder);
	  case TIER_5:  
	  			   if(fMask_Power_Remainder ==0){
				   		fMask_Power_Remainder=1;
				   		Display_Cost= Cost.Billing_Rate[TIER_5]* Power_Remainder;	
					//printf("\n TIER_5 Display_Cost = %f   Billing_Rate_5 = %f Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_5],Power_Remainder);
	  			   }
				   else {
				   		Display_Cost += Cost.Billing_Rate[TIER_5]* (Cost.Treshold[TIER_5]-Cost.Treshold[TIER_4]);
					//printf("\n TIER_5 Display_Cost = %f  Billing_Rate_5 = %f  Treshold_5 = %d Treshold_4 = %d", Display_Cost, Cost.Billing_Rate[TIER_5], Cost.Treshold[TIER_5],Cost.Treshold[TIER_4] );
	  			   }
	  case TIER_4:  
	  			   if(fMask_Power_Remainder ==0){
				   		fMask_Power_Remainder=1;
				   		Display_Cost= Cost.Billing_Rate[TIER_4]* Power_Remainder;	
					//printf("\n TIER_4 Display_Cost = %f   Billing_Rate_4 = %f Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_4],Power_Remainder);
	  			   }
				   else {
				   		Display_Cost += Cost.Billing_Rate[TIER_4]* (Cost.Treshold[TIER_4]-Cost.Treshold[TIER_3]);	
					//printf("\n TIER_4 Display_Cost = %f  Billing_Rate_4 = %f  Treshold_4 = %d Treshold_3 = %d", Display_Cost, Cost.Billing_Rate[TIER_4], Cost.Treshold[TIER_4],Cost.Treshold[TIER_3] );
	  			   }
				
	  case TIER_3:  
	  			   if(fMask_Power_Remainder ==0){
				   		fMask_Power_Remainder=1;
				   		Display_Cost= Cost.Billing_Rate[TIER_3]* Power_Remainder;	
					//printf("\n TIER_3 Display_Cost = %f   Billing_Rate_3 = %f Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_3],Power_Remainder);
	  			   }
				   else {
				   		Display_Cost += Cost.Billing_Rate[TIER_3]* (Cost.Treshold[TIER_4]-Cost.Treshold[TIER_3]);	
					//printf("\n TIER_3 Display_Cost = %f  Billing_Rate_3 = %f  Treshold_4 = %d Treshold_3 = %d", Display_Cost, Cost.Billing_Rate[TIER_3], Cost.Treshold[TIER_4],Cost.Treshold[TIER_3] );
	  			   }
				
	  case TIER_2:  
	  			   if(fMask_Power_Remainder ==0){
				   		fMask_Power_Remainder=1;
				   		Display_Cost= Cost.Billing_Rate[TIER_2]* Power_Remainder;	
					//printf("\n TIER_2 Display_Cost = %f   Billing_Rate_2 = %f Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_2],Power_Remainder);
				
	  			   }
				   else {
				   		if(Cost.Treshold[TIER_3]==0xffff)
						{
				   			Display_Cost += Cost.Billing_Rate[TIER_2]* (Cost.Treshold[TIER_2]-Cost.Treshold[TIER_1]);	
					//printf("\n TIER_2 Display_Cost = %f  Billing_Rate_2 = %f  Treshold_2 = %d Treshold_1 = %d", Display_Cost, Cost.Billing_Rate[TIER_2], Cost.Treshold[TIER_2],Cost.Treshold[TIER_1] );
				   		}
						else {
				   			Display_Cost += Cost.Billing_Rate[TIER_2]* (Cost.Treshold[TIER_3]-Cost.Treshold[TIER_2]);		
					//printf("\n TIER_2 Display_Cost = %f  Billing_Rate_2 = %f  Treshold_3 = %d Treshold_2 = %d", Display_Cost, Cost.Billing_Rate[TIER_2], Cost.Treshold[TIER_3],Cost.Treshold[TIER_2] );
				   		}
	  			   }
	                 
	  case TIER_1:  
	  			   if(fMask_Power_Remainder ==0){
				   		fMask_Power_Remainder=1;
				   		Display_Cost= Cost.Billing_Rate[TIER_1]* Power_Remainder;	
					//printf("\n TIER_1 Display_Cost = %f  Billing_Rate_1 = %f  Power_Remainder = %d", Display_Cost, Cost.Billing_Rate[TIER_1], Power_Remainder );
						 
	  			   }
				   else {
				   		Display_Cost += Cost.Billing_Rate[TIER_1]* Cost.Treshold[TIER_1];
					//printf("\n TIER_1 Display_Cost = %f  Billing_Rate_1 = %f  Treshold = %d", Display_Cost, Cost.Billing_Rate[TIER_1], Cost.Treshold[TIER_1] );
	  			   }
				 
       default :    break;
	}

	//printf("\n 2 Power_Remainder = %d Display_Cost = %f ",Power_Remainder, Display_Cost);
	return (U32) Display_Cost;
	//printf("\n  return Display_Cost = %ld ", Display_Cost);
	
}	


extern U8 No_Step_Fare_System;
#define HOUR_POWER 	10  
#define AVERAGE_COST 	153.94   // 평균 단가 

U32 Lcd_Dsp_Money_Proc(volatile U8 Dsp_Period,  volatile U32 Power )
{
	U32   Dsp_Money, temp_Dsp_Money;	
	U32   One_Month_Power, Temp_One_Month_Power,Temp_Week_Power, Temp_Day_power;
	float tax1, tax2, test;
	U8    Cost_Level;
	U32   Power_Remainder=0;
	#if 1
	One_Month_Power=Power;
	Temp_Day_power=Power;
	Temp_Week_Power=Power;
	// if(Power <1000) 
	#else
	
	#endif
	//printf(" \n 1 One_Month_Power = %ld ", One_Month_Power);
		
	switch(Dsp_Period)
	{
	  	case NEW_POWER:
						One_Month_Power *=ONE_MONTH_POWER;  // 1달  소비 예상 전력 
						Temp_One_Month_Power=One_Month_Power;
						
				 		break;
	   	case DAY_POWER:		
						//if(One_Month_Power&&One_Month_Power>1000)One_Month_Power /=(float)1000;
						//else if(One_Month_Power<1000) One_Month_Power=0;
						// Testing
						One_Month_Power=800000; 
						break;
						
		case WEEK_POWER: 	
						break;					

		case MONTH_POWER: 		
						break;

		case THIS_MONTH_POWER: 						
						break;	
		#if 1
		default : 		break;
		#endif										
	}

						//printf("\n 2 One_Month_Power = %ld ",One_Month_Power);
		
	if(One_Month_Power){	
	 					Cost_Level=Get_Tier_Level(One_Month_Power, &Power_Remainder);	
						
					#if 1// cmlee request by hong 20140515 	
					if(No_Step_Fare_System==2 && (Dsp_Period==DAY_POWER || Dsp_Period==WEEK_POWER)){
						#if 0
						Dsp_Money= Cost.Billing_Rate[TIER_3] * One_Month_Power;
						#else 
						Dsp_Money= (Cost.Billing_Rate[TIER_3] * (float)Temp_Week_Power) / (float)1000;
						//Dsp_Money= Dsp_Money /1000;
						#endif
						}
					else if(No_Step_Fare_System==0) {   // 
							test = event1.Average_Cost;
							#if 0
							Dsp_Money= ((U32)event1.Average_Cost *  One_Month_Power) / 1000;
							#else
							Dsp_Money= (event1.Average_Cost * (float) One_Month_Power) / (float)1000;
							#endif
						}
					else 
						Dsp_Money= Cost.Base_Cost[Cost_Level] + Calculation_Display_Cost_One_Month(Cost_Level, Power_Remainder);
						temp_Dsp_Money=Dsp_Money;
						tax1=(float)temp_Dsp_Money + (float)(temp_Dsp_Money * 0.137);
						Dsp_Money = (U32)tax1;
						//printf("\n  Base_Cost = %d Cost_Level = %d Power_Remainder = %d ",Cost.Base_Cost[Cost_Level],Cost_Level, Power_Remainder);
					//	}
					#else 
					Dsp_Money= Cost.Base_Cost[Cost_Level] + Calculation_Display_Cost_One_Month(Cost_Level, Power_Remainder);
						//printf("\n  Base_Cost = %d Cost_Level = %d Power_Remainder = %d ",Cost.Base_Cost[Cost_Level],Cost_Level, Power_Remainder);
		                   #endif
	}
	else Dsp_Money=0;

	//printf("\n Dsp_Money = %ld ",Dsp_Money);
   
	return Dsp_Money;
				
}


#define DSP_NUMBER_HUNDREDS_OF_THOUSANDS  1000000L  // 백 만 
#define MAX_LCD_DSP_NUMBER   					99999L  //LCD 표시 가능한  5 자리  숫자 

void LCD_Display_History_Cost(volatile U8 Dsp_Period, volatile  U32 Power )
{
	U32  Dsp_Money; 		
	
	HISTORY_COST_UNIT_POUND_OFF;
	HISTORY_COST_UNIT_JAPAN_OFF;
	HISTORY_COST_UNIT_EURO_OFF;
	HISTORY_COST_UNIT_DOLLAR_OFF;
	
	HISTORY_COST_K_OFF	;
	HISTORY_COST_UNIT_Won_OFF;
		
	LCDMap.LCD_BitCtrl.SEG23_HISTORY_COST_DOT1=0; 
	LCDMap.LCD_BitCtrl.SEG22_HISTORY_COST_DOT2=0; 

	//HISTORY_COST_UNIT_JAPAN_ON;
	HISTORY_COST_UNIT_Won_ON;
	#if 0         // this code make truncating number of float
       if(Power > KWH)Power /= KWH;
       else if(Power < KWH)Power = 0;
 	//Power=1070;  
 	#endif
	Dsp_Money = Lcd_Dsp_Money_Proc( Dsp_Period,   Power );
	
	//printf(" \n Dsp_Money_1 = %ld  H_Dsp_Period = %d  H_Power = %ld ", (U32)Dsp_Money,(U16)Dsp_Period, (U32)Power) ;
	//printf(" \n H_Dsp_Period = %d, H_Power = %ld ", (U16)Dsp_Period, (U32)Power);
		
	if(Dsp_Money>=DSP_NUMBER_HUNDREDS_OF_THOUSANDS)
	{
		Dsp_Money /=100;

		//printf(" \n HISTORY_COST_100 = %ld ", Dsp_Money);
		
		HISTORY_COST_K_ON;		
		LCDMap.LCD_BitCtrl.SEG23_HISTORY_COST_DOT1=1; 		
	}
	else if( MAX_LCD_DSP_NUMBER < Dsp_Money&&Dsp_Money< DSP_NUMBER_HUNDREDS_OF_THOUSANDS)
	{
		Dsp_Money /=10;

		//printf(" \nHISTORY_COST_10 = %ld ", Dsp_Money);
		
		HISTORY_COST_K_ON;		
		LCDMap.LCD_BitCtrl.SEG22_HISTORY_COST_DOT2=1; 		
	}
	
     Lcd_Put_Number(HISTORY_COST_Digit1, Dsp_Money,5);	//Dsp_Money
			
}



void LCD_Display_Now_Cost(volatile U32 Power )
{
	volatile U32 Dsp_Money;
 		
	Lcd_Dsp_All_Off_Symbol_Now_Cost();
	
	NOW_COST_Won_ON;                     // 화페 단위 표시 ( 한 화 )
	
	Dsp_Money=Lcd_Dsp_Money_Proc( NEW_POWER,   Power );

	//printf("\n NOW_Money = %ld ", Dsp_Money); 
	
	if(Dsp_Money>=10000009L)  // 천 만 이상 
	{
		Dsp_Money /=1000;
		NOW_COST_K_ON;
	}
	if(1000000L< Dsp_Money&&Dsp_Money< 9999999L)  // 백만 이상   ~ 9999999L
	{
		Dsp_Money /=100;
		NOW_COST_K_ON;
		NOW_COST_DOT1_ON;
	}
	else if(99999L< Dsp_Money&&Dsp_Money< 1000000L) // 99999L ~ 백만 미만 
	{
		Dsp_Money /=10;
		NOW_COST_K_ON;
		NOW_COST_DOT2_ON;
	}
       Lcd_Put_Number(Now_COST_Digit1, Dsp_Money,5);
	    //printf(" \n Now_Power = %ld, Now_cost = %ld", (U32)Power, (U32)Dsp_Money);
				
}
#define RSSI_Level_0  0
#define RSSI_Level_1  1
#define RSSI_Level_2  2
#define RSSI_Level_3  3

#define RSSI_Dsp_Step	3
#define RSSI_Level_Max 	17  // DataSheet  에는 120 임  
#define RSSI_Level_min 	0  //최소 한  받을수  잇는  RSSI ,  실험치로 찻 아야 함 
#define RSSI_Level 		(RSSI_Level_Max-RSSI_Level_min)/RSSI_Dsp_Step

void LCD_Display_RSSI_Level(volatile U8 Dsp_Level)
{ 

	Dsp_Level  /=RSSI_Level;

	switch(Dsp_Level){
		case RSSI_Level_0: 
							LCDMap.LCD_BitCtrl.SEG1_RF_LEVEL_1 =0;
							LCDMap.LCD_BitCtrl.SEG2_RF_LEVEL_2 =0;
							LCDMap.LCD_BitCtrl.SEG3_RF_LEVEL_3 =0;
							break;
		case RSSI_Level_1: 
							LCDMap.LCD_BitCtrl.SEG1_RF_LEVEL_1 =1;
							LCDMap.LCD_BitCtrl.SEG2_RF_LEVEL_2 =0;
							LCDMap.LCD_BitCtrl.SEG3_RF_LEVEL_3 =0;
							break;
		case RSSI_Level_2: 
							LCDMap.LCD_BitCtrl.SEG1_RF_LEVEL_1 =1;
							LCDMap.LCD_BitCtrl.SEG2_RF_LEVEL_2 =1;
							LCDMap.LCD_BitCtrl.SEG3_RF_LEVEL_3 =0;
							break;
		default: 
							LCDMap.LCD_BitCtrl.SEG1_RF_LEVEL_1 =1;
							LCDMap.LCD_BitCtrl.SEG2_RF_LEVEL_2 =1;
							LCDMap.LCD_BitCtrl.SEG3_RF_LEVEL_3 =1;
							break;
	}		
}


#define Battery_Level_0  0
#define Battery_Level_1  1
#define Battery_Level_2  2
#define Battery_Level_3  3


void LCD_Display_Battery_Level(volatile U8 Dsp_Position, volatile U8 Dsp_Level)
{ 
	if(Dsp_Position==LCD_Map_Bufer_Main_Battery_Base_Index)
	{
		switch(Dsp_Level){
		    case Battery_Level_0: 	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_1 =0;
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_2 =0;	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_3 =0;	
								break;
		    case Battery_Level_1: 	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_2 =0;	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_3 =0;	
								break;
		    case Battery_Level_2: 	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_2 =1;	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_3 =0;	
								break;
		    default: 	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_2 =1;	
								LCDMap.LCD_BitCtrl.SEG18_MAIN_POWER_LEVEL_3 =1;	
								break;
		}
	}
	else {
		switch(Dsp_Level){

		    case Battery_Level_0: 	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_1 =0;
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_2 =0;	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_3 =0;	
								break;
		    case Battery_Level_1: 	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_2 =0;	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_3 =0;	
								break;
		    case Battery_Level_2: 	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_2 =1;	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_3 =0;	
								break;
		    case Battery_Level_3: 	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_1 =1;
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_2 =1;	
								LCDMap.LCD_BitCtrl.SEG19_TRAN_POWER_LEVEL_3 =1;	
								break;
			default :				break;
		}
	}
}


void LCD_Display_AC_PHASE(volatile U8 Ac_Phase_T)
{ 

	LCDMap.LCD_BitCtrl.SEG15_AC_PHASE_T1 =0;
	LCDMap.LCD_BitCtrl.SEG16_AC_PHASE_T2 =0;
	LCDMap.LCD_BitCtrl.SEG17_AC_PHASE_T3 =0;
	
	if(Ac_Phase_T&0x01)LCDMap.LCD_BitCtrl.SEG15_AC_PHASE_T1 =1;
	if(Ac_Phase_T&0x02)LCDMap.LCD_BitCtrl.SEG16_AC_PHASE_T2 =1;
	if(Ac_Phase_T&0x04)LCDMap.LCD_BitCtrl.SEG17_AC_PHASE_T3 =1;

}


void LCD_Display_Temperature(void ){

	U32 temp;
	float temp1;
//	U8 test;
	
	LCDMap.LCD_BitCtrl.SEG26_TEMPERATURE=1; 
	
	LCDMap.LCD_BitCtrl.SEG53_THRESHOLD_DOT=1; 	
	
	temp = Current_Temperature;
	if(!(event1.plus_minus == 0xff || event1.compensate_temp==0xffff)) {
			if(event1.plus_minus==0) 
					 temp = Current_Temperature + event1.compensate_temp;
			else if(event1.plus_minus==1) 
					temp = Current_Temperature - event1.compensate_temp;	
		}
    //test =event1.Temperature_C_F;
	if(event1.Temperature_C_F==0)
		{
		LCDMap.LCD_BitCtrl.SEG28_Celsius=1; 
		LCDMap.LCD_BitCtrl.SEG29_Fahrenheit =0; 
		
		}
	else
		{
		temp1=(float)temp/10;
		LCDMap.LCD_BitCtrl.SEG29_Fahrenheit =1; 
		LCDMap.LCD_BitCtrl.SEG28_Celsius=0; 
			temp1=temp1 * (float)9/5;
			temp1=temp1 + 32;
			temp=(U32)(temp1*10);
	       // C*(9/5) +32            
		}
	
	#if 1
	Lcd_Put_Number( THRESHOLD_Digit1, temp,4);       ////////    Lcd_Put_Number( THRESHOLD_Digit1, (U32)Current_Temperature,4);
      #else 
	//LcdPutChar(THRESHOLD_Digit4, LCD_BAR);	      // display '-' if temp is lower than 0   by cmlee
	Lcd_Put_Number( THRESHOLD_Digit1, (U32)Current_Temperature,3);
	#endif
}     
void LCD_Display_Co2(volatile U32 Power)
{
	volatile float Co2; 
	volatile bit fDot=0;
		
	LCDMap.LCD_BitCtrl.SEG59_CO2_DOT =0;	

	if(Power>=1000){ fDot=1; Power/=1000; }	// 입력된  전력이 KW 이면  1000으로 나누고 Dot를 표시 한다 
	
	Co2=(float)Power*0.425;

	if(fDot){
			Co2 *=10.0;  // 소수점 이하 숫자 표시 
			LCDMap.LCD_BitCtrl.SEG59_CO2_DOT=1;	
	}
	else {
			if(Co2>=1000.0)
			{
				Co2 /=10.0;
				LCDMap.LCD_BitCtrl.SEG59_CO2_DOT=1;	
			}
	}
	
  	Lcd_Put_Number(CO2_Digit1, (U32)Co2,5);
}



#define  PIONT_Y_0            0    // RAM X Column      0 ~ 101 
#define  PIONT_Y_1            1    // RAM X Column  102 ~ 204 

#define LCD_BufMax_64	65   //  LCD_BufMax[0] ~  LCD_BufMax[64] 

#define  LCD_Debug     0
void LCD_Write(void)
{
	idata U8  volatile i, k, h, y;
	idata U8 volatile  Lcd_Data;
	idata U8  volatile LCD_Dsp_Reg;	

   //	LCD_Display_Battery_Level(LCD_Map_Bufer_Main_Battery_Base_Index, 3);
									
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	DEVICE_ADDR_CMD | MASTER);	       // device-address
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_X_MSB_CMD |0 );	        //pointer x,MSB
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_X_LSB_CMD |0x01 );	 //pointer x,LSB
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_Y_MSB_CMD |0 );	       // pointer y=0

	I2C_Start(DEVICE_ADDR | I2C_WRITE); 	
	I2C_Write( SEL_RAM_DATA_REG  );	 // (last command,data is a display byte)	

	for(i=0; i < 23; i++) 
	{	
		#if LCD_Debug
			LCD_Dsp_Reg =  LCDMap.LCD_ByteCtrl[i];
		#else
			LCD_Dsp_Reg =  (LCD_InverseMask |Attribute.LCD_ByteCtrl[i]) &LCDMap.LCD_ByteCtrl[i];
		#endif
		
			I2C_Write(LCD_Dsp_Reg);
	}

	for(i=23; i < 58; i++) I2C_Write(0xff);  // 35

	k=58;
	
	for(i=23; i < LCD_BufMax_64; i++)   //  42
	{		 	
		#if LCD_Debug
			LCD_Dsp_Reg=  LCDMap.LCD_ByteCtrl[i];
		#else
			LCD_Dsp_Reg=  (LCD_InverseMask |Attribute.LCD_ByteCtrl[i]) &LCDMap.LCD_ByteCtrl[i];
		#endif
		
			I2C_Write(LCD_Dsp_Reg);
		
			k++;		
	}

	I2C_Stop(); 


				
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	DEVICE_ADDR_CMD | MASTER);	       // device-address
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_X_MSB_CMD |0 );	        //pointer x,MSB
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_X_LSB_CMD |0x01 );	 //pointer x,LSB
	Lcd_Command_Byte_Write( CTRL_BYTE|SEL_CMD_REG , 	SET_DATA_P_Y_MSB_CMD |0x01 );	       // pointer y=0

       h=LCD_BufMax_64;
	y=0;

	I2C_Start(DEVICE_ADDR | I2C_WRITE); 	
	I2C_Write( SEL_RAM_DATA_REG  );	 // (last command,data is a display byte)	
	
	for(i=0; i < 3; i++) 
	{
		#if LCD_Debug
			Lcd_Data=LCDMap.LCD_ByteCtrl[h] ;
		#else
			Lcd_Data =  (LCD_InverseMask |Attribute.LCD_ByteCtrl[h]) &LCDMap.LCD_ByteCtrl[h];
		
		#endif
				
		for(k=0; k < 8; k++)                      // 24
		{			
			LCD_Dsp_Reg= Lcd_Data;
			
			I2C_Write(LCD_Dsp_Reg);
			
			Lcd_Data = Lcd_Data >> 1;
			y++;
		}
		h++;
	}
	
	for(i=23; i < 58; i++) I2C_Write(0xff);  // 34

       h=68;
	y=59;
		
	for(i=0; i < 3; i++)                              // 24
	{
		#if LCD_Debug
			Lcd_Data=LCDMap.LCD_ByteCtrl[h] ;
		#else
			Lcd_Data =  (LCD_InverseMask |Attribute.LCD_ByteCtrl[h]) &LCDMap.LCD_ByteCtrl[h];
		#endif
		
		for(k=0; k < 8; k++) 
		{			
			LCD_Dsp_Reg= Lcd_Data;
			
			I2C_Write(LCD_Dsp_Reg);
			
			Lcd_Data = Lcd_Data >> 1;
			y++;
		}
		h++;
	}	

	I2C_Stop(); 

	
}



void  LCD_Dsplay_AM_PM(void)
{
		if(AM_0_HOUR<=event1.hours&&event1.hours<AM_12_HOUR)
		{ 
				event1.Pm_Am=AM;  				
				LCD_TIME_AM ;		
		}
		else {                           				  
				event1.Pm_Am=PM; 		
				LCD_TIME_PM;		
		}
}

void  LCD_Dsplay_which_AMPM(U8 count)
{
		if(AM_0_HOUR<Peak.hour[count]&&Peak.hour[count]<AM_12_HOUR)
				{ 		
				LCD_TIME_AM ;	
				//Peak.which_AMPM=AM;
		}
		else {                  				  
				LCD_TIME_PM;
				//Peak.which_AMPM=PM;
		}
}	
#define RATE_OFF 0
#define RATE_MID   1
#define RATE_ON 2
void  LCD_Dsplay_which_peak(U8 count)
{
	LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_Rate =1 ; //  Rate  in Time Section
	Attribute.LCD_BitCtrl.SEG40_SETING_TIME_Rate=LCD_INVERSE_DISPLAY_bit;
		switch(Peak.which_Peak[count]) 
		{ 
		     	case RATE_OFF : 	
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF =1; 
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_MID =0; 
							LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON =0; 

							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_OFF =LCD_INVERSE_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_MID =LCD_NORMAL_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG38_SETING_TIME_ON =LCD_NORMAL_DISPLAY_bit;
							break;
			case RATE_MID :	
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF =0; 
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_MID =1; 
							LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON =0; 

							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_OFF =LCD_NORMAL_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_MID =LCD_INVERSE_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG38_SETING_TIME_ON =LCD_NORMAL_DISPLAY_bit;
							break; 
			case RATE_ON :	
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF =0; 
							LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_MID =0; 
							LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON =1; 

							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_OFF =LCD_NORMAL_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG40_SETING_TIME_MID =LCD_NORMAL_DISPLAY_bit; 
							//Attribute.LCD_BitCtrl.SEG38_SETING_TIME_ON =LCD_INVERSE_DISPLAY_bit;
							break;
		       default: 			break;
		}
}		

#ifdef SET_ONOFFTIMER
void  LCD_Dsplay_OnOffTimer_AMPM(U8 count, U8 onoff)
{
	if(onoff)
	{
		if(AM_0_HOUR<OnOffTimer.on_hour[count]&&OnOffTimer.on_hour[count]<AM_12_HOUR)
				{ 		
				LCD_TIME_AM ;	
		}
		else {                  				  
				LCD_TIME_PM;
		}
	}
	else
	{
		if(AM_0_HOUR<OnOffTimer.off_hour[count]&&OnOffTimer.off_hour[count]<AM_12_HOUR)
				{ 		
				LCD_TIME_AM ;	
		}
		else {                  				  
				LCD_TIME_PM;
		}
	}
}	

#define TIMER_OFF 0
#define TIMER_ON   1
void  LCD_Dsplay_OnOff_Timer(U8 count)
{
		if(OnOffTimer.timer_onoff[count] == TIMER_ON) 
		{ 
			LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF =0; 
			LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON =1; 
			Attribute.LCD_BitCtrl.SEG38_SETING_TIME_ON=LCD_INVERSE_DISPLAY_bit;
		}
		else
		{
			LCDMap.LCD_BitCtrl.SEG40_SETING_TIME_OFF =1; 
			LCDMap.LCD_BitCtrl.SEG38_SETING_TIME_ON =0; 
			Attribute.LCD_BitCtrl.SEG40_SETING_TIME_OFF=LCD_INVERSE_DISPLAY_bit;							
		}
}
#endif

void LCD_Display_Week_Grap_Clr(void)
{
	LCD_Set_Graph_Level(WEEK_GRAPH, Mon_7, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Tue_6, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Wed_5, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Thu_4, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Fri_3, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Sat_2, 0);
	LCD_Set_Graph_Level(WEEK_GRAPH, Sun_1, 0);
}

void LCD_Dsplay_Week(void)
{
	
	LCD_Week_ALL_OFF;

	event1.Week=Compute_Week_zeller(event1.years,  event1.output_month, event1.output_days);

	switch(event1.Week)
	{		
		case Sun:  LCD_Sunday_ON;     	break;					
		case Mon:  LCD_Monday_ON;     break;					
		case Tue:  LCD_Tuesday_ON;  	break;					
		case Wed: LCD_Wednesday_ON;	break;					
		case Thu:  LCD_Thursday_ON;   	break;					
		case Fri:    LCD_Friday_ON;    	break;					
		case Sat:   LCD_Saturday_ON;  	break;
		default : break;
	}
}

void LCD_Dsplay_Time_Hour_Minute(U8 hours, U8 minutes )
{	
	LcdPutByte(SETING_TIME_Hour_Digit1,    hours);		
	LcdPutByte(SETING_TIME_Minute_Digit1,  minutes);
}


U8 Key_Set_operation  ;  // cmlee   this is not to rotate time if =1
U8 three_display ;

void LCD_Dsplay(void)
{		

	if(time_mSecTimeExpired(Lcd_Dispaly_Timer) == TIMER_EXPIRED ){

		timer_mSecTimerSet(Lcd_Dispaly_Timer, LCD_DSPLAY_TIME_TIC);  
		if(fRTC_Run==RTC_RUN){
		 	
		 			RTC_ReadTime();	
					Check_Peak_Time_alarm();   // cmlee
					
#if 1  // cmlee    key set mode 
		if(time_mSecTimeExpired(Lcd_Day_Display_Timer) == TIMER_EXPIRED ){
		timer_mSecTimerSet(Lcd_Day_Display_Timer, LCD_DSPLAY_TIME_TIC*100);   // orig 
		if(Key_Set_operation==0) 
  						{
						Normal_Display_Time_Day(three_display);  // orig
						three_display++;  // cmlee
						if (three_display >=3)three_display=0; //cmlee
						}
			}
#else
                                 Normal_Display_Time_Day(Day_Display_Count);  	
#endif
			
		}
		 
		if(++Lcd_Blik_Timer>=4){
			Lcd_Blik_Timer=0;
			LCD_InverseMask= ~LCD_InverseMask;  //  LCD Inverse  mask  control  ( Repeat 0X00 and 0XFF )
		}
			
	 	LCD_Write();
		
	}
}


void Check_Peak_Time_alarm(void)    // 10:00~ 12:00         13:00~17:00 
{
  U8 i;
  for (i=0;i<6;i++)
  	{
	if(Peak.hour[i] <= event1.hours && event1.hours < Peak.hour[i+1])  
		{
		if (Peak.which_Peak[i] == RATE_ON) {ALARM_2ND_ON;}
		else {ALARM_2ND_OFF;} 
		}
  	}
  }
/*
*********************************************************************************************************
*                                                                   LCD_Put_String
*
* Description:   LCD에 1문자 표시 
*
* Arguments  :   a_DisplayStart_FND_Sel  :    표시를 시작 할  LCD 위치로 LCD 숫자인 0~3 사에에 수만 지정 가능  
*                      *a_Display_String           :     표시 할 문자 열 
*			
*
* Returns    :     NONE

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

void LCD_Put_String(UBYTE a_DisplayStart_FND_Sel, const char *a_Display_String, U8 NumLen )
{
	volatile UBYTE FND_Locat, i;
	volatile UBYTE DisplayData;
	volatile U16 StrLen;
	
	FND_Locat = a_DisplayStart_FND_Sel;
		
	StrLen = strlen( (const char*) a_Display_String);

	for(i=0; i < NumLen; i++){
		
		if( *a_Display_String==' '){ 
								LcdPutChar(FND_Locat--,  LCD_DEL);    
		}
		else{			
								DisplayData=Converted_to_Numeric(*a_Display_String);
								
								LcdPutChar(FND_Locat--, DisplayData);
		}

		a_Display_String++;

	}
	
}








