#ifndef TOUCH_PANEL_H
#define TOUCH_PANEL_H
#include "Std_Types.h"
#include "forceSnsr/forcedetect.h"



#define PI                3.1415926f

#define TP_ERR_RANGE        15
#define TP_DEBOUNCE_CYCLE   1
#define TP_RUNNING_ERROR_CYCLE   60000

#define SLIDE_LR_MIN_DISTANCE  (30)
#define SLIDE_LR_SHORT_DISTANCE_NUM   90
#define SLIDE_UD_MIN_DISTANCE  (1.59*SLIDE_LR_MIN_DISTANCE)
#define SLIDE_UD_SHORT_DISTANCE_NUM   140

//#define SLIDE_SHORT_DISTANCE_NUM   150
#define SLIDE_CAN_EVENT_KEEP_CYCLE   30//2MS*30

#define TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM   350
#define TOUCH_KET_ON                            1
#define TOUCH_KET_OFF                           0


	
typedef enum{
	TOUCH_PANEL_NONE_EVENT = 0,
	TOUCH_PANEL_PRESS_EVENT,
}TouchPanel_EventType;

typedef enum{
	PANEL_PRESS_LEVEL0 = 0,/*< 1N*/
	PANEL_PRESS_LEVEL1,/*1N <= X < 3N*/
	PANEL_PRESS_LEVEL2 /*>= 3N*/
}PanelPress_LevelType;





typedef struct{
 uint8 convert_x;
 uint8 convert_y;
}TouchSurface_Convert_type;

typedef struct{
 float32 x;
 float32 y;
}TouchXY_type;

typedef struct{
	uint16 status;
	uint32 RunCycle;
}TouchButtons_type;

typedef enum{
	BTN_RESUME1 = 0,
	//BTN_TJP2,
	BTN_ADAS1,
	//BTN_RES2,
	BTN_CANCEL1,	
	//BTN_CANCEL2,
	/****************/
	BTN_UP,
	BTN_DOWN,
	BTN_LEFT,
	BTN_RIGHT,
	BTN_CONFIRM,
	/****************/
	BTN_MAX_CH_NUM
}Buttons_ChType;

typedef enum{
	BUTTON_RELEASE = 0,//notcative
	BUTTON_TOUCH,
	BUTTON_TOUCH_AND_PRESS,
	//BUTTON_INVALID
}Buttons_SignalType;

#define GET_TouchPanel_is_Press    Get_forcedetect_btn_is_press_state

extern volatile uint8 measurement_done_touch;

extern volatile uint8 Vibra_force_level;
extern volatile uint8 last_Vibra_force_level;

extern uint8 Vibra_PressCheck(void);

void TouchPanel_init(void);
void GetSurface_Position(uint8 *x, uint8 *y);
Buttons_SignalType TouchPanel_BtnSignalRead(Buttons_ChType ChId);
void TouchPanel_MainFunction(void);

Buttons_SignalType TouchSurface_XY_StsRead(void);
PanelPress_LevelType TouchPanel_PressLevelRead(void);
boolean TouchSurface_is_TouchActive(void);



#endif
