Ejemplo n.º 1
0
Archivo: elo.c Proyecto: ysei/uclinux-2
// Reset the touch-screen interface.
//
static int elo_reset_touch(int fd)
{
  fd_set set;
  struct timeval timeout={0, 100000};  /* 0.1 seconds */
  unsigned char packet[8];

  /* Send reset command */
  memset(packet, 0, 8);
  packet[0]='R';
  packet[1]=1;    /* 0=Hard reset, 1=Soft */
  elo_putbuf(fd, packet);

  /* Wait for response */
  FD_ZERO(&set);
  FD_SET(fd, &set);
  if(!select(fd+1, &set, NULL, NULL, &timeout))
    return -1;  /* no communications */

  if(!elo_check_ack(fd))
    return -1;  /* no valid packet received */

  /* Set the proper mode of operation:
      Initial Touch, Range Checking, Calibration, Scaling, and Trim. */

  elo_set_mode(fd,ELO_M_INITIAL|ELO_M_UNTOUCH|ELO_M_RANGECK,
                  ELO_M_CALIB|ELO_M_SCALE|ELO_M_TRIM);

  /* Set scaling to 80 x 25 */
  elo_set_scale(fd, 'X', elo_MINX, elo_SCREENWIDTH-1);
  elo_set_scale(fd, 'Y', elo_MINY, elo_SCREENHEIGHT-1);

  return 0;
}
Ejemplo n.º 2
0
Archivo: elo.c Proyecto: ysei/uclinux-2
// Set scaling info to touch device. Axis can be either 'X', 'Y', or 'Z'.
//
static int elo_set_scale(int fd, unsigned char axis, short low, short high)
{
  unsigned char packet[8], *ptr;

  if(axis < 'X' || axis > 'Z')
    return -1;

  memset(packet, 0, 8);
  packet[0]='S';
  packet[1]=axis;
  packet[2]=low;
  packet[3]=low >> 8;
  packet[4]=high;
  packet[5]=high >> 8;

  /* send packet until proper ack is received */
  while(1) {
    elo_putbuf(fd, packet);

    if(!(ptr=elo_getbuf(fd)))
      return -2;
    if(!strncmp("A0000", (char*)ptr, 5))
      return 0;
  }
}
Ejemplo n.º 3
0
// Reset the touch-screen interface.
//
static int elo_reset_touch(int fd)
{
  unsigned char packet[8];

  /* Send reset command */
  memset(packet, 0, 8);
  packet[0]='R';
  packet[1]=1;    /* 0=Hard reset, 1=Soft */
  elo_putbuf(fd, packet);

  /* Wait for response */
  if(!elo_check_ack(fd))
    return -1;  /* no valid packet received */

  /* Set the proper mode of operation:
      Initial Touch, Range Checking, Calibration, Scaling, and Trim. */

  elo_set_mode(fd,ELO_M_INITIAL|ELO_M_UNTOUCH|ELO_M_RANGECK,
                  ELO_M_CALIB|ELO_M_SCALE|ELO_M_TRIM);

  /* Set scaling to 80 x 25 */
  elo_set_scale(fd, 'X', elo_MINX, elo_SCREENWIDTH-1);
  elo_set_scale(fd, 'Y', elo_MINY, elo_SCREENHEIGHT-1);

  return 0;
}
Ejemplo n.º 4
0
// Set scaling info to touch device. Axis can be either 'X', 'Y', or 'Z'.
//
static int elo_set_scale(int fd, unsigned char axis, short low, short high)
{
  unsigned char packet[8], *ptr;

  if(axis < 'X' || axis > 'Z')
    return -1;

  memset(packet, 0, 8);
  packet[0]='S';
  packet[1]=axis;
  packet[2]=low;
  packet[3]=low >> 8;
  packet[4]=high;
  packet[5]=high >> 8;

  /* send packet until proper ack is received */
  while(1) {
    elo_putbuf(fd, packet);

    int ret = elo_check_ack(fd);
    if( ret == 1 )      // OK
      return 0;
    if( ret == 0 )      // No receive 
      return -2;
  }
}
Ejemplo n.º 5
0
Archivo: elo.c Proyecto: ysei/uclinux-2
// Set touch screen response packet mode (see #ifdefs in beginning of file).
//
static int elo_set_mode(int fd, unsigned char mode1, unsigned char mode2)
{
  unsigned char packet[8], *ptr;

  /* create packet */
  memset(packet, 0, 8);
  packet[0]='M';
  packet[2]=mode1;
  packet[3]=mode2;

  /* send packet until proper ack is received */
  while(1) {
    elo_putbuf(fd, packet);

    if(!(ptr=elo_getbuf(fd)))
      return -2;
    if(!strncmp("A0000", (char*)ptr, 5))
      return 0;
  }
}
Ejemplo n.º 6
0
// Set touch screen response packet mode (see #ifdefs in beginning of file).
//
static int elo_set_mode(int fd, unsigned char mode1, unsigned char mode2)
{
  unsigned char packet[8];

  /* create packet */
  memset(packet, 0, 8);
  packet[0]='M';
  packet[2]=mode1;
  packet[3]=mode2;

  /* send packet until proper ack is received */
  while(1) {
    elo_putbuf(fd, packet);

    int ret = elo_check_ack(fd);
    if( ret == 1 )      // OK
      return 0;
    if( ret == 0 )      // No receive 
      return -2;
    
  }
}