
#include "Menus.h"

uint8_t KeyAValid , KeyBValid;
uint8_t FirstStatus;
uint8_t ClockPOS;
uint8_t BcakLightPOS=2;
uint8_t BAOYANGPOS;
uint8_t DriveModePOS;
uint8_t OverSpeedPOS;
uint8_t DriveMode;
uint8_t OverSpeedSet=1;
uint8_t ServicePos;
uint8_t TPMSGPOS ;
//uint8_t TrapPOS;
uint16_t keytime;

static const uint16_t BAOYANGPosy[] = {150, 184, 218, 252};
static const uint16_t DriveModePosy[] = {149, 198, 247};
static const uint16_t TPMSPosy[] = {218, 252};
static const uint16_t ClockPosy[] = {412, 436, 345, 369}; 

uint8_t MenuDisplay    = 0;
uint8_t Maintain_clear = 0;

_MeterPos	g_batMeter;
/*******************************************************************************************
按键服务函数
********************************************************************************************/
uint8_t  SetMenu ;          //设置页     0 时间设置 1 雷达设置 2 退出
uint8_t  SetMenupage ;      //显示页     0 设置页   1 时间设置 2 雷达设置
uint8_t  SetRadar;          //雷达显示   0 开启     1 关闭      白条
uint8_t  SetDot;            //雷达设置   0 开启     1 关闭      圆点
uint8_t  SetHoofswear = 1;  //蹄片磨损报警设置
uint8_t  SetHoof      = 1;  //蹄片磨损报警设置
uint8_t  Setservice   = 1;  //保养设置
uint8_t  Service_Open = 1;
uint8_t  SetMinute_Ten;     //分钟设置
uint8_t  SetMinute_One;     //分钟设置
uint8_t  SetHour_Ten;       //小时设置
uint8_t  SetHour_One;       //小时设置

void Menu_Processing_Service(void)
{
  /******************************如果当前是背景显示界面*******************************/
  if (IO_BG_INFO_DISPLAY_ENABLE)
  {
    /************************设置界面*************************************/
    //----hyq--20180602
    // Time_Seting(); //按键信息调用
    if (IO_TIME_DISPLAY_ENABLE)
    { 
      if (SetMenu == 0)                 //设置界面
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU05, LAYER_MENU14);
        TFT_LCD_Display_Sprite(LAYER_MENU01, SN_menu04_png, 337, 150, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU02, SN_menu02_png, 337, 184, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU03, SN_menu03_png, 337, 218, 64);
        
        switch (SetMenupage)
        {
          case 0:
            TFT_LCD_Display_Sprite(LAYER_MENU04, SN_menu00_png, 310, 150, 64);                
            break;
          case 1: 
            TFT_LCD_Display_Sprite(LAYER_MENU04, SN_menu00_png, 310, 184, 64);        
            break;
          case 2: 
            TFT_LCD_Display_Sprite(LAYER_MENU04, SN_menu00_png, 310, 218, 64);
            break;
          default:
            IODispFuncSwitch = 1;
            ClockPOS = 0;
            TPMSGPOS = 0; 
            SetMenupage = 0;
            SetMenu = 0;
            //IOTFTLCDAccessRight  = 0x00;
            //IOTFTLCDAccessRight |= (IO_BG_INFO_BIT | IO_TELLTALE_BIT); 
            break;
        } 
      }
      else if (SetMenu == 1)             //用户设置
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU06, LAYER_MENU14);
        TFT_LCD_Clear_Layer(LAYER_MENU01);
        //TFT_LCD_Display_Sprite(LAYER_MENU01, SN_Set_2_01_png, 337, 150, 64);   //时间设置
        TFT_LCD_Display_Sprite(LAYER_MENU02, SN_zhaomingliangdu_png, 337, 150/*184*/, 64); //照明亮度
        TFT_LCD_Display_Sprite(LAYER_MENU03, SN_Set_2_02_png, 337, 184/*218*/, 64);   //小计里程清零
        TFT_LCD_Display_Sprite(LAYER_MENU04, SN_baoyangtishiqingchu_png, 337, 218/*252*/, 64); //保养提示清零
        TFT_LCD_Display_Sprite(LAYER_MENU05, SN_menu00_png, 316, BAOYANGPosy[ServicePos], 64);  
      }
      else if (SetMenu == 2)             //胎压监测信息  
      {
        //if (NVM_CONFIG_TPMS == 0)        //20200907
        //{
          Menu2_3_Display();
        //}     
      }           
      else if (SetMenu == 3)             //行车信息
      {
        Menu2_4_Display();
      }
      else if (SetMenu == 5)             //小计清零
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU05, LAYER_MENU14);
        TFT_LCD_Display_Sprite(LAYER_MENU01, SN_Set_3_01_png, 354, 151, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_02_png, 354, 220, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU03, SN_Set_3_03_png, 354, 253, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU04, SN_menu00_png, 310, TPMSPosy[TPMSGPOS], 64); 
      }
      else if (SetMenu == 6)             //时间设置界面
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU08, LAYER_MENU14);
        TFT_LCD_Display_Sprite(LAYER_MENU01, SN_Set_3_04_png, 354, 151, 64); 
        TFT_LCD_Display_Sprite(LAYER_MENU07, SN_NB_23_maohao_png, 399, 213, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU03, SN_NB_23_00_png + SetMinute_Ten, ClockPosy[0], 210, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU04, SN_NB_23_00_png + SetMinute_One, ClockPosy[1], 210, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU05, SN_NB_23_00_png + SetHour_Ten, ClockPosy[2], 210, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU06, SN_NB_23_00_png + SetHour_One, ClockPosy[3], 210, 64);
        
        switch (ClockPOS)
        {
          case  HOUR_Ten_Set_Disp :
            TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_05_png, 342, 202, 64);
            TFT_LCD_Display_Sprite(LAYER_MENU05, SN_NB_23_black_00_png + SetHour_Ten, ClockPosy[2], 210, 64);
            break;
          case HOUR_One_Set_Disp:
            TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_05_png, 366, 202, 64); 
            TFT_LCD_Display_Sprite(LAYER_MENU06, SN_NB_23_black_00_png + SetHour_One, ClockPosy[3], 210, 64);
            break;
          case MINUTE_Ten_Set_Disp:
            TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_05_png, 409, 202, 64); 
            TFT_LCD_Display_Sprite(LAYER_MENU03, SN_NB_23_black_00_png + SetMinute_Ten, ClockPosy[0], 210, 64);
            break;
          case MINUTE_One_Set_Disp:
            TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_05_png, 433, 202, 64); 
            TFT_LCD_Display_Sprite(LAYER_MENU04, SN_NB_23_black_00_png + SetMinute_One, ClockPosy[1], 210, 64);
            break;  
          default:
            // RTC_MINUTE  = SetMinute_One + SetMinute_Ten * 10;
            // RTC_HOUR  = SetHour_One + SetHour_Ten * 10 ;
            ClockPOS = 0;  
            SetMenupage = 0;
            SetMenu = 0; 
            IODispFuncSwitch     = 1;
            IOTFTLCDAccessRight  = 0x00;
            IOTFTLCDAccessRight |= (IO_BG_INFO_BIT | IO_TELLTALE_BIT | IO_DRIVE_INFO_BIT );
            break;
        }
      }
      else if (SetMenu == 7)             //照明亮度
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU06, LAYER_MENU14);
        TFT_LCD_Display_Sprite(LAYER_MENU01, SN_zhaomingliangdu_png, 328, 151, 64); //照明亮度
        if (BcakLightPOS == 0)
        {   
          TFT_LCD_Display_Sprite(LAYER_MENU02, SN_liangduge___hui_png, 378, 201, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU03, SN_liangduge___hui_png, 378, 221, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU04, SN_liangduge___hui_png, 378, 241, 64);            
          TFT_LCD_Display_Sprite(LAYER_MENU05, SN_liangdutiao__bai_png, 378, 261, 64);
        } 
        if (BcakLightPOS == 1)
        {
          TFT_LCD_Display_Sprite(LAYER_MENU02, SN_liangduge___hui_png, 378, 201, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU03, SN_liangduge___hui_png, 378, 221, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU04, SN_liangdutiao__bai_png, 378, 241, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU05, SN_liangdutiao__bai_png, 378, 261, 64);
        }
        if (BcakLightPOS == 2)
        {
          TFT_LCD_Display_Sprite(LAYER_MENU02, SN_liangduge___hui_png, 378, 201, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU03, SN_liangdutiao__bai_png, 378, 221, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU04, SN_liangdutiao__bai_png, 378, 241, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU05, SN_liangdutiao__bai_png, 378, 261, 64);
        }
        if (BcakLightPOS == 3)
        {
          TFT_LCD_Display_Sprite(LAYER_MENU02, SN_liangdutiao__bai_png, 378, 201, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU03, SN_liangdutiao__bai_png, 378, 221, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU04, SN_liangdutiao__bai_png, 378, 241, 64);
          TFT_LCD_Display_Sprite(LAYER_MENU05, SN_liangdutiao__bai_png, 378, 261, 64);
        }         
      }
      else if (SetMenu == 8)             //保养清零
      {
        TFT_LCD_Clear_Multi_Layer(LAYER_MENU05, LAYER_MENU14);
        TFT_LCD_Display_Sprite(LAYER_MENU01, SN_Set_3_01_png, 354, 151, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU02, SN_Set_3_02_png, 354, 220, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU03, SN_Set_3_03_png, 354, 253, 64);
        TFT_LCD_Display_Sprite(LAYER_MENU04, SN_menu00_png, 310, TPMSPosy[TPMSGPOS], 64); 
      }
      else 
      {
        ClockPOS = 0;
        TPMSGPOS = 0;  
        SetMenupage = 0;
        SetMenu = 0;  
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        IOTFTLCDAccessRight |= (IO_BG_INFO_BIT | IO_TELLTALE_BIT | IO_DRIVE_INFO_BIT);   
      }
    }
  }
}
/**************************************时间设置*************************************************/
void Time_Seting(void)
{
  if (IO_TIME_DISPLAY_ENABLE)
  {
    if (IO_CAN_KEY_ENTER == IO_KEY_LONG)
    {
      IO_CAN_KEY_ENTER = IO_KEY_IDLE ;
      MenuDisplay = 0;
      SetMenupage = 0;
      SetMenu = 0;      
      IODispFuncSwitch     = 1;
      IOTFTLCDAccessRight  = 0x00;
      IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
      //TFT_LCD_Clear_Multi_Layer(LAYER_MENU01, LAYER_MENU16);
    }
    //设置界面进入
    if (SetMenu == 0)
    {
      //设置界面短按切换选项
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        SetMenupage++;
        if (SetMenupage > 2)
          SetMenupage = 0;
      }
      if (IO_CAN_KEY_LEFT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_LEFT = IO_KEY_IDLE;
        if (SetMenupage == 0)
          SetMenupage = 2;
        else
          SetMenupage--;
      }
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_ENTER = IO_KEY_IDLE;
        switch (SetMenupage)
        {
          case  0 :
            SetMenu = 1;
            break;
          case  1 :
            SetMenu = 2;
            break;
          case  2 :
            SetMenu = 3;
            break;   
          default :
            break; 
        }
      }
    } 
    //用户设置
    if (SetMenu == 1)
    { 
      if (IO_CAN_KEY_LEFT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_LEFT = IO_KEY_IDLE;
        /*if (ServicePos == 3)
          ServicePos = 2;
        else*/ if (ServicePos == 2)
          ServicePos = 1;
        else if (ServicePos == 1)
          ServicePos = 0;
        else
          ServicePos = 2;//3;
      }
    
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        ServicePos++;
        if (ServicePos > 2)//3)
          ServicePos = 0;
      }
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 1;
        IODispFuncSwitch = 1;
        IOTFTLCDAccessRight  = 0x00;
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
        /*if (ServicePos == 0)
        {
          SetMenu = 6;
          SetMinute_Ten = RTC_MINUTE / 10;
          SetMinute_One = RTC_MINUTE % 10;
          SetHour_Ten = RTC_HOUR / 10;
          SetHour_One = RTC_HOUR % 10;
        }
        else*/ if (ServicePos == 0)
          SetMenu = 7;
        else if (ServicePos == 1)
          SetMenu = 5;
        else if (ServicePos == 2)
          SetMenu = 8;
      } 
    }
    else if (SetMenu == 2)               //胎压设置界面
    { 
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 0;
        SetMenu = 0;      
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      }
      if (IO_CAN_KEY_RIGHT == IO_KEY_LONG)
      {
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        MenuDisplay = 0;
        SetMenupage = 0;
        SetMenu = 0;      
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
      } 
    }
    else if (SetMenu == 3)               //行车信息
    {
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 0;
        SetMenu = 0;      
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      } 
      if (IO_CAN_KEY_LEFT == IO_KEY_LONG)
      {
        IO_CAN_KEY_LEFT = IO_KEY_IDLE ;
        MenuDisplay = 0;
        SetMenupage = 0;
        SetMenu = 0;      
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
      }
    }
    else if (SetMenu == 5)               //小计清零
    {
      if (IO_CAN_KEY_LEFT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_LEFT = IO_KEY_IDLE;
        if (TPMSGPOS == 1)
          TPMSGPOS = 0;
        else
          TPMSGPOS = 1;
      }
    
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        TPMSGPOS++;
        if (TPMSGPOS > 1)
          TPMSGPOS = 0;
      }
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER= IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 0;
        SetMenu = 0;     
        if (TPMSGPOS == 0) 
        {
          Data_Clear_TripA(); 
          //Maintain_clear = 1;
        }
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      } 
    }
    //时间设置界面
    if (SetMenu == 6)
    {
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        ClockPOS++;
        if (ClockPOS > 3)
          ClockPOS = 0;
      }
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        RTC_MINUTE = SetMinute_One + SetMinute_Ten * 10;
        RTC_HOUR   = SetHour_One + SetHour_Ten * 10;
        MenuDisplay = 0;
        keytime = 0;
        ClockPOS = 0;
        SetMenupage = 0;
        SetMenu = 0;      
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      } 
      switch (ClockPOS)
      {
        case HOUR_Ten_Set_Disp:  
                      if ((IO_CAN_KEY_LEFT == IO_KEY_PRESS))
                      { 
                        IO_CAN_KEY_LEFT = IO_KEY_IDLE;   
                        keytime = 0;  
                        if (SetHour_Ten < 2)
                          SetHour_Ten++;
                        else
                          SetHour_Ten = 0;     
                      }                
                      break;
        case HOUR_One_Set_Disp:   
                      if ((IO_CAN_KEY_LEFT == IO_KEY_PRESS))
                      { 
                        IO_CAN_KEY_LEFT= IO_KEY_IDLE;   
                        keytime = 0; 
                        if (SetHour_Ten < 2)
                        { 
                          if (SetHour_One < 9)
                            SetHour_One++;
                          else
                            SetHour_One = 0; 
                        }
                        else if (SetHour_Ten == 2)
                        { 
                          if (SetHour_One < 3)
                            SetHour_One++;
                          else
                            SetHour_One = 0; 
                        }
                      } 
                      break;
        case  MINUTE_Ten_Set_Disp :
                      if ((IO_CAN_KEY_LEFT == IO_KEY_PRESS))
                      { 
                        IO_CAN_KEY_LEFT = IO_KEY_IDLE;   //
                        keytime = 0;  
                        if (SetMinute_Ten < 5)
                          SetMinute_Ten++;
                        else
                          SetMinute_Ten = 0;     
                      }
                      break;
        case MINUTE_One_Set_Disp    :
                      if ((IO_CAN_KEY_LEFT == IO_KEY_PRESS))
                      { 
                        IO_CAN_KEY_LEFT = IO_KEY_IDLE;   //
                        keytime = 0;  
                        if (SetMinute_One < 9)
                          SetMinute_One++;
                        else
                          SetMinute_One = 0;     
                      }
                      break;               
        default   : 
                      ClockPOS = 0; 
                      SetMenupage = 0;
                      SetMenu = 0;    
                      IODispFuncSwitch     = 1;
                      //IOTFTLCDAccessRight  = 0x00;
                      IOTFTLCDAccessRight |= (IO_BG_INFO_BIT | IO_TELLTALE_BIT | IO_DRIVE_INFO_BIT);

                      break;
      }
    }
    else if (SetMenu == 7)               //照明亮度
    {
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS) //按键左右调换20200229
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        if (BcakLightPOS > 0)
          BcakLightPOS--;
        else
          BcakLightPOS = 3;  
      }
    
      if (IO_CAN_KEY_LEFT == IO_KEY_PRESS) //按键左右调换20200229
      {
        keytime = 0;
        IO_CAN_KEY_LEFT = IO_KEY_IDLE;
        if (BcakLightPOS < 3)
          BcakLightPOS++;
        else
          BcakLightPOS = 0;
      }
      
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 0;
        SetMenu = 0;     
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      } 
    }    
    else if (SetMenu == 8)               //保养清零
    {
      if (IO_CAN_KEY_LEFT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_LEFT = IO_KEY_IDLE;
        if (TPMSGPOS == 1)
          TPMSGPOS = 0;
        else
          TPMSGPOS = 1;
      }
    
      if (IO_CAN_KEY_RIGHT == IO_KEY_PRESS)
      {
        keytime = 0;
        IO_CAN_KEY_RIGHT = IO_KEY_IDLE;
        TPMSGPOS++;
        if (TPMSGPOS > 1)
          TPMSGPOS = 0;
      }
      
      if (IO_CAN_KEY_ENTER == IO_KEY_PRESS)
      {
        IO_CAN_KEY_ENTER = IO_KEY_IDLE; 
        MenuDisplay = 0;
        keytime = 0;
        SetMenupage = 0;
        SetMenu = 0;     
        if (TPMSGPOS == 0) 
        {
          //Data_Clear_TripA(); 
          Maintain_clear = 1;
        }
        IODispFuncSwitch     = 1;
        IOTFTLCDAccessRight  = 0x00;
        //IOTFTLCDAccessRight |= (IO_TRAP_BIT | IO_BG_INFO_BIT | IO_DRIVE_INFO_BIT);
        IOTFTLCDAccessRight |= (IO_TIME_BIT | IO_BG_INFO_BIT);
      } 
    }
  }
}
/**********************************电压获取**********************************************/
void App_CalBatBoard(void)
{
  if (IO_BG_INFO_DISPLAY_ENABLE)
  {
  	if (g_batMeter.Time)
  	{
  		g_batMeter.Time--;	
  	}
  	else
  	{	
  	 	g_batMeter.Time         = 100; // 20ms*500 = 10s
  		g_batMeter.CurBoardVal  = ANALOG_KL15_VOLTAGE;
  		g_batMeter.DestPosition = g_batMeter.CurBoardVal / 100;
  		g_batMeter.CurPosition  = g_batMeter.DestPosition;
  	
  		if (g_batMeter.DestPosition > g_batMeter.CurPosition)
  		{
  			g_batMeter.CurPosition++;
  		}
  		else if (g_batMeter.DestPosition < g_batMeter.CurPosition)
  		{
  			g_batMeter.CurPosition--;
  		}
  	}
  }
}