The Touch Sensor Module communicates with messages that are serialized according to the zForce serialization protocol. Here is a quick introduction to the messages you need to send to get started and also how you interpret received messages.
ASN.1 encoded integers, for example values representing scanning frequency or touch active area size, are represented by one or more bytes:
- If the integer is between 0 and 127, it is represented by one byte (
- If the integer is between 128 and 32767, it is represented by two bytes (
The length of the message therefore varies depending on parameter values.
Enabling Touch Sensor Modules
Do the following to enable a Touch Sensor Module, that is, tell the module to start sending touch notifications.
Enable the sensor module by sending a request with an Enable command:
This enables the sensor module to send touch notifications.
Read the response. The response should be:
The Touch Sensor Module is now Enabled. After this, wait for the sensor module to indicate it has something to send, which means that the device will send a Touch Notification or a BootComplete. A BootComplete indicates that the device has restarted for some reason, so rerun the initialization and enable the sensor module to start receiving touch notifications again.
Disabling Touch Sensor Modules
Do the following to disable a Touch Sensor Module, that is, tell the module to stop sending touch notifications.
Disable the sensor module by sending a request with the following command:
This disables the sensor module to send touch notifications.
Read the response. The response should be:
- The Touch Sensor Module is now Disabled.
Device configuration is a command that includes different settings for the sensor module, for example the Touch Active Area. When sending a device configuration message, all of the settings specified are not required to be sent, however the response from the sensor module will include the full device configuration message.
This is an example message that changes the touch active area using the Device Configuration command:
The message is explained in the table below:
|ID for request followed by length of total payload (0x1A = 26 bytes)|
|Device address (always the same for Neonode Touch Sensor Modules)|
|ID for Device Configuration followed by the length of the total Device Configuration payload (20 bytes)|
|ID for Sub Touch Active Area followed by the length of Sub Touch Active Area payload|
|ID for xMin followed by payload length and an integer value (0x00B5 = 181)|
ID for yMin followed by payload length and an integer value (0x43 = 67)
ID for xMax followed by payload length and an integer value (0x0698 = 1688)
|ID for yMax followed by payload length and an integer value (0x0434 = 1076)|
|ID for "Invert y axis" followed by length of payload and a Boolean (0xFF= True)|
The response from the sensor module to the above message will contain the full device configuration message, also the parts not set in the request.
Setting the Touch Active Area should be done before enabling the sensor module with the ENABLE request.
Reflective Edge Filter
In the Device Configuration command there is something called Reflective Edge filter (from firmware version 1.45 and later). This setting is useful if there is a highly reflective material, right outside of the Touch Active Area. If such conditions are present, enabling this feature could increase the touch performance.
To set the finger frequency to 200 Hz and idle frequency to 63 Hz use a request with the following command:
Neonode Touch Sensor Module does not support Stylus mode, and setting the stylus frequency does not do anything.
Decoding Touch Notifications
A packet can contain from one up to 10 touches, and optionally a timestamp. On packets where the timestamp is not included, the 58 02 TT TT bytes are missing from the end and the length bytes are adjusted accordingly, For One touch (below), F0 15 in the beginning will be F0 11 and A0 0F in the middle will be A0 0B. The same bytes are decreased by 4 for Two and Three touches.
A packet that contains one touch will look like:
where the data is defined as follows:
ID of this specific touch object. More than one can be tracked simultaneously.
00 = DOWN (new object). 01 = MOVE (existing object has moved). 02 = UP (existing object is no longer being tracked).
|XX XX||X Coordinate of the object. This is in Network Byte Order / Big Endian / Motorola Endian.|
|YY YY||Y Coordinate of the object. See above.|
|GG GG||Size of object on the X Axis.|
|JJ||This value should be ignored.|
|TT TT||Timestamp of the touch.|
A packet that contains two Touches will look like:
where the first "II" and the following bytes up to and including "JJ" are from the first touch, and the second "II" and the following bytes up to and including "JJ" are from the second touch.
A packet that contains three Touches will look like:
For a more thorough explanation of the serialization protocol, refer to Understanding the zForce ASN.1 Serialization Protocol.
Read More about the Communication Protocol
- Serialization Protocol Quick Start
- USB HID Transport
- I2C Transport
- zForce Message Specification
- Understanding the zForce ASN.1 Serialization Protocol