eGalaxTouch Touchscreen
Geändert am So, 19 Jun 2011 23:38 von Administrator — Kategorisiert als: Nicht kategorisiert
Packet Format for eGalaxTouch Touchscreen controller
eGalaxTouch Touchscreen system defines two kinds of packet format for communication between Host and controller device. Both of these two kinds of packet format are valid for all of series of eGalaxTouch touchscreen controllers with RS232, USB, PS2, and I2C interfaces.
Diagnostics Packet
These packets are issued from the host for querying some device information. The controller firmware will report the corresponding data to the host. The packet format is as follows:
0x0A LengthInByte + 1 Command Response
1 Byte 1 Byte 1 Byte LengthInByte
The maximum packet size is 16 bytes. The first byte is Start of Packet as 0X0A. The second byte is the length of Response. The third byte is the issued command and the last part (length is defined in second byte) is the response from controller firmware.
1. Check active : this packet is to check if the device is working properly.
Host issues
0x0A 1 ‘A’
Device responds when active
0x0A 1 ‘A’
2. Get firmware version
Host issues
0x0A 1 ‘D’
Controller firmware responds
0x0A Length ‘D’ Response
The response is an ASCII string, such as ‘0.99’
3. Get type
This packet is to request the controller type.
Host issues
0x0A 1 ‘E’
Controller firmware responds
0x0A Length ‘E’ Response
Report Packet
eGalaxTouch USB HID Touchscreen controllers support Microsoft HID touch digitizer. By default, eGalaxTouch HID compatible controller report with HID format for coordination data according to the HID report descriptor it reported to Host system. In addition, eGalaxTouch serial RS232 controllers support emulation modes.
Serial controller’s report format depends on the format of command sets it receives from Host. By default, it reports with non-emulated packet format as below. To make sure the controllers to report with the below format, the host driver should issue any one of diagnostics packet data to controller. For example, host driver may send a “Check Active”( 0x0A, 1, ‘A’ ) packet data to controller to make it report with below report format.
Each report packet may contain 5 or 6 bytes as below:
Byte0
Byte1
Byte2
Byte3
Byte4
Byte5 MSB LSB
1 Z M 0 0 AD1 AD0 Status 0 A13 A12 A11 A10 A9 A8 A7 0 A6 A5 A4 A3 A2 A1 A0 0 B13 B12 B11 B10 B9 B8 B7 0 B6 B5 B4 B3 B2 B1 B0 0 P6 P5 P4 P3 P2 P1 P0
Byte0: Byte0 is the header of the point packet. It contains below point
Information
Z : pressure bit. eGalaxTouch controller SAW technology may report with
pressure information.
Z=0 means no pressure information
Z=1 means Byte5 is pressure information.
M: Player ID. eGalaxTouch multipler controller report player ID information
M=0 means no player ID information
M=1 means Byte5 is player ID
Status: touch down status.
Status = 1 means touch down
Status = 0 means lift off point
Byte1~Byte4:
AD1,AD0: resolution information of the current point coordination.
AD1:AD0 = 0:0 means the coordination resolution is 11 bits
AD1:AD0 = 0:1 means the coordination resolution is 12 bits
AD1:AD0 = 1:0 means the coordination resolution is 13 bits
AD1:AD0 = 1:1 means the coordination resolution is 14 bits
indicates the touch status: 1 for touch down and 0 for touch up.
A10/A11/A12/A13 – A0: 11/12/13/14 bits of 1st direction raw data
B10/B11/B12/B13 – B0: 11/12/13/14 bits of 2nd direction raw data
Please be aware that A and B just represent 2 resolution directions of the touch panel.
Byte5: Pressure or player ID
The point packet has 6th byte only when Z=1 or M=1. Otherwise, the
point packet has 5 bytes only. If Z=1, this byte is pressure value. If
M=1, this byte is player ID.
Communication Interface
eGalaxTouch provides controllers to communicate with Host devices with RS232, USB, PS2, and I2C interfaces.
RS232 Interface
The RS232 interface controllers communicate with Host device with RS232 protocol definition as below
Baud rate: 9600 bps
Data bits: 8 bit
Stop bit: 1 bit
Parity check: NONE
PS/2 Mouse Interface
eGalaxTouch PS2 controller follows the IBM PS2 mouse specification to communicate with Host device.
USB Interface
eGalaxTouch USB controllers communicate with Host with USB Low speed or Full Speed and “Vendor Specific Class”.
The VID( Vendor ID ) and PID( Product ID ) may be one of
u 1.) VID = 0123, PID=0001
u 2.) VID = 0EEF, PID=0001
u 3.) VID = 0EEF, PID=0002
l Two end points are used:
u Control pipe:
for standard USB PnP and writing packets to controller device controller.
u Interrupt or Bulk IN pipe:
for reading packet from controller device.
l It needs to wait for 3ms at least to issue another write command after one write command is issued
l The polling interval of reading with interrupt pipe is 5 ms
l Control Write Urb format is as follows
/*==================================================================*
/* Vendor specific request Urb format for Touch Panel controller kit */
/* with Win2000 DDK */
/*=====================================================================*/
UsbBuildVendorRequest( pWriteUrb, //IN PURB Urb,
URB_FUNCTION_VENDOR_DEVICE , //IN USHORT Function,
sizeof( struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST ), //IN USHORT Length,
0, //IN ULONG TransferFlags,
0, //IN UCHAR ReservedBits,
0, //IN UCHAR Request,
0, //IN USHORT Value,
0, //IN USHORT Index,
pTxBuffer, //IN PVOID TransferBuffer OPTIONAL,
NULL, //IN PMDL TransferBufferMDL OPTIONAL,
ulBytesToSend, //IN ULONG TransferBufferLength,
NULL //IN PURB Link OPTIONAL,
);
I2C Interface
l Baud rate: less than 12.5 kbps
l I2C transaction package: ( Packet ) = Bytes of transfer + Payload
Where the payload is packet for touch screen feature.
l Default address: 04
l Software needs to reassemble the payload as the eGalaxTouch packet.
Example: Bytes of transaction = N
Packet Parser Sample Code
define MAX_BUFFER 1024
define MOUSE_PACKET_LEN 5
define MAX_CMD_LEN 16
define POLLING_BUFFER_SIZE 3
unsigned __stdcall PortThreadRoutine( LPVOID pContext )
{
CPort *pPort = ( CPort *) pContext;
CHAR pBuffer
MAX_BUFFER
;
CHAR pMsgBuffer
MAX_BUFFER
;
DWORD dwRead = 0;
DWORD dwCnts = 0;
BOOL bPointPacket = FALSE ;
BOOL bCmdPacket = FALSE;
DWORD dwCmdPacketLen;
UCHAR ucChar;
INT i;
while( TRUE )
{
if( WAIT_OBJECT_0 == ::WaitForSingleObject( pPort->m_hStopEvent, 0 ) )
{
return 100;
}
// read packet from COM port or USB port
if ( pPort->Read( pBuffer, POLLING_BUFFER_SIZE, &dwRead, pPort->m_hReadEvent ) )
{ // parse the packet
for( i = 0; i< (INT)dwRead; i++ )
{
ucChar = pBuffer
i
;
if( ( pBuffer
i
& 0xF0 ) == _SYNCBIT ) && !bCmdPacket )
{
dwCnts = 0;
pMsgBuffer
dwCnts
= pBuffer
i
;
bPointPacket = TRUE;
dwCnts++;
continue;
}
else if( _SOP == ucChar && !bPointPacket && !bCmdPacket )
{
bCmdPacket = TRUE;
dwCmdPacketLen = ( DWORD )-1;
bPointPacket = FALSE;
continue;
}
else if( bCmdPacket )
{
if( ( DWORD )-1 == dwCmdPacketLen )
{
dwCmdPacketLen = ( DWORD )pBuffer
i
;
dwCnts = 0;
if( dwCmdPacketLen > MAX_CMD_LEN )
dwCmdPacketLen = MAX_CMD_LEN;
continue;
}
pMsgBuffer
dwCnts
= pBuffer
i
;
dwCnts++;
if( dwCmdPacketLen == dwCnts )
{
dwCmdPacketLen = 0;
pMsgBuffer
dwCnts
= 0;
dwCnts++;
// Here, a completely Cmd packet received !!!
// Do what you want to do!
// For instance,
// pPort->DisPatchMessage( pMsgBuffer, dwCnts );
dwCnts = 0;
bCmdPacket = FALSE;
continue;
}
continue;
}
if( bPointPacket )
{
pMsgBuffer
dwCnts
= pBuffer
i
;
dwCnts++;
if( MOUSE_PACKET_LEN == dwCnts )
{
// Here, a completely point packet received !!!
// Do what you want to do!
// For instance,
//pPort->DisPatchMessage( pMsgBuffer, dwCnts );
dwCnts = 0;
bPointPacket = FALSE;
}
continue;
}
}
}
}
}
2 Points Calibration for Position Decoding
¶
( 0 , 0 ) ADC ( 2047 , 0 ) ADC
( 0 , 2047 ) ADC ( 2047 , 2047 ) ADC
LL and UR are the calibration target points of touch panel, the points are setup at
LL = (1/8 screen X, 1/8 screen Y) = ( 256 , 256 ) ADC ; UR = (7/8 screen X, 7/8 screen Y ) = ( 1791 , 1791 ) ADC
During calibration, press on these two target points, the raw data are obtained as
LL ‘and UR’: LL’ = ( LLX, LLY ) ; UR’ = ( URX, URY )
After the calibration, whenever the panel was touched, firmware report the raw data X and Y. Then, the calibrated position X’ and Y’ are calculated with the formulation as follows: