精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>嵌入式开发>>外设接口:屏幕、串口、并口等>>触摸屏>>Re:顶一下人气。(2)

主题:Re:顶一下人气。(2)
发信人: yexunkai(叶云)
整理人: wenbobo(2003-09-19 09:19:39), 站内信件
头定义




#ifndef ELO_TOUCH_H
#define ELO_TOUCH_H

/*
 ***************************************************************************
 *
 * Default constants.
 *
 ***************************************************************************
*/
#define ELO_MAX_TRIALS 3 /* Number of timeouts waiting for a */
/* pending reply. */
#define ELO_MAX_WAIT 100000 /* Max wait time for a reply (microsec)*/
#define ELO_UNTOUCH_DELAY 5 /* 100 ms */
#define ELO_REPORT_DELAY 1 /* 40 ms or 25 motion reports/s */
#define ELO_LINK_SPEED B9600 /* 9600 Bauds */
#define ELO_PORT "/dev/ttyS3"

#define ELO_DEFAULT_MAX_X 3000
#define ELO_DEFAULT_MIN_X 600
#define ELO_DEFAULT_MAX_Y 3000
#define ELO_DEFAULT_MIN_Y 600

#define ELO_DEVICE_INIT 0
#define ELO_DEVICE_ON 1
#define ELO_DEVICE_OFF 2
#define ELO_DEVICE_CLOSE 3

#define ELO_PACKET_SIZE 10

#define ELO_SYNC_BYTE 'U' /* Sync byte. First of a packet.*/
#define ELO_TOUCH 'T' /* Report of touchs and motions. Not*/
/* used by 2310. */
#define ELO_OWNER 'O' /* Report vendor name. */
#define ELO_ID 'I' /* Report of type and features. */
#define ELO_MODE 'M' /* Set current operating mode. */
#define ELO_PARAMETER 'P' /* Set the serial parameters. */
#define ELO_REPORT 'B' /* Set touch reports timings. */
#define ELO_ACK 'A' /* Acknowledge packet */

#define ELO_INIT_CHECKSUM 0xAA /* Initial value of checksum. */

#define ELO_PRESS 0x01 /* Flags in ELO_TOUCH status byte */
#define ELO_STREAM 0x02
#define ELO_RELEASE 0x04

#define ELO_TOUCH_MODE 0x01 /* Flags in ELO_MODE command */
#define ELO_STREAM_MODE 0x02
#define ELO_UNTOUCH_MODE 0x04
#define ELO_RANGE_CHECK_MODE 0x40
#define ELO_TRIM_MODE 0x02
#define ELO_CALIB_MODE 0x04
#define ELO_SCALING_MODE 0x08
#define ELO_TRACKING_MODE 0x40

#define ELO_SERIAL_SPEED 0x06 /* Flags for high speed serial (19200)*/
#define ELO_SERIAL_MASK 0xF8

#define ELO_SERIAL_IO '0' /*Indicator byte for PARAMETER command*/


/*
 ***************************************************************************
 *
 * Device private records.
 *
 ***************************************************************************
*/
typedef struct _EloPrivateRec {
  char *input_dev; /* The touchscreen input tty            */
  int min_x; /* Minimum x reported by calibration */
  int max_x; /* Maximum x                         */
  int min_y; /* Minimum y reported by calibration */
  int max_y; /* Maximum y */
  int untouch_delay; /* Delay before reporting an untouch (in ms) */
  int report_delay; /* Delay between touch report packets */
  int link_speed; /* Speed of the RS232 link connecting the ts. */
  int screen_no; /* Screen associated with the device */
  int screen_width; /* Width of the associated X screen */
  int screen_height; /* Height of the screen */
  int inited; /* The controller has already been configured ? */
  int is_a_2310; /* Set if the smartset is a 2310. */
  int checksum; /* Current checksum of data in assembly buffer */
  int packet_buf_p; /* Assembly buffer pointer */
  int swap_axes; /* Swap X an Y axes if != 0 */
  unsigned char packet_buf[ELO_PACKET_SIZE]; /* Assembly buffer */
} EloPrivateRec;


/*
 ***************************************************************************
 *
 * Prototypes
 *
 ***************************************************************************
*/
void EloInit( EloPrivateRec *priv );
void EloAllocate( EloPrivateRec *priv );
int EloGetPacket( unsigned char *buffer, int *buffer_p, int *checksum, int fd );
void EloReadInput( EloPrivateRec *priv, int fd, int *nX, int *nY, int *nState );
int EloSendPacket( unsigned char *packet, int fd );
int WaitForInput( int fd, int timeout );
int EloWaitReply( unsigned char type, unsigned char *reply, int fd );
int EloWaitAck( int fd );
int EloSendQuery( unsigned char *request, unsigned char *reply, int fd );
int EloSendControl( unsigned char *control, int fd );
int EloControl( EloPrivateRec *priv, int *fd, int mode );

#endif // ELO_TOUCH_H



----
有兴趣请直接寄信
在下上线时间不定,
回应帖子也比较慢。

[关闭][返回]