1766 lines
46 KiB
C

#include "TouchPanel.h"
//#include "TouchPanel_Cfg.h"
#include "Std_Types.h"
#include "device.h"
#include "touch/touch.h"
#include "math.h"
#include "stdlib.h"
#include <stddef.h> // Defines NULL
#include <stdbool.h> // Defines true
#include <stdlib.h> // Defines EXIT_FAILURE
#include "definitions.h" // SYS function prototypes
#include "OsekCom/OsekCom.h"
#include "Speaker/Speaker.h"
#include "P417_SWTL_App_ert_rtw/P417_SWTL_App.h"
#include "TouchPanel/TouchPanel.h"
#include "forceSnsr/forcedetect.h"
#include "TLE9263/TLE926x_Main.h"
#include "RTE.h"
#include "calib_public.h"
#include "smartee.h"
#include "SysDiagDetect.h"
static uint16 sensor_signal[DEF_NUM_CHANNELS] = {0};
static uint16 sensor_reference[DEF_NUM_CHANNELS] = {0};
static TouchButtons_type key_status[BTN_MAX_CH_NUM - 5U] = {0};
static TouchSurface_type TouchSurface;
static Buttons_SignalType Buttons_Signal[BTN_MAX_CH_NUM] = {BUTTON_RELEASE};
static TouchSlideEvent_type TouchSlideEvent;
TouchSurface_Convert_type Surface_Convert;
static PanelPress_LevelType TouchPanel_PressLevel = PANEL_PRESS_LEVEL0;
static float32 TouchPanel_PressNValue = 0.0f;//0N
static uint8 TouchPanel_SurfaceStatus = 0;
static uint16 TouchPanel_PressRawData = 0;
//kailong add
volatile uint16 g_Trig_Threshold=350;
volatile uint16 g_Release_Threshold=175;
volatile uint8 K_Vibra_Trig_pad=0;
volatile uint8 Reach2_flag = 0x00;
volatile uint8 Vibra_force_level=0;
volatile uint8 last_Vibra_force_level=0;
volatile uint8 Over3N_vibra_req = 0x00;
volatile uint8 Below1P5N_vibra_req = 0x00;
uint8 UDS_Vibration_Gain = 0;
uint8 UDS_DAC_Timer_Period = 80;
uint8 Touch_Flag = TOUCH_KET_OFF;
uint8 CurrentPosition = 0xff;//0xff no position 1:fun1 2:fun2 3:fun3 4:up 5:down 6:left 7:right 8:ok
uint8 Surface_Button = 0xff;
#define RESUME1_DEFAULT 339
#define ADAS1_DEFAULT 412
#define CANCEL1_DEFAULT 576
#define BTN_UP_DEFAULT 269
#define BTN_DOWN_DEFAULT 398
#define BTN_LEFT_DEFAULT 261
#define BTN_RIGHT_DEFAULT 372
#define BTN_CONFIRM_DEFAULT 303
//force Trig threshold
static uint16 Button0_GetRESUME1_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(0U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=RESUME1_DEFAULT;
}
else
{
rtn=Calib_GetData(0U);
}
return rtn;
// return 800;
}
//static uint16 Button1_GetVoice2_Trig_Threshold(void)
//{
// return 400;
//}
//static uint16 Button2_GetVol2_Trig_Threshold(void)
//{
// return 1600;
//}
static uint16 Button3_GetADAS1_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(1U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=ADAS1_DEFAULT;
}
else
{
rtn=Calib_GetData(1U);
}
return rtn;
}
//static uint16 Button4_GetMenu2_Trig_Threshold(void)
//{
// return 1600;
//}
static uint16 Button5_GetCANCEL1_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(2U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=CANCEL1_DEFAULT;
}
else
{
rtn=Calib_GetData(2U);
}
return rtn;
}
static uint16 Button6_GetBTN_UP_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(3U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_UP_DEFAULT;
}
else
{
rtn=Calib_GetData(3U);
}
return rtn;
}
static uint16 Button7_GetBTN_DOWN_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(4U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_DOWN_DEFAULT;
}
else
{
rtn=Calib_GetData(4U);
}
return rtn;
}
static uint16 Button8_GetBTN_LEFT_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(5U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_LEFT_DEFAULT;
}
else
{
rtn=Calib_GetData(5U);
}
return rtn;
}
static uint16 Button9_GetBTN_RIGHT_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(6U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_RIGHT_DEFAULT;
}
else
{
rtn=Calib_GetData(6U);
}
return rtn;
}
static uint16 Button10_GetBTN_CONFIRM_Trig_Threshold(void)
{
uint16 temp = Calib_GetData(7U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_CONFIRM_DEFAULT;
}
else
{
rtn=Calib_GetData(7U);
}
return rtn;
}
//force Release threshold
static uint16 Button0_GetRESUME1_Release_Threshold(void)
{
uint16 temp = Calib_GetData(0U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=RESUME1_DEFAULT/2;
}
else
{
rtn=Calib_GetData(0U)/2;
}
return rtn;
}
//static uint16 Button1_GetVoice2_Release_Threshold(void)
//{
// return 200;
//}
//static uint16 Button2_GetVol2_Release_Threshold(void)
//{
// return 400;
//}
static uint16 Button3_GetADAS1_Release_Threshold(void)
{
uint16 temp = Calib_GetData(1U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=ADAS1_DEFAULT/2;
}
else
{
rtn=Calib_GetData(1U)/2;
}
return rtn;
}
//static uint16 Button4_GetMenu2_Release_Threshold(void)
//{
// return 400;
//}
static uint16 Button5_GetCANCEL1_Release_Threshold(void)
{
uint16 temp = Calib_GetData(2U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=CANCEL1_DEFAULT/2;
}
else
{
rtn=Calib_GetData(2U)/2;
}
return rtn;
}
static uint16 Button6_GetBTN_UP_Release_Threshold(void)
{
uint16 temp = Calib_GetData(3U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_UP_DEFAULT/2;
}
else
{
rtn=Calib_GetData(3U)/2;
}
return rtn;
}
static uint16 Button7_GetBTN_DOWN_Release_Threshold(void)
{
uint16 temp = Calib_GetData(4U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_DOWN_DEFAULT/2;
}
else
{
rtn=Calib_GetData(4U)/2;
}
return rtn;
}
static uint16 Button8_GetBTN_LEFT_Release_Threshold(void)
{
uint16 temp = Calib_GetData(5U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_LEFT_DEFAULT/2;
}
else
{
rtn=Calib_GetData(5U)/2;
}
return rtn;
}
static uint16 Button9_GetBTN_RIGHT_Release_Threshold(void)
{
uint16 temp = Calib_GetData(6U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_RIGHT_DEFAULT/2;
}
else
{
rtn=Calib_GetData(6U)/2;
}
return rtn;
}
static uint16 Button10_GetBTN_CONFIRM_Release_Threshold(void)
{
uint16 temp = Calib_GetData(7U);
uint16 rtn = 0;
if(temp == 0)
{
rtn=BTN_CONFIRM_DEFAULT/2;
}
else
{
rtn=Calib_GetData(7U)/2;
}
return rtn;
}
/**
* \brief Sets buffers to a specified byte value.
* \param pDestP buffer with set value
* \param u8ValueP byte value
* \param BytesCountP number of bytes
* \return None
*/
static void LIB_Mem_MemSet (void * const pDestP, const uint8 u8ValueP, const uint32 u32BytesCountP)
{
uint8 * pu8BufL = (uint8 *)pDestP;
uint32 u32IdxL;
if( (NULL_PTR != pu8BufL) )
{
u32IdxL = u32BytesCountP;
while( u32IdxL > (uint32)0 )
{
--u32IdxL;
(*pu8BufL) = u8ValueP;
pu8BufL = &pu8BufL[1];
}
}
}
static float32 AlideAverage_Filter(uint8 mode, float32 RawData)
{
#define MAX_ALIDE_AVG_NUM 8
static uint16 CalcAverageNum = 0;
static uint16 DIndex = 0;
static uint16 Mode_Status = 0;
static float32 RawData_Table[MAX_ALIDE_AVG_NUM] = {0};
uint16 i;
float32 Sum = 0;
float32 AverageValue = 0;
if(mode == 0x00){
CalcAverageNum = 0;
DIndex = 0;
Mode_Status = 0;
for(i=0; i<MAX_ALIDE_AVG_NUM; i++){
RawData_Table[i] = 0.0f;
}
}else{
if(Mode_Status == 0x00)
{
if(CalcAverageNum < MAX_ALIDE_AVG_NUM)
{
RawData_Table[CalcAverageNum++] = RawData;
for(i=0; i<CalcAverageNum; i++)
{
Sum += RawData_Table[i];
}
}
if(CalcAverageNum >= MAX_ALIDE_AVG_NUM)
{
Mode_Status = 0x01;
DIndex = 0;
}
AverageValue = Sum/((float32)CalcAverageNum + 0.000001f);
}
else
{
RawData_Table[DIndex++] = RawData;
if(DIndex >= MAX_ALIDE_AVG_NUM){
DIndex = 0x00;
}
for(i=0; i<MAX_ALIDE_AVG_NUM; i++)
{
Sum += RawData_Table[i];
}
AverageValue = Sum/MAX_ALIDE_AVG_NUM;
}
}
return AverageValue;
}
void TouchPanel_init(void)
{
uint8 index;
//touch_init();
uint8_t eedata[5];
LIB_Mem_MemSet(&TouchSurface, 0x00U, sizeof(TouchSurface_type));
LIB_Mem_MemSet(&TouchSlideEvent, 0x00U, sizeof(TouchSlideEvent_type));
LIB_Mem_MemSet(&Surface_Convert, 0x00U, sizeof(TouchSurface_Convert_type));
SmartEE_Read(0x780, eedata, 3);
if(eedata[0]< 4)
{
UDS_Vibration_Gain = eedata[0];
}else
{
UDS_Vibration_Gain = SA51024_STRENGTH_LEVEL0;
}
if(eedata[2] < 255 && eedata[2] >= 40)
{
UDS_DAC_Timer_Period = eedata[2];
}
else
{
UDS_DAC_Timer_Period = 110;
}
TC2_REGS->COUNT16.TC_CC[0U] = UDS_DAC_Timer_Period;
AlideAverage_Filter(0, 0);
TouchPanel_PressLevel = PANEL_PRESS_LEVEL0;
TouchPanel_PressNValue = 0.0f;//0N
TouchPanel_SurfaceStatus = 0;
TouchPanel_PressRawData = 0;
for(index = 0; index< DEF_NUM_CHANNELS; index++)
{
sensor_signal[index] = 0x00;
sensor_reference[index] = 0x00;
if(index < (BTN_MAX_CH_NUM-5u)){
key_status[index].status = 0x00;
key_status[index].RunCycle = 0x00;
}
if(index < BTN_MAX_CH_NUM ){
Buttons_Signal[index] = BUTTON_RELEASE;
}
}
}
void GetSurface_Position(uint8 *x, uint8 *y)
{
if(x != NULL_PTR){
*x = Surface_Convert.convert_x;
}
if(y != NULL_PTR){
*y = Surface_Convert.convert_y;
}
}
TP_SlideDirection_Enum TouchPanel_SlideEventRead(void)
{
TP_SlideDirection_Enum Dir = TP_SlideDirection_NONE;
if(TouchSlideEvent.Event == TRUE){
Dir = TouchSlideEvent.Direction;
//TouchSlideEvent.Event = FALSE;
}
return Dir;
}
Buttons_SignalType TouchPanel_BtnSignalRead(Buttons_ChType ChId)
{
Buttons_SignalType Signal = BUTTON_RELEASE;
if(ChId < BTN_MAX_CH_NUM)
{
Signal = Buttons_Signal[ChId];
}
return Signal;
}
PanelPress_LevelType TouchPanel_PressLevelRead(void)
{
return TouchPanel_PressLevel;
}
boolean TouchSurface_is_TouchActive(void)
{
boolean ret = FALSE;
if (TouchPanel_SurfaceStatus & TOUCH_ACTIVE)
{
ret = TRUE;
}
return ret;
}
Buttons_SignalType TouchSurface_XY_StsRead(void)
{
Buttons_SignalType XY_Sts = BUTTON_RELEASE;
if (TouchPanel_SurfaceStatus & TOUCH_ACTIVE)
{
switch (TouchPanel_PressLevel)
{
case PANEL_PRESS_LEVEL0:
XY_Sts = BUTTON_TOUCH;
break;
case PANEL_PRESS_LEVEL1:
XY_Sts = BUTTON_TOUCH;
break;
case PANEL_PRESS_LEVEL2:
XY_Sts = BUTTON_TOUCH_AND_PRESS;
break;
default:
break;
}
}
return XY_Sts;
}
static PanelPress_LevelType TouchPanel_PressCheck(void)
{
//static uint16 ForceHcount = 0;
//static uint16 ForceMcount = 0;
//static uint16 ForceLcount = 0;
static uint16 tempForcePress = 0;
static uint16 tempForceRelease = 0;
uint16 RawData = 0;
uint16 temp_RawData = 0;
static uint16 LastRawData = 0;
static PanelPress_LevelType Last_PressLevel = PANEL_PRESS_LEVEL0;
static uint8 P_force_Reach2_flag = 0;
PanelPress_LevelType ret_Press = PANEL_PRESS_LEVEL0;
float32 FilterValue;
uint16 Backup_Force_Value;
Backup_Force_Value=Touch_Sensor_delta03+Touch_Sensor_delta04+Touch_Sensor_delta05+Touch_Sensor_delta06+Touch_Sensor_delta07+
+Touch_Sensor_delta08+Touch_Sensor_delta09+Touch_Sensor_delta10+Touch_Sensor_delta11+Touch_Sensor_delta12;
//float32 PressNValueTable[3][2] = {
// {1.21f, 1.73f},
// {0.5f, 3.0f},
// {1.0f, 1.8f}
//};
if(CurrentPosition != 0xff)
{
tempForcePress = g_Trig_Threshold;
tempForceRelease = g_Release_Threshold;
}
if(Last_PressLevel > PANEL_PRESS_LEVEL2){ Last_PressLevel = PANEL_PRESS_LEVEL0;}
////if(TRUE == GET_TouchPanel_is_Press())
temp_RawData = (0xfff & Get_forcedetect_force_value());
if(SPEAKER_UPDATE_CYCLE == Get_Speaker_Main_State() || SPEAKER_START == Get_Speaker_Main_State())
{
RawData = LastRawData;
}
else
{
if(temp_RawData&0x800)//negative
{
RawData = 0x00;
}else{
RawData = temp_RawData;
}
if(abs(RawData - LastRawData) > (10*0xF2))
{
RawData = LastRawData;
}
}
TouchPanel_PressRawData = RawData;
TouchPanel_PressNValue = ((float32)RawData / (float32)0xF2);
FilterValue = AlideAverage_Filter(1, TouchPanel_PressNValue);
if(Force_Sens_Err == 0)
{
if(FilterValue <= ((float32)tempForceRelease/ (float32)0xF2)){//< 1.5N
// ForceHcount = 0;
// ForceMcount = 0;
//ForceLcount++;
P_force_Reach2_flag = 0;
// if(ForceLcount > 40)
//{
// ForceLcount = 40;
ret_Press = PANEL_PRESS_LEVEL0;
// }
Vibra_force_level=PANEL_PRESS_LEVEL0;
}
else if(FilterValue >= ((float32)tempForceRelease/ (float32)0xF2) &&
FilterValue < ((float32)tempForcePress/ (float32)0xF2)){//1.5N~~3N
//ForceHcount = 0;
// ForceMcount++;
// ForceLcount = 0;
// if(ForceMcount > 40)
// {
// ForceMcount = 40;
if(P_force_Reach2_flag==1)
{
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
Vibra_force_level=PANEL_PRESS_LEVEL2;
ret_Press = PANEL_PRESS_LEVEL2;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
}
else
{
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
Vibra_force_level=PANEL_PRESS_LEVEL1;
ret_Press = PANEL_PRESS_LEVEL1;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
}
}
else {//>=3
//ForceHcount++;
//ForceMcount = 0;
// ForceLcount = 0;
P_force_Reach2_flag = 1;
// if(ForceHcount > 40)
// {
// ForceHcount = 40;
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
ret_Press = PANEL_PRESS_LEVEL2;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
Vibra_force_level=PANEL_PRESS_LEVEL2;
}
}
else //backup When force sensor error happened
{
if(Backup_Force_Value <= 100){//< 1.5N
// ForceHcount = 0;
// ForceMcount = 0;
//ForceLcount++;
P_force_Reach2_flag = 0;
// if(ForceLcount > 40)
//{
// ForceLcount = 40;
ret_Press = PANEL_PRESS_LEVEL0;
// }
Vibra_force_level=PANEL_PRESS_LEVEL0;
}
else if(Backup_Force_Value >= 100 &&
Backup_Force_Value < 200){//1.5N~~3N
//ForceHcount = 0;
// ForceMcount++;
// ForceLcount = 0;
// if(ForceMcount > 40)
// {
// ForceMcount = 40;
if(P_force_Reach2_flag==1)
{
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
Vibra_force_level=PANEL_PRESS_LEVEL2;
ret_Press = PANEL_PRESS_LEVEL2;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
}
else
{
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
Vibra_force_level=PANEL_PRESS_LEVEL1;
ret_Press = PANEL_PRESS_LEVEL1;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
}
}
else {//>=3
//ForceHcount++;
//ForceMcount = 0;
// ForceLcount = 0;
P_force_Reach2_flag = 1;
// if(ForceHcount > 40)
// {
// ForceHcount = 40;
//if(TOUCH_SCREEN_CONTACT_AREA_INVALID_NUM > get_contact_size())
//{
ret_Press = PANEL_PRESS_LEVEL2;
//}
//else
//{
// ret_Press = PANEL_PRESS_LEVEL0;
// Vibra_force_level=PANEL_PRESS_LEVEL0;
//}
Vibra_force_level=PANEL_PRESS_LEVEL2;
}
}
LastRawData = RawData;
Last_PressLevel = ret_Press;
return ret_Press;
}
static Buttons_SignalType TouchSurface_BntCheck(Buttons_ChType ChId, TouchPanel_EventType TP_Event)
{
Buttons_SignalType BSignal = BUTTON_RELEASE;
//static uint8 PB_force_Reach2_flag = 0;
//uint8 x_pos = 0, y_pos = 0;
uint8 data_ready = 0x00;
//GetSurface_Position(&x_pos, &y_pos);
switch(ChId)
{
case BTN_UP:
if (Surface_Button ==1)//37
{
data_ready = 0x01;
}
break;
case BTN_DOWN:
if (Surface_Button ==2)//223
{
data_ready = 0x01;
}
break;
case BTN_LEFT:
if (Surface_Button ==3)
{
data_ready = 0x01;
}
break;
case BTN_RIGHT:
if (Surface_Button ==4)
{
data_ready = 0x01;
}
break;
case BTN_CONFIRM:
if (Surface_Button ==5)
{
data_ready = 0x01;
}
break;
default: break;
}
if(data_ready != 0x00)
{
if(TP_Event == TOUCH_PANEL_PRESS_EVENT)
{
switch (TouchPanel_PressLevel)
{
case PANEL_PRESS_LEVEL0:
BSignal = BUTTON_TOUCH;
break;
case PANEL_PRESS_LEVEL1:
BSignal = BUTTON_TOUCH;
break;
case PANEL_PRESS_LEVEL2:
BSignal = BUTTON_TOUCH_AND_PRESS;
break;
default:
break;
}
}else if(TP_Event == TOUCH_PANEL_BERR_EVENT){
BSignal = BUTTON_RELEASE;//////////////BUTTON_INVALID;
}
}
return BSignal;
}
static Buttons_SignalType TouchButton_BntCheck(Buttons_ChType ChId)
{
Buttons_SignalType BSignal = BUTTON_RELEASE;
//static uint8 TB_force_Reach2_flag = 0;
if(ChId == BTN_RESUME1 || ChId == BTN_ADAS1 || ChId == BTN_CANCEL1)
{
key_status[ChId].status = get_sensor_state(ChId);
if (ChId == BTN_CANCEL1)
{
key_status[ChId].status = (get_sensor_state(ChId) == QTM_KEY_STATE_DETECT || get_sensor_state(ChId+13) == QTM_KEY_STATE_DETECT)?QTM_KEY_STATE_DETECT:get_sensor_state(ChId);
}
if (QTM_KEY_STATE_DETECT == (key_status[ChId].status)) {//KEY_TOUCHED_MASK
//Touch detect
key_status[ChId].RunCycle++;
if(TP_RUNNING_ERROR_CYCLE <= key_status[ChId].RunCycle){
key_status[ChId].RunCycle = TP_RUNNING_ERROR_CYCLE;
BSignal = BUTTON_RELEASE;//BUTTON_INVALID;
}else{
if(Force_Sens_Err == 0)
{
switch (TouchPanel_PressLevel)
{
case PANEL_PRESS_LEVEL0:
BSignal = BUTTON_TOUCH;
case PANEL_PRESS_LEVEL1:
BSignal = BUTTON_TOUCH;
// }
break;
case PANEL_PRESS_LEVEL2:
BSignal = BUTTON_TOUCH_AND_PRESS;
break;
default:
break;
}
}
else //backup When force sensor error happened
{
BSignal = BUTTON_TOUCH;
}
}
} else {
//Touch No detect
key_status[ChId].RunCycle = 0x00;
}
}
return BSignal;
}
static float32 GetSlide_Angle(float32 dx, float32 dy)
{
return(atan2(dy, dx) * 180 / PI);
}
/**************************************************************/
// x X(y)
// y <---------- ^(0,0) ^
// | mapping |
// | =======> |
// | |
// | X(-y)<-------|(0,0)
/*************************************************************/
static TP_SlideDirection_Enum GetSlide_Direction(uint8 startX, uint8 startY, uint8 endX, uint8 endY)
{
TP_SlideDirection_Enum result = TP_SlideDirection_NONE;
sint32 CoordMapping_sx,CoordMapping_sy;
sint32 CoordMapping_ex,CoordMapping_ey;
uint16 absx,absy;
sint32 dy,dx;
float32 angle;
CoordMapping_sx = (-1u * (sint32)startX);
CoordMapping_sy = (-1u * (sint32)startY);
CoordMapping_ex = (-1u * (sint32)endX);
CoordMapping_ey = (-1u * (sint32)(endY));
dx = CoordMapping_ex - CoordMapping_sx;
dy = CoordMapping_ey - CoordMapping_sy;
absx = abs(dx);
absy = abs(dy);
if(TouchSurface.Event == TOUCH_PANEL_MOVE_EVENT && (absx > SLIDE_LR_MIN_DISTANCE || absy > SLIDE_UD_MIN_DISTANCE) )
{
/*Ignore small Slide*/
angle = GetSlide_Angle(dx, dy);
if (angle >= -45.0 && angle < 45.0)
{
if(absx > SLIDE_LR_SHORT_DISTANCE_NUM){
result = TP_SlideDirection_LongRIGHT;
}else{
result = TP_SlideDirection_ShortRIGHT;
}
}
else if (angle >= 45.0 && angle < 135.0)
{
if(absy > SLIDE_UD_SHORT_DISTANCE_NUM){
result = TP_SlideDirection_LongUP;
}else{
result = TP_SlideDirection_ShortUP;
}
} else if (angle >= -135.0 && angle < -45.0)
{
if(absy > SLIDE_UD_SHORT_DISTANCE_NUM){
result = TP_SlideDirection_LongDOWN;
}else{
result = TP_SlideDirection_ShortDOWN;
}
}
else if ((angle >= 135.0 && angle <= 180.0) || (angle >= -180.0 && angle < -135.0))
{
if(absx > SLIDE_LR_SHORT_DISTANCE_NUM){
result = TP_SlideDirection_LongLEFT;
}else{
result = TP_SlideDirection_ShortLEFT;
}
}
}
return result;
}
struct Point {
float x;
float y;
};
// ~{EP6OR;8v5cJG7qTZH}=GPNDZ2?~}
uint8_t point_in_triangle(struct Point p, struct Point p1, struct Point p2, struct Point p3) {
float s = p1.y * p3.x - p1.x * p3.y + (p3.y - p1.y) * p.x + (p1.x - p3.x) * p.y;
float t = p1.x * p2.y - p1.y * p2.x + (p1.y - p2.y) * p.x + (p2.x - p1.x) * p.y;
if ((s < 0) != (t < 0)) return 0;
float A = -p2.y * p3.x + p1.y * (p3.x - p2.x) + p1.x * (p2.y - p3.y) + p2.x * p3.y;
if (A < 0.0) {
s = -s;
t = -t;
A = -A;
}
return (s > 0 && t > 0 && (s + t) < A);
}
// ~{EP6OR;8v5cJG7qTZKD1_PNDZ2?~}
uint8_t point_in_quadrilateral(struct Point p, struct Point q1, struct Point q2, struct Point q3, struct Point q4) {
return point_in_triangle(p, q1, q2, q3) || point_in_triangle(p, q1, q3, q4);
}
static void TouchPanel_XY_Convert(uint8 origin_x, uint8 origin_y)
{
#define Y_OFFSET 40
#define START_X 95
#define START_Y 240
#define END_X 255
#define END_Y 197
TouchXY_type start,end;
float32 k,b,y;
uint8 temp_x, temp_y;
uint8 convert_x,convert_y;
float32 f_x;
temp_x = origin_y;
f_x = (((float32)temp_x)/(255.0f/160.0f));// 255u-95u
if(f_x - (uint32)(f_x) < 0.5f){
convert_x = (uint8)f_x + 95u;
}else{ convert_x = (uint8)f_x + 1u + 95u;}
temp_y = origin_x;
/*******************************************/
start.x = START_X;
start.y = START_Y;
end.x = END_X;
end.y = END_Y;
k = ((end.y - start.y)/(end.x - start.x));
b = (start.y - k * start.x);
y = k*convert_x + b;
convert_y =(uint8)(((float32)temp_y * (y - Y_OFFSET))/255 + Y_OFFSET);
Surface_Convert.convert_x = convert_x; //KalmanFilter(convert_x, 0);
Surface_Convert.convert_y = convert_y; //KalmanFilter(convert_y, 0);
}
void touch_test(void)
{
}
extern uint8_t Allow_Touch_flag;
//static uint16_t touch_delay = 500;
void TouchPanel_MainFunction(void)
{
uint8 index;
uint8 x1,y1, x2,y2, Temp_x,Temp_y;
uint8 touchEnd_flag = 0x00;
uint8 pad_trig_x,pad_trig_y;//by kailong
uint8 count = 0;
uint8 K_Vibra_Trig_adas=0;
uint8 K_Vibra_Trig_cancel=0;
uint8 K_Vibra_Trig_resume=0;
static uint8 threshold_select_resume = 0;
static uint8 threshold_select_adas = 0;
static uint8 threshold_select_cancel = 0;
static uint8 threshold_select_up = 0;
static uint8 threshold_select_down = 0;
static uint8 threshold_select_left = 0;
static uint8 threshold_select_right = 0;
static uint8 threshold_select_confirm = 0;
touch_process();
//kailong add
if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_ADAS1) && QTM_KEY_STATE_DETECT == get_sensor_state(BTN_ADAS1+13))
{
CurrentPosition = 2;
threshold_select_adas=1;
}
else
{
threshold_select_adas=0;
}
if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_RESUME1) && QTM_KEY_STATE_DETECT == get_sensor_state(BTN_RESUME1+13))
{
CurrentPosition = 1;
threshold_select_resume=1;
}
else
{
threshold_select_resume=0;
}
if (QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1) || QTM_KEY_STATE_DETECT == get_sensor_state(BTN_CANCEL1+13))
{
CurrentPosition = 3;
threshold_select_cancel=1;
}
else
{
threshold_select_cancel=0;
}
if((TouchPanel_SurfaceStatus & TOUCH_ACTIVE) == 1)
{
struct Point Current_XY;
#if 1
struct Point Point_Up[4] = {
{76,0},
{255,41},
{206,87},
{135,87},
};
struct Point Point_Down[4] = {
{135,169},
{206,169},
{255,199},
{106,255},
};
struct Point Point_Right[4] = {
{76,21},
{135,87},
{135,169},
{96,255},
};
struct Point Point_Left[4] = {
{206,87},
{255,48},
{255,183},
{206,169},
};
struct Point Point_Confirm[4] = {
{140,92},
{206,92},
{206,164},
{140,164},
};
#endif
//point_in_quadrilateral(Current_XY,Point_Up[0],Point_Up[1],Point_Up[2],Point_Up[3])
GetSurface_Position(&pad_trig_x, &pad_trig_y);
Current_XY.x = (float)pad_trig_x;
Current_XY.y = (float)pad_trig_y;
if(point_in_quadrilateral(Current_XY,Point_Up[0],Point_Up[1],Point_Up[2],Point_Up[3]))
{
if(CurrentPosition != 1 && CurrentPosition != 2 && CurrentPosition != 3 )
{
CurrentPosition = 4;
K_Vibra_Trig_pad=1;
threshold_select_up=1;
Surface_Button = 1;
}
}
else if(point_in_quadrilateral(Current_XY,Point_Down[0],Point_Down[1],Point_Down[2],Point_Down[3]))
{
if(CurrentPosition != 1 && CurrentPosition != 2 && CurrentPosition != 3 )
{
CurrentPosition = 5;
K_Vibra_Trig_pad=1;
threshold_select_down=1;
Surface_Button = 2;
}
}
else if(point_in_quadrilateral(Current_XY,Point_Right[0],Point_Right[1],Point_Right[2],Point_Right[3]))
{
if(CurrentPosition != 1 && CurrentPosition != 2 && CurrentPosition != 3 )
{
CurrentPosition = 7;
K_Vibra_Trig_pad=1;
threshold_select_right=1;
Surface_Button = 4;
}
}
else if(point_in_quadrilateral(Current_XY,Point_Left[0],Point_Left[1],Point_Left[2],Point_Left[3]))
{
if(CurrentPosition != 1 && CurrentPosition != 2 && CurrentPosition != 3 )
{
CurrentPosition = 6;
K_Vibra_Trig_pad=1;
threshold_select_left=1;
Surface_Button = 3;
}
}
else if(point_in_quadrilateral(Current_XY,Point_Confirm[0],Point_Confirm[1],Point_Confirm[2],Point_Confirm[3]))
{
if(CurrentPosition != 1 && CurrentPosition != 2 && CurrentPosition != 3 )
{
CurrentPosition = 8;
K_Vibra_Trig_pad=1;
threshold_select_confirm=1;
Surface_Button = 5;
}
}
}
else
{
K_Vibra_Trig_pad=0;
threshold_select_up=0;
threshold_select_down=0;
threshold_select_right=0;
threshold_select_left=0;
threshold_select_confirm=0;
Surface_Button = 0;
}
switch (CurrentPosition)
{
case 1:
g_Trig_Threshold=Button0_GetRESUME1_Trig_Threshold();
g_Release_Threshold=Button0_GetRESUME1_Release_Threshold();
break;
case 2:
g_Trig_Threshold= Button3_GetADAS1_Trig_Threshold();
g_Release_Threshold= Button3_GetADAS1_Release_Threshold();
break;
case 3:
g_Trig_Threshold=Button5_GetCANCEL1_Trig_Threshold();
g_Release_Threshold= Button5_GetCANCEL1_Release_Threshold();
break;
case 4:
g_Trig_Threshold=Button6_GetBTN_UP_Trig_Threshold();
g_Release_Threshold= Button6_GetBTN_UP_Release_Threshold();
break;
case 5:
g_Trig_Threshold=Button7_GetBTN_DOWN_Trig_Threshold();
g_Release_Threshold= Button7_GetBTN_DOWN_Release_Threshold();
break;
case 6:
g_Trig_Threshold=Button8_GetBTN_LEFT_Trig_Threshold();
g_Release_Threshold= Button8_GetBTN_LEFT_Release_Threshold();
break;
case 7:
g_Trig_Threshold=Button9_GetBTN_RIGHT_Trig_Threshold();
g_Release_Threshold= Button9_GetBTN_RIGHT_Release_Threshold();
break;
case 8:
g_Trig_Threshold=Button10_GetBTN_CONFIRM_Trig_Threshold();
g_Release_Threshold= Button10_GetBTN_CONFIRM_Release_Threshold();
break;
default:
break;
}
/*
if(threshold_select_resume == 1 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button0_GetRESUME1_Trig_Threshold();
g_Release_Threshold=Button0_GetRESUME1_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==1 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold= Button3_GetADAS1_Trig_Threshold();
g_Release_Threshold= Button3_GetADAS1_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==1 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button5_GetCANCEL1_Trig_Threshold();
g_Release_Threshold= Button5_GetCANCEL1_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==1 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button6_GetBTN_UP_Trig_Threshold();
g_Release_Threshold= Button6_GetBTN_UP_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==1 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button7_GetBTN_DOWN_Trig_Threshold();
g_Release_Threshold= Button7_GetBTN_DOWN_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==1 && threshold_select_right==0 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button8_GetBTN_LEFT_Trig_Threshold();
g_Release_Threshold= Button8_GetBTN_LEFT_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==1 && threshold_select_confirm==0 )
{
g_Trig_Threshold=Button9_GetBTN_RIGHT_Trig_Threshold();
g_Release_Threshold= Button9_GetBTN_RIGHT_Release_Threshold();
}
else if(threshold_select_resume == 0 && threshold_select_adas==0 && threshold_select_cancel==0 && threshold_select_up==0 && threshold_select_down==0 && threshold_select_left==0 && threshold_select_right==0 && threshold_select_confirm==1 )
{
g_Trig_Threshold=Button10_GetBTN_CONFIRM_Trig_Threshold();
g_Release_Threshold= Button10_GetBTN_CONFIRM_Release_Threshold();
}
else
{
g_Trig_Threshold=Button10_GetBTN_CONFIRM_Trig_Threshold();
g_Release_Threshold= Button10_GetBTN_CONFIRM_Release_Threshold();
}
*/
//InitMessage(SIG_SWTLSENSOR1_BASELINE, &g_Trig_Threshold);
TouchPanel_PressLevel = TouchPanel_PressCheck();
if(measurement_done_touch == 1)
{
// process touch data
for(index = 0; index< DEF_NUM_CHANNELS; index++){
sensor_signal[index] = get_sensor_node_signal(index);
sensor_reference[index] = get_sensor_node_reference(index);
}
TouchPanel_SurfaceStatus = get_surface_status();
if (TouchPanel_SurfaceStatus & TOUCH_ACTIVE)
{
Temp_x = get_surface_position(HOR_POS);
Temp_y = get_surface_position(VER_POS);
TouchPanel_XY_Convert(Temp_x, Temp_y);
TouchSurface.x_position = Surface_Convert.convert_x;
TouchSurface.y_position = Surface_Convert.convert_y;
if(TouchSurface.end_x_pos == 0x00 && TouchSurface.end_y_pos == 0x00){
TouchSurface.end_x_pos = TouchSurface.x_position;
TouchSurface.end_y_pos = TouchSurface.y_position;
}
if(TouchSurface.Event == TOUCH_PANEL_NONE_EVENT){
x1 = TouchSurface.end_x_pos; y1 = TouchSurface.end_y_pos;
x2 = TouchSurface.x_position; y2 = TouchSurface.y_position;
}else{
x1 = TouchSurface.origin_x_pos; y1 = TouchSurface.origin_y_pos;
x2 = TouchSurface.x_position; y2 = TouchSurface.y_position;
}
TouchSurface.CheckCycle++;
TouchSurface.TouchCycle++;
if((abs(x2-x1) < TP_ERR_RANGE) && (abs(y2-y1) < TP_ERR_RANGE))
{
// sampling error <= +- TP_ERR_RANGE
if (TouchSurface.CheckCycle >= TP_DEBOUNCE_CYCLE)
{
if(TOUCH_PANEL_NONE_EVENT == TouchSurface.Event){
TouchSurface.origin_x_pos = (x1+x2)/2;
TouchSurface.origin_y_pos = (y1+y2)/2;
TouchSurface.Event = TOUCH_PANEL_PRESS_EVENT;
}
TouchSurface.CheckCycle = TP_DEBOUNCE_CYCLE;
}
TouchSurface.end_x_pos = x2;
TouchSurface.end_y_pos = y2;
}
else
{
if(TOUCH_PANEL_PRESS_EVENT == TouchSurface.Event || TOUCH_PANEL_MOVE_EVENT == TouchSurface.Event)
{
TouchSurface.Event = TOUCH_PANEL_MOVE_EVENT;
}else{
TouchSurface.Event = TOUCH_PANEL_NONE_EVENT;
TouchSurface.origin_x_pos = 0x00;
TouchSurface.origin_y_pos = 0x00;
}
TouchSurface.end_x_pos = x2;
TouchSurface.end_y_pos = y2;
}
}
else
{
x1 = TouchSurface.origin_x_pos; y1 = TouchSurface.origin_y_pos;
x2 = TouchSurface.end_x_pos; y2 = TouchSurface.end_y_pos;
if(TOUCH_PANEL_MOVE_EVENT == TouchSurface.Event)
{
if((abs(x2-x1) < TP_ERR_RANGE) && (abs(y2-y1) < TP_ERR_RANGE))
{
TouchSurface.Event = TOUCH_PANEL_RES_EVENT;
}else{
TouchSurface.Event = TOUCH_PANEL_MOVE_EVENT;
TouchSlideEvent.Direction = GetSlide_Direction(x1, y1, x2, y2);
if(TouchSlideEvent.Direction != TP_SlideDirection_NONE){
TouchSlideEvent.keep_cycle = SLIDE_CAN_EVENT_KEEP_CYCLE;
TouchSlideEvent.Event = TRUE;
}
}
}
else if(TOUCH_PANEL_PRESS_EVENT == TouchSurface.Event)
{
//do nothing
}
else
{
TouchSurface.Event = TOUCH_PANEL_NONE_EVENT;
}
TouchSurface.end_x_pos = 0x00;
TouchSurface.end_y_pos = 0x00;
TouchSurface.CheckCycle = 0x00;
TouchSurface.origin_x_pos = 0x00;
TouchSurface.origin_y_pos = 0x00;
TouchSurface.x_position = 0;
TouchSurface.y_position = 0;
TouchSurface.TouchCycle = 0;
Surface_Convert.convert_x = 0x00;
Surface_Convert.convert_y = 0x00;
touchEnd_flag = 0x01;
}
if(TouchSurface.TouchCycle >= TP_RUNNING_ERROR_CYCLE){
TouchSurface.TouchCycle = TP_RUNNING_ERROR_CYCLE;
TouchSurface.Event = TOUCH_PANEL_BERR_EVENT;
}
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
}
switch(CurrentPosition)
{
case 1:{
Buttons_Signal[BTN_RESUME1] = TouchButton_BntCheck(BTN_RESUME1);
if(Buttons_Signal[BTN_RESUME1] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 2:{
Buttons_Signal[BTN_ADAS1] = TouchButton_BntCheck(BTN_ADAS1);
if(Buttons_Signal[BTN_ADAS1] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 3:{
Buttons_Signal[BTN_CANCEL1] = TouchButton_BntCheck(BTN_CANCEL1);
if(Buttons_Signal[BTN_CANCEL1] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 4:{
Buttons_Signal[BTN_UP] = TouchSurface_BntCheck(BTN_UP, 1);
if(Buttons_Signal[BTN_UP] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 5:{
Buttons_Signal[BTN_DOWN] = TouchSurface_BntCheck(BTN_DOWN, 1);
if(Buttons_Signal[BTN_DOWN] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 6:{
Buttons_Signal[BTN_LEFT] = TouchSurface_BntCheck(BTN_LEFT, 1);
if(Buttons_Signal[BTN_LEFT] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 7:{
Buttons_Signal[BTN_RIGHT] = TouchSurface_BntCheck(BTN_RIGHT, 1);
if(Buttons_Signal[BTN_RIGHT] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
case 8:{
Buttons_Signal[BTN_CONFIRM] = TouchSurface_BntCheck(BTN_CONFIRM, 1);
if(Buttons_Signal[BTN_CONFIRM] >= BUTTON_TOUCH)
{
break;
}else
{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
}
break;
}
default:{
for(index = 0; index< BTN_MAX_CH_NUM; index++)
{
if(index< (BTN_MAX_CH_NUM - 5U)){
Buttons_Signal[index] = TouchButton_BntCheck(index);
}else{
Buttons_Signal[index] = TouchSurface_BntCheck(index, 1);
}
if(Buttons_Signal[index] < BUTTON_TOUCH)
{
count++;
}
}
break;
}
}
if(count == BTN_MAX_CH_NUM)
{
CurrentPosition = 0xff;
//Allow_Touch_flag=1;
}
if(touchEnd_flag != 0x00){
TouchSurface.Event = TOUCH_PANEL_NONE_EVENT;
}
touch_test();
measurement_done_touch = 0;
}
if(TouchSlideEvent.Event == TRUE)
{
if(TouchSlideEvent.keep_cycle != 0x00){
TouchSlideEvent.keep_cycle--;
}
if(TouchSlideEvent.keep_cycle == 0x00){
TouchSlideEvent.Direction = TP_SlideDirection_NONE;
TouchSlideEvent.Event = FALSE;
}
}
if(TouchSurface.Event == TOUCH_PANEL_BERR_EVENT)
{
TouchSurface.Event = TOUCH_PANEL_NONE_EVENT;
}
if (threshold_select_adas == 1)
{
K_Vibra_Trig_adas=1;
}
else
{
K_Vibra_Trig_adas=0;
}
if (threshold_select_cancel == 1)
{
K_Vibra_Trig_cancel=1;
}
else
{
K_Vibra_Trig_cancel=0;
}
if (threshold_select_resume == 1)
{
K_Vibra_Trig_resume=1;
}
else
{
K_Vibra_Trig_resume=0;
}
if(Vibra_force_level == 2 && last_Vibra_force_level != 2
&&Allow_Touch_flag)//((Two_Finger_Y_count<=4 && Y_count == Two_Finger_Y_count)&&(Two_Finger_X_count<=4 && X_count == Two_Finger_X_count))
{
Over3N_vibra_req = 1;
Below1P5N_vibra_req = 0;
}
else if(Vibra_force_level == 0 && last_Vibra_force_level != 0)
{
Below1P5N_vibra_req = 1;
Over3N_vibra_req = 0;
}
last_Vibra_force_level=Vibra_force_level;
if((K_Vibra_Trig_pad==1||K_Vibra_Trig_adas==1||K_Vibra_Trig_cancel==1||K_Vibra_Trig_resume==1)&&Vibra_force_level==2&&Allow_Touch_flag==1)
{
Reach2_flag=1;
}
//add by kailong
//Vibra_force_level=Vibra_PressCheck();
if((K_Vibra_Trig_pad==1||K_Vibra_Trig_adas==1||K_Vibra_Trig_cancel==1||K_Vibra_Trig_resume==1)&&Over3N_vibra_req == 1&&Allow_Touch_flag==1)
{
Touch_Flag = TOUCH_KET_ON;
speeker_Tig_Once(49, UDS_Vibration_Gain);
Over3N_vibra_req = 0;
}
else if(Below1P5N_vibra_req ==1&&Reach2_flag==1)
{
if(TOUCH_KET_ON == Touch_Flag)
{
Touch_Flag = TOUCH_KET_OFF;
speeker_Tig_Once(49, UDS_Vibration_Gain);
}
Below1P5N_vibra_req = 0;
Reach2_flag = 0;
}
if (CurrentPosition == 0xff)
{
Allow_Touch_flag=1;
}
}