emWIN5 touch problem 触屏问题

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

emWIN5 touch problem 触屏问题

619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xiaobobo2008 on Sun Mar 17 21:02:17 MST 2013
在触摸屏驱动中的程序
static void readAndFilter(int32_t *x, int32_t* y, int32_t* z)
{
  int32_t ix, iy, iz1, iz2 = 0;
  int32_t lastx, lasty, lastz1, lastz2 = 0;
  int i = 0;

  *x = 0;
  *y = 0;
  *z = 0;

  lasty = getFilteredValue(READ_X(0)); //READ_Y(0)交换 X Y
  lasty >>= 3;
  if (lasty >= 4095) {
    lasty = 0;
  }
  _DBG("\r\n lasty data is:");_DBD32(lasty);

  lastx = getFilteredValue(READ_Y(0)); //READ_X(0)
  lastx >>= 3;
  if (lastx >= 4095) {
    lastx = 0;
  }
  _DBG("\r\n lastx data is:");_DBD32(lastx);

  lastz1 = getFilteredValue(READ_Z1(0));
  lastz1 >>= 3;
  _DBG("\r\n lastz1 data is:");_DBD32(lastz1);

  lastz2 = getFilteredValue(READ_Z2(0));
  lastz2 >>= 3;
  _DBG("\r\n lastz2 data is:");_DBD32(lastz2);

  if (lastx && lastz1)
  {
   *z = (lastx * ABS(lastz2 - lastz1)) / lastz1;
  }
  else
  {
   *z = 0;
  }
     
  if (*z > 10500) {
    *z = 0;
  }

  if (*z == 0) {
    return;
  }

  for (i = 0; i < DEBOUNCE_MAX; i++) {
    iy = getFilteredValue(READ_X(0));   // //READ_Y(0)交换 X Y
    iy >>= 3;  

    if (ABS (lasty - iy) <= DEBOUNCE_TOL) {
      break;
    }

    lasty = iy;
  }

  for (i = 0; i < DEBOUNCE_MAX; i++) {
    ix = getFilteredValue(READ_Y(0));   //READ_X(0)交换 X Y
    ix >>= 3;
    if (ix > 4095) {
      ix = 0;
    }  

    if (ABS (lastx - ix) <= DEBOUNCE_TOL) {
      break;
    }

    lastx = ix;
  } 

  for (i = 0; i < DEBOUNCE_MAX; i++) {
    iz1 = getFilteredValue(READ_Z1(0));
    iz1 >>= 3;  

    if (ABS (lastz1 - iz1) <= DEBOUNCE_TOL) {
      break;
    }

    lastz1 = iz1;
  }

  for (i = 0; i < DEBOUNCE_MAX; i++) {
    iz2 = getFilteredValue(READ_Z2(0));
    iz2 >>= 3;  

    if (ABS (lastz2 - iz2) <= DEBOUNCE_TOL) {
      break;
    }

    lastz2 = iz2;
  }
 
  *x = ix;
  *y = iy;
   
  if (ix && iz1) {
   *z = (ix * ABS(iz2 - iz1)) / iz1;
  }
  else {
   *z = 0;
  }

  if (*z > 10500) {
    *z = 0;
  }
         
}

其中以下代码是什么原理啊,
  if (lastx && lastz1)
  {
   *z = (lastx * ABS(lastz2 - lastz1)) / lastz1;
  }
  else
  {
   *z = 0;
  }
  if (*z > 10500) {
    *z = 0;
  }
Labels (1)
0 Kudos
0 Replies