/*********************************************************************
*
*       GUI_TOUCH_Exec
*/
void GUI_TOUCH_Exec(void) {
#ifndef WIN32
  static U8 ReadState;
  int x,y;
  /* calculate Min / Max values */
  if (xyMinMax[GUI_COORD_X].Min < xyMinMax[GUI_COORD_X].Max) {
    xMin = xyMinMax[GUI_COORD_X].Min;
    xMax = xyMinMax[GUI_COORD_X].Max;
  } else {
    xMax = xyMinMax[GUI_COORD_X].Min;
    xMin = xyMinMax[GUI_COORD_X].Max;
  }
  if (xyMinMax[GUI_COORD_Y].Min < xyMinMax[GUI_COORD_Y].Max) {
    yMin = xyMinMax[GUI_COORD_Y].Min;
    yMax = xyMinMax[GUI_COORD_Y].Max;
  } else {
    yMax = xyMinMax[GUI_COORD_Y].Min;
    yMin = xyMinMax[GUI_COORD_Y].Max;
  }
  /* Execute the state machine which reads the touch */
  switch (ReadState) {
  case 0:
    yPhys = TOUCH_X_MeasureY();
    TOUCH_X_ActivateY();  /* Prepare X- measurement */
    ReadState++;
    break;
  default:
    xPhys = TOUCH_X_MeasureX();
    TOUCH_X_ActivateX();  /* Prepare Y- measurement */
    /* Convert values into logical values */
    #if !GUI_TOUCH_SWAP_XY   /* Is X/Y swapped ? */
      x = xPhys;
      y = yPhys;
    #else
      x = yPhys;
      y = xPhys;
    #endif
    if ((x < xMin) || (x > xMax)  || (y < yMin) || (y > yMax)) {
      _StoreUnstable(-1, -1);
    } else {
#if 0
      x = _AD2X(x);
      y = _AD2Y(y);
#endif
	 
	 myAD2XY( &x ,&y );
     _StoreUnstable(x, y);
    }
    /* Reset state machine */
    ReadState = 0;
    break;
  }
  #endif /* WIN32 */
}
示例#2
0
void GUI_TOUCH_Exec(void)
{
    int x,y;
    // calculate Min / Max values 
    if (xyMinMax[0].Min < xyMinMax[0].Max)
    {
        xMin = xyMinMax[0].Min;
        xMax = xyMinMax[0].Max;
    }
    else
    {
        xMax = xyMinMax[0].Min;
        xMin = xyMinMax[0].Max;
    }
    if (xyMinMax[1].Min < xyMinMax[1].Max)
    {
        yMin = xyMinMax[1].Min;
        yMax = xyMinMax[1].Max;
    }
    else
    {
        yMax = xyMinMax[1].Min;
        yMin = xyMinMax[1].Max;
    }
		//参数合法性检测
		if((gpCHGUI->tops->ctrl_get_touch_x == NULL) || (gpCHGUI->tops->ctrl_get_touch_y == NULL))
		{
			return;
		}
    xPhys = gpCHGUI->tops->ctrl_get_touch_x();
    yPhys = gpCHGUI->tops->ctrl_get_touch_y();
    // Convert values into logical values 
    #if !GUI_TOUCH_SWAP_XY   // Is X/Y swapped ?
      x = xPhys;
      y = yPhys;
    #else
      x = yPhys;
      y = xPhys;
    #endif
    if ((x < xMin) || (x > xMax)  || (y < yMin) || (y > yMax)) 
    {
			GUI_TOUCH_StoreState(-1, -1);
    }
    else 
    {
        x = _AD2X(x);
        y = _AD2Y(y);
			GUI_TOUCH_StoreState(x, y);
    }
}