Touchkit Software Programming Guide
Touchkit Software Programming Guide
Version 1.2
www.densitron.com
10400-4 Pioneer Blvd. Santa Fe Springs, Ca 90670
TEL: (562) 941-5000 ext. 252 FAX: (562) 941-5757
CONTENTS
1. Introduction.Pg.3 2. Programming Guide of Using Touch Kit Controller Board ......Pg.4
2.1 Packets Format...Pg.4
2.1.1 Diagnostics Packet....Pg.4 2.1.2 Report Packet ..........Pg.5
2.2.2 PS/2 Interface ..Pg.5 2.2.3 USB Interface .....................Pg.6 2.2.4 IIC Interface ....Pg.7
2.3 Packet Parser Sample Code .......Pg.8 2.4 2 Points Calibration for Position Decoding .......Pg.11
www.densitron.com
Pg. 02
1. Introduction
Densitron provides a full range of controllers designed to optimize the performance of analog resistive touch panels. The controller communicates with the PC system directly through RS232, PS/2, USB port and even IC. In recent years, portable devices become popular, and IC transaction is the best way to communicate withthese portable devices, like PDA, eBook, Mira, etc. Densitrons superior design combines accuracy, sensitivity and speed to reach the outstanding touch performance and ease of use. The drivers emulate the mouse input and right button function, and support a variety of operation systems, including DOS, Windows 98, Windows NT4, Windows 2000, Windows Me, Windows XP, Windows CE.net, iMac, Linux RedHat and Mandrake Linux. However some special designs, our honor customers have to develop their own programs communicating with the touch panel controller firmware directly. The data command packet structure will be described in chapter 1. Then special notices of programming RS232, PS/2, USB port and IC are expressed. At the end, the sample code of parsing the packet from controller and the two points calibration/ alignment conversion formulas are listed. And some OEM customers need to use their own logos and brand names instead of that of Densitron. Therefore chapter 2 of this application note is designed to fit our honor to customers needs on Windows OS.
www.densitron.com
Pg. 03
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 1 D Response The response is an ASCII string, such as 0.99 3. Get type This packet is to request the controller type. The possible responses are 4 wire or wire. Host Issues 0x0A 1 E Controller firmware responds 0x0A Length E Response
www.densitron.com
Pg. 04
0 A8 A1 B8 B1
Status: indicates the touch status: 1 for touch down and 0 for touch up. A10 - A0: 11 bits of 1st direction raw data. B10 - B0: 11 bits of 2nd direction raw data. Please be aware that A and B just represent 2 resolution directions of the touch panel.
www.densitron.com
Pg. 05
www.densitron.com
Pg. 06
2.2.3 IC Interface
Baud rate: less than 12.5 kbps. IC transaction packages: (Packet) = bytes of transfer + Payload where the payload is packet for touch screen feature. Default address: 04 Software needs to reassemble the payload as the Touch Kit packet.
IC Timing:
www.densitron.com
Pg. 07
www.densitron.com
Pg. 08
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;
10400-4 Pioneer Blvd. Santa Fe Springs, CA 90670 TEL: (562) 941-5000 ext. 252 FAX: (562) 941-5757
www.densitron.com
Pg. 09
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; } } } } }
www.densitron.com
Pg. 10
1. 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 2. During calibration, press on these two target points, the raw data are obtained as: LL and UR; LL = (LLX, LLY); UR = (URX , URY) 3. 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:
www.densitron.com
Pg. 11