This library is useful if you would like to easily get started with a prototype, understand how to communicate with the sensor using I2C or if you would like to see how the library has implemented the communication.
The library offers an easy way to communicate with the sensor as well as some primitive parsing of the ASN.1 serialized messages. This makes it easy for the end user to get x and y coordinates from touch notifications or set different settings such as the correct touch active area. The library does not have support for all messages available in the ASN.1 protocol, however the I2C read and write functions are public and can be used if any setting or request not supported by the library needs to be sent/read from the sensor.
This library is distributed under the GNU LGPL v2.1 open source license and is available on https://github.com/neonode-inc/zforce-arduino along with additional documentation as well as a full example program. For questions regarding how to use the library, please refer to our helpcenter.
How to use the library
The library is built around using zforce.GetMessage() as the main loop for reading messages from the sensor. GetMessage checks if the data ready pin is high and if it is, the function zforce.Read() will be called. The read function takes a buffer parameter which is used to store the data from the sensor.
When GetMessage has been called it is up to the end user to destroy the message by calling zforce.DestroyMessage() and passing the message pointer as a parameter.
Send and Read Messages
The library has support for some basic settings in the sensor, for example zforce.SetTouchActiveArea(). When writing a message to the sensor the end user has to make sure that data ready is not high before writing. This is done by calling GetMessage and reading whatever might be in the I2C buffer.
When a message has been sent, the sensor always creates a response that has to be read by the host. It could take some time for the sensor to create the response and put it on the I2C buffer, which is why it is recommended to call the GetMessage function in a do while loop.