FT5XX6 Library
This library covers the usage of the FT5x06, FT5x16, FT5x26 and FT5x46 series single-chip capacitive touch panel controllers. They adopt the mutual capacitance approach, which supports true multi-touch capability.
In conjunction with a mutual capacitive touchpanel, the FT5xx6 have user-friendly input functions, which can be applied on many portable devices, such as cellular phones, MIDs, netbook and notebook personal computers.
Important :
- This library uses I²C communication so it is necessary to initialize the I²C module previously.
Library Routines
- FT5XX6_SetI2CAddress
- FT5XX6_WriteRegister
- FT5XX6_ReadRegister
- FT5XX6_GetRunningState
- FT5XX6_IsOperational
- FT5XX6_SetTouchPanelOrientation
- FT5XX6_GetTouchPanelOrientation
- FT5XX6_SetSize
- FT5XX6_SetSizeAndRotation
- FT5XX6_GetRawCoordinates
- FT5XX6_GetCoordinates
- FT5XX6_PressDetect
- FT5XX6_Rotate180
- FT5XX6_SetController
- FT5XX6_GetController
- FT5XX6_SetDefaultMode
- FT5XX6_GetGesture
FT5XX6_SetI2CAddress
| Prototype |
void FT5XX6_SetI2CAddress(unsigned short DeviceAddr) ; |
|---|---|
| Description |
This routine sets the I²C address of the FT5xx6 touch panel. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Nothing. |
| Example |
// Set FT5XX6 device address FT5XX6_SetI2CAddress(0x38); |
| Notes |
|
FT5XX6_WriteRegister
| Prototype |
unsigned short FT5XX6_WriteRegister(unsigned short RegisterAddr, unsigned short RegisterValue) ; |
|---|---|
| Description |
This routine writes a value into touch panel register. |
| Parameters |
|
| Returns |
|
| Requires |
Nothing. |
| Example |
// write 0xAA into the touch detect threshold register FT5XX6_WriteRegister(FT5XX6_TOUCH_DET_TH_REG, 0xAA); |
| Notes |
|
FT5XX6_ReadRegister
| Prototype |
unsigned short FT5XX6_ReadRegister(unsigned short RegisterAddr) ; |
|---|---|
| Description |
This routine reads a value from the touch panel register. |
| Parameters |
|
| Returns |
The value of the read register. |
| Requires |
Nothing. |
| Example |
// read touch detect threshold register read_value = FT5XX6_ReadRegister(FT5XX6_TOUCH_DET_TH_REG); |
| Notes |
|
FT5XX6_GetRunningState
| Prototype |
unsigned short FT5XX6_GetRunningState(); |
|---|---|
| Description |
This routine reads the running state mode register. |
| Parameters |
None. |
| Returns |
|
| Requires |
Nothing. |
| Example |
// get running state
running_state = FT5XX6_GetRunningState();
if (running_state == 0) {
// configure state
}
if (running_state == 1) {
// work state
}
if (running_state == 2) {
// calibration state
}
if (running_state == 3) {
// factory state
}
if (running_state == 4) {
// auto-calibration state
}
|
| Notes |
|
FT5XX6_IsOperational
| Prototype |
unsigned short FT5XX6_IsOperational(); |
|---|---|
| Description |
This routine checks if the controller is running. |
| Parameters |
None. |
| Returns |
|
| Requires |
Nothing. |
| Example |
// if the controller is running
if (FT5XX6_IsOperational() == FT5XX6_OK) {
...
}
|
| Notes |
|
FT5XX6_SetTouchPanelOrientation
| Prototype |
void FT5XX6_SetTouchPanelOrientation(unsigned short rotation); |
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine sets touch panel orientation. |
||||||||||
| Parameters |
|
||||||||||
| Returns |
Nothing. |
||||||||||
| Requires |
Nothing. |
||||||||||
| Example |
// rotate touch panel by 90 degrees (CCW) FT5XX6_SetTouchPanelOrientation(1); |
||||||||||
| Notes |
|
FT5XX6_GetTouchPanelOrientation
| Prototype |
unsigned short FT5XX6_GetTouchPanelOrientation(); |
|---|---|
| Description |
This routine returns the current touch panel orientation. |
| Parameters |
None. |
| Returns |
|
| Requires |
Nothing. |
| Example |
// get touch panel orientation
tp_orientation = FT5XX6_GetTouchPanelOrientation();
if (orientation == 0) {
// 0 degree rotation (CCW)
}
if (orientation == 1) {
// 90 degree rotation (CCW)
}
if (orientation == 2) {
// 180 degree rotation (CCW)
}
if (orientation == 3) {
// 270 degree rotation (CCW)
}
|
| Notes |
|
FT5XX6_SetSize
| Prototype |
void FT5XX6_SetSize(unsigned int display_width, unsigned int display_height); |
|---|---|
| Description |
This routine sets the touch panel dimensions (should be same as display dimensions). |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Nothing. |
| Example |
// set touch panel area size to 320x240 FT5XX6_SetSize(320,240); |
| Notes |
|
FT5XX6_SetSizeAndRotation
| Prototype |
void FT5XX6_SetSizeAndRotation(unsigned int display_width, unsigned int display_height, unsigned short rotation); |
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine sets the touch panel dimensions (should be same as display dimensions) and rotation. |
||||||||||
| Parameters |
|
||||||||||
| Returns |
Nothing. |
||||||||||
| Requires |
Nothing. |
||||||||||
| Example |
// set touch panel area size to 320x240 with 180 degrees rotation (CCW) FT5XX6_SetSizeAndRotation(320,240,2); |
||||||||||
| Notes |
|
FT5XX6_GetRawCoordinates
| Prototype |
unsigned short FT5XX6_GetRawCoordinates(unsigned int *x_coordinate, unsigned int *y_coordinate); |
|---|---|
| Description |
This routine gets the raw touch coordinates disregarding the touch panel orientation. By default, the landscape orientation is assumed. |
| Parameters |
|
| Returns |
|
| Requires |
Nothing. |
| Example |
// get raw coordinates FT5XX6_GetRawCoordinates(&Xcoord, &Ycoord); |
| Notes |
|
FT5XX6_GetCoordinates
| Prototype |
unsigned short FT5XX6_GetCoordinates(unsigned int *x_coordinate, unsigned int *y_coordinate); |
|---|---|
| Description |
This routine gets the touch coordinates taking into the account touch panel orientation. |
| Parameters |
|
| Returns |
|
| Requires |
Nothing. |
| Example |
// get touch panel coordinates
if (FT5XX6_GetCoordinates(&Xcoord, &Ycoord) == FT5XX6_OK) {
...
}
|
| Notes |
|
FT5XX6_PressDetect
| Prototype |
unsigned short FT5XX6_PressDetect(); |
|---|---|
| Description |
This routine detects if touch panel has been pressed. |
| Parameters |
None. |
| Returns |
|
| Requires |
Nothing. |
| Example |
// if touch panel has been pressed
if (FT5XX6_PressDetect()) {
...
}
|
| Notes |
|
FT5XX6_Rotate180
| Prototype |
void FT5XX6_Rotate180(unsigned short rotate); |
||||||
|---|---|---|---|---|---|---|---|
| Description |
This routine rotates touch panel orientation by 0 or 180 degrees. |
||||||
| Parameters |
|
||||||
| Returns |
Nothing. |
||||||
| Requires |
Nothing. |
||||||
| Example |
// rotate touch panel by 180 degrees FT5XX6_Rotate180(FT5XX6_ROTATE_0); |
||||||
| Notes |
|
FT5XX6_SetController
| Prototype |
void FT5XX6_SetController(unsigned short FT_type); |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine sets the specific controller from FT5xx6 family. |
||||||||||||
| Parameters |
|
||||||||||||
| Returns |
Nothing. |
||||||||||||
| Requires |
Nothing. |
||||||||||||
| Example |
// set FT5x46 controller FT5XX6_SetController(_TC_FT5x46); |
||||||||||||
| Notes |
|
FT5XX6_GetController
| Prototype |
unsigned short FT5XX6_GetController(); |
|---|---|
| Description |
This routine gets the specific controller from FT5xx6 family. |
| Parameters |
None. |
| Returns |
Value of controller that is set. Valid values :
|
| Requires |
Nothing. |
| Example |
// if the FT5x46 controller was set
if (FT5XX6_GetController() == _TC_FT5x46) {
...
}
|
| Notes |
|
FT5XX6_SetDefaultMode
| Prototype |
void FT5XX6_SetDefaultMode(); |
|---|---|
| Description |
This routine sets default values needed by the library - touch panel rotation set to 0 degrees and no touch panel controller selected. |
| Parameters |
None. |
| Returns |
Nothing. |
| Requires |
Nothing. |
| Example |
FT5XX6_SetDefaultMode(); |
| Notes |
|
FT5XX6_GetGesture
| Prototype |
unsigned short FT5XX6_GetGesture(); |
|---|---|
| Description |
This routine detects the gesture performed on the touch panel. |
| Parameters |
None. |
| Returns |
|
| Requires |
Nothing. |
| Example |
// get gesture ID
gestureid = FT5XX6_GetGesture();
if (gestureid == ft5xx6_gest_move_up) {
// if Swipe up gesture detected
}
if (gestureid == ft5xx6_gest_move_left) {
// if Swipe left gesture detected
}
if (gestureid == ft5xx6_gest_move_down) {
// if Swipe down gesture detected
}
if (gestureid == ft5xx6_gest_move_right) {
// if Swipe right gesture detected
}
if (gestureid == FT5XX6_GEST_ZOOM_IN) {
// if Zoom in gesture detected
}
if (gestureid == FT5XX6_GEST_ZOOM_OUT) {
// if Zoom out gesture detected
}
|
| Notes |
|
What do you think about this topic ? Send us feedback!



