#ifndef __MXC_METER_H__
#define __MXC_METER_H__

typedef void (*btn_event_func)(lv_obj_t *obj);

#define LV_KEY_Q  	113
#define LV_KEY_W  	10

#define _EMOTO_   // 宏开关
#define _OMOTO_

typedef enum _ENUM_CONTROL_WIN_ID
{
    IDLE_CONTROL_WIN_ID,  // 0,
    PAGE_MAINMENU_WIN_ID, //
    SUBMENU_SET_THEME,
    SUBMENU_SET_LIGHT,      //
    SUBMENU_SET_BLUETOOTH, // 4
    SUBMENU_SET_OTHER,
    SUBMENU_SET_INFORMATION,
    SUBMENU_SET_PRESSURE,   //
    SUBMENU_SET_FAULT_CODE, //8
    SUBMENU_THEME_SELECT,
    SUBMENU_THEME_BG,
    SUBMENU_OTHER_TIME,
    SUBMENU_OTHER_LANGUAGE,
    SUBMENU_OTHER_UINT,        // 13
    MOTO_WIN_ID_MAX,
} ENUM_CONTROL_WIN_ID;

#if 0
//A27项目界面所需结构体
typedef struct
{
	uint16_t  ucYear;
	uint8_t   ucMonth;
    uint8_t   ucDate;
	uint8_t   ucHour;
	uint8_t   ucMinute;
    uint8_t   ucSecond;
}STime_t, *pSTime;

typedef struct
{
	uint8_t  mEngine;			//发动机故障
	uint8_t  mEngineOil;	    //机油报警
	uint8_t  mAbs;			    //abs防抱死
	uint8_t  mTcs;			    //tcs牵引力系统
	uint8_t  mFan;			    //风扇
	uint8_t  mNeutralGear;	    //空挡
	uint8_t  mWaterTemper;      //水温故障
	uint8_t  mBrakesFault;      //刹车故障
}Error_t, *pError;

typedef struct
{
    uint8_t  mFactorySet;       //出厂设置
	uint8_t  mLanguage;			//语言
	uint8_t  mDisplayUint;		//单位
	uint8_t  mTheme;			//当前主题
	uint8_t  mThemeState;		//主题状态
	uint8_t  mLightValue;		//亮度
	uint8_t  mBT_OnOff;			//蓝牙
	uint8_t  mBT_State;			//状态
	uint8_t  mGearPos;			//档位
	uint16_t  mFuel;			//油量
	uint32_t  mTotalMile;		//里程数
}SaveData_t, *pSaveData;

typedef struct
{
    uint8_t   mSoftMainVersion;	       //主版本号
	uint8_t   mSoftSubVersion;	       //次版本号
	//uint8_t bt_name[BT_NAME_MAX_LEN];
	uint8_t   mSetMode;                //高字节 SET 1 为短按 2为长按  低字节 MODE 1 为短按 2为长按
	uint16_t  mSpeed;                  //速度信息
	uint8_t   mGearInfo;               //档位信息
	uint32_t  mTotalMile;              //总计里程
    uint32_t  mTripMile;               //单次行驶里程
    uint8_t   mMileClearTags;          //小计里程清零标志
	uint8_t   mWifi;				   //WIFI
	uint8_t   mBlueTooth;              //蓝牙
	uint8_t   mTurn;				   //转向 	0-无 1-左转 2-右转
	uint8_t   mTurnPrompt;			   //转向提示	0无 1左 2右
    uint8_t   mTurnLight;              //转向灯  0-无 1-左转向灯 2-右转向灯
    uint8_t   mBeamLight;              //灯光	0-无灯光 1-远光 2-近光 3-自动大灯
    uint8_t   mSideMarkerLight;        //示宽灯 0-无灯光 1-示宽灯
    uint8_t   mFanLight;               //风扇灯 0-无灯光 1-灯亮
    uint8_t   mABSLight;               //0-无灯光 1-灯亮
    uint8_t   mOilPressLight;          //机油压力报警灯 0-无灯光 1-灯亮
    uint8_t   mEngineLight;            //0-无灯光 1-灯亮
    uint8_t   mRefreshTags;            //0-无刷新 1-油量/水温/电池电压刷新标志

    uint8_t   mLightValue;             //灯光亮度,具体的light_value值
	uint8_t   mSelfCheck;	           //开机自检
	uint8_t   mLightSensingVolt;       //光感电压值 （暂定范围0-3300）

	uint8_t   return_demo;             //????
	char mUuid[32];
	char mBT_name[32];
	uint16_t  mCurrentFaultCode;		//当前故障码
	uint16_t  mHistoryFaultCode;		//历史故障码

	uint8_t   mBTData_Inherit;          //继承的蓝牙数据(保留)
	uint8_t   mTtrb;					//开机检测是否获取到时间的标志
	uint8_t   mTtrb_Time;				//设施时间后检测是否正常设置时间的标志
	uint8_t   mOdo_Reset;				//小计里程清零后检测是否正常设置时间的标志
	uint8_t   mDemo_Position;			//是否在demo展示界面的标志
	Error_t     mErr;                   //告警错误
	SaveData_t  mSaveData;              //保存数据
	STime_t     mTime;                  //时间变量

	uint16_t  mPlan;		//总进度标志
	uint16_t  mPace;		//分进度标志
	uint8_t   mUpGrade;	    //内存拷贝标志

	//电摩专用属性
	#ifdef _EMOTO_
	uint8_t  mBatteryRatio;      //电池电量占比  1个字节（eg100% 传输64）
	uint8_t  mBatteryVoltage;    //电池电压 （eg3.3V 传输3300）
    #endif
    //油摩专用属性
    #ifdef _OMOTO_
	uint8_t   mEspeed;            //转速信息
	uint8_t   mFuel;              //油量指示
	uint8_t   mWaterTemper;       //水温指示
	uint8_t   mAccumulatorVolt;   //电瓶电压
    #endif

}SysData_t, *pSysData;

extern SysData_t UserData;

STime_t* getCurrentTime1();
SysData_t* GetDailyData1(void);
void SystemDate_Init(void);

#endif
typedef struct
{
	uint8_t engine;			//����������
	uint8_t machine_oil;	    //���ͱ���
	uint8_t abs;				//abs������
	uint8_t tcs;				//tcsǣ����ϵͳ
	uint8_t fan;				//����
	uint8_t null;	    //�յ�
}warning_t;

typedef struct
{
	uint16_t	ucYear;
	uint8_t		ucMonth;
    uint8_t		ucDate;
	uint8_t		ucHour;
	uint8_t		ucMinute;
    uint8_t		ucSecond;
}stTime_type;

typedef struct
{
    uint8_t factory_reset;      //��������
    uint8_t language;           //����
    uint8_t display_uint;       //��λ
    uint8_t theme;              //��ǰ����
    uint8_t theme_state;        //����״̬
    uint8_t light_value;        //����
    uint8_t bt_on_off;          //����
    uint8_t bt_state;           //״̬

}save_info_t;

typedef struct
{
    uint8_t softwar_host;   //���汾��
    uint8_t softwar_order;  //�ΰ汾��
    uint8_t ui_page_id;
    //time
	stTime_type time;
    save_info_t save_info;
    uint8_t veer;           //ת��
    uint8_t veer_hint;      //ת����ʾ
    uint8_t lamplight;      //�ƹ�
    uint8_t power_on_self_test;	        //�����Լ�
	uint8_t light_perception_value;		//�������
	uint8_t light;			            //�����light_valueֵ
	uint8_t return_demo;
	uint16_t velocity;					//�ٶ�
	uint16_t veer_velocity;				//ת��
    uint8_t grade;             //��λ
    uint8_t oil;               //����
    uint8_t temp;			   //�¶�
	double trip_mileage;       //С�������
    uint32_t total_mileage;    //�ܼ������
	double voltage;			   //��ص�ѹ
    warning_t warning;         //����ͼ��
    uint16_t max_velocity;     //���ʱ��
    uint16_t verage_velocity;       //ƽ��ʱ��
	char uuid[32];
	char bt_name[32];
	uint32_t now_defect_code;		//��ǰ������
	uint32_t his_defect_code;		//��ʷ������
	uint8_t ttrb;					//��������Ƿ��ȡ��ʱ��ı�־
	uint8_t ttrb_time;				//��ʩʱ������Ƿ���������ʱ��ı�־
	uint8_t odo_reset;				//С�������������Ƿ���������ʱ��ı�־
	uint8_t demo_position;				//�Ƿ���demoչʾ����ı�־
	uint16_t plan;		//�����ܽ��ȱ�־
	uint16_t pace;		//�����ֽ��ȱ�־
	uint8_t upgrade;	//�����ڴ濽����־

}daily_data_t;

extern daily_data_t custom_data;

daily_data_t *daily_get_UiData(void);
ENUM_CONTROL_WIN_ID get_top_history_win(void);
void Set_UI_page_id(ENUM_CONTROL_WIN_ID id);
void system_date_init(void);
void updateCurTime();
stTime_type * getCurrentTime();
daily_data_t* GetDailyData(void);
char * GetCurTimeString();


#endif
