⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 touch_panel.c

📁 MTK6225
💻 C
📖 第 1 页 / 共 5 页
字号:
*
*************************************************************************/
extern kal_uint16      TP_I2C_X;
extern kal_uint16      TP_I2C_Y;

kal_uint8   UP_states=0;

void touch_panel_up_hdr(void)
{
   /*check if the down point is reasonable*/
   if(TP.wait_next_down==KAL_TRUE)
      return;
 
	  
   /*reset temp coordinate*/
   TP.temp.x=0;
   TP.temp.y=0;
   /*stop polling*/    
 //  kal_print("touch_panel_up_hdr");
// kal_print("TP UP.....");
  // GPIO_WriteIO(0, 5);

   
   GPTI_StopItem(touch_panel_handle);
   GPTI_StopItem(touch_panel_repeat_handle);
   if(TP.skip_unrelease_state==KAL_FALSE)
   {   
      
	   if(TP.area==NON_HAND_WRITING)
	   {    
	         tp_data_pop(PEN_UP, TP.pre.x, TP.pre.y);
	   }   
	   else
	   {      
	         tp_data_pop(STROKE_UP, TP.pre.x, TP.pre.y);
	    }   
   }
   else/*TP.skip_unrelease_state==KAL_TRUE*/
      TP.skip_unrelease_state=KAL_FALSE;   
   
   UP_states=1; 
 touch_panel_state =0; //qsh
EINT_Set_Polarity(TP.eint_chan,touch_panel_state);//qsh
   
}   
/*************************************************************************
* FUNCTION
*	touch_panel_down_hdr
*
* DESCRIPTION
*	This function is to handle down event.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void touch_panel_down_hdr(void)
{


   kal_int16  x, y;
   kal_uint16 i;
   kal_bool valid=KAL_FALSE;
   char str[100];


   
   TP.skip_unrelease_state=KAL_FALSE;
 //  touch_panel_read_adc(&x, &y);//采样值
 // Cap_i2c_read_All_data();//qsh
i2c_tp_ReadAllData();//qsh 04-15;
 x = TP_I2C_X;//qsh
 y = TP_I2C_Y;//qsh
   touch_excute_cali(x,y);//校准
/*
sprintf(str,"zoom=%d,flick=%d,press=%d",tp_zoom,tp_flick,tp_press);
kal_print(str);
*/ 


   valid=touch_panel_adc_to_coordinate(&x,&y);/*tranlate,调整*/            
   if(valid==KAL_TRUE)
   {
   TP.pre.x=x; 
   TP.pre.y=y;
      TP.begin.x=x; 
      TP.begin.y=y;
      TP.wait_next_down=KAL_FALSE;
   }
   else
   {
  
   	TP.wait_next_down=KAL_TRUE;
   	return;
   }		
   TP.temp.x=0;
   TP.temp.y=0;
   if(TP.ext_enable==KAL_FALSE)/*not extend handwriting area*/
   {
      for(i=0;i<TP.hand_num;i++)
      {
         if((x>=TP.handarea[i].min.x)&&(y>=TP.handarea[i].min.y)&&
         (x<=TP.handarea[i].max.x)&&(y<=TP.handarea[i].max.y))
         {
            TP.area=HAND_WRITING;
            /*check if ext_handwriting exists?*/
            if((TP.ext_handarea.min.x!=TP.ext_handarea.max.x)&&
               (TP.ext_handarea.min.y!=TP.ext_handarea.max.y))
            {
               TP.ext_enable=KAL_TRUE;/*use extended handwriting area*/
            }   
            break;   
         }
         else/*non-handwriting*/
         {
            TP.area=NON_HAND_WRITING;                  
         }                  
      }      
   }         
   else/*extend handwriting area*/
   {
      if((x>=TP.ext_handarea.min.x)&&(y>=TP.ext_handarea.min.y)&&
         (x<=TP.ext_handarea.max.x)&&(y<=TP.ext_handarea.max.y))
      {
         TP.area=HAND_WRITING;         
      }
      else/*non-handwriting*/
      {
         TP.area=NON_HAND_WRITING;                  
      }
   }   


/*

if(tp_zoom)   //new
{
kal_print("qsh test tp_zoom");
 tp_data_pop(CAP_ZOOM, x, y);//new    
} //new
   */
   if(TP.area==HAND_WRITING)            
   {    
      tp_data_pop(STROKE_DOWN, x, y);     

	  if((!(finger_num))&&(!(tp_tapcode))) //qsh 04-15
	  	{
        touch_panel_up_hdr();////qsh 04-15
       return;
	 	}
      touch_panel_stroke_hdr(); //启动STROKE_MOVE定时器
      touch_start_handwriting_longtap();      //启动stroke_longtat EPN_LONGTAP定时器
   }
   else/*non-handwriting*/
   {           
  
     // sprintf(str,"PEN_DOWN x=%d,y=%d",x,y);
   //   kal_print(str);
      tp_data_pop(PEN_DOWN, x, y);       

	  if((!(finger_num))&&(!(tp_tapcode))) //qsh 04-15
	  	{
          touch_panel_up_hdr();////qsh 04-15
         return;
	  	}
      touch_panel_event_hdr();//启动PEN_MOVE定时器
      touch_start_longtap(); //启动stroke_longtat EPN_LONGTAP定时器
   }   


//if((!(finger_num))&&(!(tp_tapcode))) //qsh 04-15
//touch_panel_up_hdr();////qsh 04-15

} 
/*************************************************************************
* FUNCTION
*	touch_panel_sendilm
*
* DESCRIPTION
*	This function is to send touch event indication to upper layer.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/  
/*send touch event indication to upper layer*/
void touch_panel_sendilm(void *para, Touch_Panel_Event_enum state)
{
   ilm_struct *tp_ilm;
   module_type owner=0;
   
  // kal_print("touch_panel_sendilm");
   if (send_touch_ilm)
   {
   	#ifdef TOUCH_PANEL_DEBUG
   		owner=MOD_SSDBG1;
   	#else
   		owner=MOD_MMI;
   	#endif


	//yiadd
//	Trace_out("into   touch_panel_sendilm");
	
      send_touch_ilm = KAL_FALSE;
      DRV_BuildPrimitive(tp_ilm,
                         MOD_TP_TASK,
                         owner,
                         MSG_ID_TP_EVENT_IND,
                         NULL);   
      msg_send_ext_queue(tp_ilm);
   }   
}  
/*************************************************************************
* FUNCTION
*	touch_panel_conf_handwriting
*
* DESCRIPTION
*	This function is to configure handwriting area.
*
* PARAMETERS
*	area: handwriting area
*  n: number of handwriting areas
*  ext_area: extended handwriting area
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/ 
void touch_panel_conf_handwriting(TouchPanelHandAreaStruct *area, kal_uint16 n, 
                              TouchPanelHandAreaStruct  *ext_area)
{
   kal_uint32 i;
        // kal_print("touch_panel_conf_handwriting");
   /*n handwriting area*/       
   for(i=0;i<n;i++)
   {      
      TP.handarea[i]=*(area+i);
   }   
   /*extended handwriting area*/
   TP.ext_handarea=*ext_area;
   TP.hand_num=n;
}                                     
/*************************************************************************
* FUNCTION
*	touch_panel_reset_handwriting
*
* DESCRIPTION
*	This function is to reset handwriting area as normal.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/ 
void touch_panel_reset_handwriting(void)                               
{
   kal_uint32 savedMask;

       //     kal_print("touch_panel_reset_handwriting");
   savedMask = SaveAndSetIRQMask();
   /*MMI will reset handwriting area*/
   TP.ext_enable=KAL_FALSE;
   RestoreIRQMask(savedMask);
}                     
/*************************************************************************
* FUNCTION
*	touch_panle_conf_sample_period
*
* DESCRIPTION
*	This function is to configure sample period in handwriting and non-handwriting area.
*
* PARAMETERS
*	low:  sample period in non-handwriting area
*  high: sample period in handwriting area
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/                       
/*configure sample period in non-handwriting and handwriting area*/
void touch_panle_conf_sample_period(kal_uint32 low, kal_uint32 high)
{
      // kal_print("touch_panle_conf_sample_period");
   TP.low_sample_period=low;
   TP.high_sample_period=high;
}   
/*************************************************************************
* FUNCTION
*	touch_panle_conf_timeout_period
*
* DESCRIPTION
*	This function is to configure period of long tap and repeat event.
*
* PARAMETERS
*	long tap: long tap event period
*  repeat:  repeat event period
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/                       
/*configure longtap and repeat period*/
void touch_panle_conf_timeout_period(kal_uint32 longtap, 
                                     kal_uint32 repeat,
                                     kal_uint32 handwriting_longtap)
{

    // kal_print("touch_panle_conf_timeout_period");
   TP.handwriting_longtap_cnt=handwriting_longtap;
   TP.longtap_cnt=longtap;
   TP.repeat_cnt=repeat;
}
/*************************************************************************
* FUNCTION
*	touch_panel_event_hdr
*
* DESCRIPTION
*	This function is to handle down event in non-handwriting area.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/ 
/*start timer in non-handwriting area*/
void touch_panel_event_hdr(void)//启动PEN_MOVE定时器
{
//qsh

   if(TP.low_sample_period!=0)
   {
      GPTI_StartItem(touch_panel_handle,                  
                     TP.low_sample_period,
                     touch_panel_event_cb,
                     NULL);
   }

}  
/*************************************************************************
* FUNCTION
*	touch_start_longtap
*
* DESCRIPTION
*	This function is to long tap timer.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void touch_start_longtap(void) //启动stroke_longtat EPN_LONGTAP定时器
{
//qsh
   if(TP.longtap_cnt!=0)          
   {
      TP.longtap_state=KAL_TRUE;
      GPTI_StartItem(touch_panel_repeat_handle,                  
                     TP.longtap_cnt,
                     touch_panel_longtap_cb,
                     NULL);  
   }

}   
/*************************************************************************
* FUNCTION
*	touch_start_handwriting_longtap
*
* DESCRIPTION
*	This function is to start long tap timer in handwriting area.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void touch_start_handwriting_longtap(void)
{
   if(TP.handwriting_longtap_cnt!=0)          
   {
      TP.longtap_state=KAL_TRUE;
      GPTI_StartItem(touch_panel_repeat_handle,                  
                     TP.handwriting_longtap_cnt,/*stroke long tap*/
                     touch_panel_longtap_cb,
                     NULL);  
   }   
}
/*************************************************************************
* FUNCTION
*	touch_panel_stroke_hdr
*
* DESCRIPTION
*	This function is to handle down event in handwriting area.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void touch_panel_stroke_hdr(void)//启动STROKE_MOVE定时器
{

     if(TP.high_sample_period!=0)
   {
      GPTI_StartItem(touch_panel_handle,                  
                     TP.high_sample_period,
                     touch_panel_stroke_cb,
                     NULL);
   }
 

}                              
/*************************************************************************
* FUNCTION
*	touch_panel_get_event
*
* DESCRIPTION
*	This function is to get event from ring buffer.
*
* PARAMETERS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -