PIC software documentation
 All Classes Files Functions Variables Enumerations Enumerator Groups
Files | Classes | Macros | Enumerations | Functions
FT5x06 driver

A simple driver for the FT5x06 touch controller using I²C. More...

Files

file  ft5x06.h

Classes

struct  touchCoor
 Information about where the touch occurred on the touch surface and what kind of event it is. More...
struct  touchInfo
 Information about gesture (if recognised) and the registered touch points. More...

Macros

#define FT5X06_I2C_ADDR   0x38
 FT5x06 I²C address.

Enumerations

enum  ft5x06_gesture {
  FT5X06_GESTURE_none = 0x00, FT5X06_GESTURE_up = 0x10, FT5X06_GESTURE_left = 0x14, FT5X06_GESTURE_down = 0x18,
  FT5X06_GESTURE_right = 0x1c, FT5X06_GESTURE_zoomIn = 0x48, FT5X06_GESTURE_zoomOut = 0x49
}
 Types of gestures the FT5x06 can recognise. More...
enum  ft5x06_touchEvent { FT5X06_EVENT_putDown = 0, FT5X06_EVENT_putUp = 1, FT5X06_EVENT_contact = 2, FT5X06_EVENT_invalid = 3 }
 Type of touch event. More...
enum  ft5x06_retrieveTouchInfoRetVal {
  FT5X06_RETTOUCH_OK = 0, FT5X06_RETTOUCH_ERR_I2C_ERROR = 1, FT5X06_RETTOUCH_NULL_ARG = 2, FT5X06_RETTOUCH_ERR_NUM_POINTS = 3,
  FT5X06_RETTOUCH_ERR_EVENT = 4
}
 ft5x06_queryTouchInfo() return values More...

Functions

void ft5x06_queryTouchInfo (int numPoints)
 Query the FT5x06 chip on the I²C bus for touch data.
int ft5x06_retrieveTouchInfo (struct touchInfo *touchInfo)
 Parse touch data from I²C RX buffer.

Detailed Description

A simple driver for the FT5x06 touch controller using I²C.

Author
Andreas Misje
Date
21.02.13

Implementation is based on the I²C driver and requires the user to query for touch data, wait until the I²C driver has finished receiving and then retrieve the data from the I²C RX buffer. Touch data should only be queried when the FT5x06 controller has sent an interrupt.


Class Documentation

struct touchCoor

Information about where the touch occurred on the touch surface and what kind of event it is.

As long as the FT5x06 touch controller is correctly configured, coordinates will be within the defined width and height. Origo is top-left corner. Coordinates are not valid when event is FT5X06_EVENT_putUp. See ft5x06_touchEvent.

Class Members
enum ft5x06_touchEvent event Touch event (see ft5x06_touchEvent )
unsigned int x X coordinate
unsigned int y Y coordinate
struct touchInfo

Information about gesture (if recognised) and the registered touch points.

Note that touch points with the FT5X06_EVENT_putUp event are not included in the numPoints count (see ft5x06_touchEvent).

Class Members
unsigned char gesture Gesture (if any recognised) (see ft5x06_gesture)
unsigned char numPoints Number of touch points registered
struct touchCoor points Array of registered touch points. If numPoints is not 5, the remaining touchCoor objects in the array have undefined values.

Enumeration Type Documentation

Types of gestures the FT5x06 can recognise.

Note
Only FT5X06_GESTURE_zoomIn and FT5X06_GESTURE_zoomOut is known to work. Newhaven has been notified of this, but they could not explain why this is so.
Enumerator:
FT5X06_GESTURE_none 

No gestured recognised

FT5X06_GESTURE_up 

Up gesture recognised

FT5X06_GESTURE_left 

Left gesture recognised

FT5X06_GESTURE_down 

Down gesture recognised

FT5X06_GESTURE_right 

Right gesture recognised

FT5X06_GESTURE_zoomIn 

Zoom in / expand gesture recognised

FT5X06_GESTURE_zoomOut 

Zoom out / pinch gesture recognised

ft5x06_queryTouchInfo() return values

Enumerator:
FT5X06_RETTOUCH_OK 

Everything went fine

FT5X06_RETTOUCH_ERR_I2C_ERROR 

An I²C error occurred. Check i2c_error for more information about the error

FT5X06_RETTOUCH_NULL_ARG 

touchInfo was NULL

FT5X06_RETTOUCH_ERR_NUM_POINTS 

The number of points reported from the I²C data was incorrect. This may indicate corrupt I²C data or a bug.

FT5X06_RETTOUCH_ERR_EVENT 

This is guaranteed to be a bug

Type of touch event.

Enumerator:
FT5X06_EVENT_putDown 

The finger was put down on the touch surface

FT5X06_EVENT_putUp 

The finger was lifted from the touch surface.

The touch coordinates are not valid for touch data with this event. Touch points with this event is not included in the number of points counter.

FT5X06_EVENT_contact 

The finger is still in contact with the touch surface

FT5X06_EVENT_invalid 

This event is reserved and should be treated as an invalid event

Function Documentation

void ft5x06_queryTouchInfo ( int  numPoints)

Query the FT5x06 chip on the I²C bus for touch data.

The I²C driver must be initialised and idle.

Parameters
numPointsnumber of touch points to query
int ft5x06_retrieveTouchInfo ( struct touchInfo touchInfo)

Parse touch data from I²C RX buffer.

Events will stored for all points queried by ft5x06_queryTouchInfo(), but coordinates will only be stored for active points. The I²Cdriver" must be initialised and idle.

Parameters
touchInfoobject to populate
Returns
ft5x06_retrieveTouchInfoRetVal