mikroSDK Reference Manual
Touch Panel Library

Touch Panel library API reference. More...

Functions list

void tp_cfg_setup (tp_cfg_t *cfg)
 Touch Panel Configuration Function. More...
 
tp_err_t tp_init (tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx)
 Touch Panel Initialization Function. More...
 
void tp_press_callback_setup (tp_t *ctx, tp_press_callback_t cb)
 Touch Panel Callback Setup Function. More...
 
void tp_gesture_callback_setup (tp_t *ctx, tp_gesture_callback_t cb)
 Touch Panel Callback Setup Function. More...
 
void tp_rotate (tp_t *ctx, tp_rotate_t rotate)
 Touch Panel Rotate Function. More...
 
tp_rotate_t tp_get_orientation (tp_t *ctx)
 Touch Panel Orientation Check Function. More...
 
void tp_get_size (tp_t *ctx, uint16_t *width, uint16_t *height)
 Touch Panel Size Check Function. More...
 
tp_event_t tp_press_detect (tp_t *ctx)
 Touch Panel Pressure Detector Function. More...
 
tp_err_t tp_press_coordinates (tp_t *ctx, tp_touch_item_t *touch_item)
 Touch Panel Pressure Coordinates Check Function. More...
 
void tp_gesture (tp_t *ctx, tp_event_t *event)
 Touch Panel Gesture Check Function. More...
 
tp_err_t tp_process (tp_t *ctx)
 Touch Panel Process Function. More...
 

Detailed Description

API for configuring and manipulating Touch Panel library.

Function Documentation

◆ tp_cfg_setup()

void tp_cfg_setup ( tp_cfg_t cfg)

Configures Touch Panel configuration structure to default initialization values.

Parameters
[out]cfg: Touch Panel configuration object. See tp_cfg_t structure definition for detailed explanation.
Returns
Nothing.
Note
Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.

Example

// TP configuration object declaration.
tp_cfg_t tp_cfg;
// TP configuration object setup to initial values.
tp_cfg_setup( &tp_cfg );

◆ tp_init()

tp_err_t tp_init ( tp_t ctx,
tp_cfg_t cfg,
tp_drv_t drv,
void *  drv_ctx 
)

This function initializes Touch Panel context object to default initialization values and executes a linking procedure between Touch Panel API and touch controller driver.

Parameters
[out]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[in]cfg: Touch Panel configuration object. See tp_cfg_t structure definition for detailed explanation.
[in]drv: Touch Panel driver interface object. See tp_drv_t structure definition for detailed explanation.
[in]drv_ctx: Touch Panel driver context object. See ft5xx6_t structure definition for detailed explanation.
Returns
  • 0 - OK,
  • 3 - Size error.
See tp_err_t structure definition for detailed explanation.

Example

// TP API object.
tp_t tp;
// TP configuration object.
tp_cfg_t tp_cfg;
// TP driver interface object.
tp_drv_t tp_interface;
// FT5xx6 touch controller driver object.
ft5xx6_t ft5xx6;
// FT5xx6 configuration object.
ft5xx6_cfg_t ft5xx6_cfg;
// FT5x26 series touch controllers descriptor.
// FT5xx6 driver setup.
// FT5xx6 driver pin mapping.
FT5XX6_MAP_PINS( ft5xx6_cfg );
// FT5xx6 driver initialization.
ft5xx6_init( &ft5xx6, &ft5xx6_cfg, &tp_interface );
// FT5xx6 driver default configuration.
ft5xx6_default_cfg( &ft5xx6 );
// TP API setup.
tp_cfg_setup( &tp_cfg );
tp_cfg.width = 800;
tp_cfg.height = 480;
// TP API initialization.
tp_init( &tp, &tp_cfg, &tp_interface, &ft5xx6 );

◆ tp_press_callback_setup()

void tp_press_callback_setup ( tp_t ctx,
tp_press_callback_t  cb 
)

This function sets callback handler for touch pressure detection.

Parameters
[out]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[in]cb: Callback function (handler). See tp_press_callback_t structure definition for detailed explanation.
Returns
Nothing.
Note
If callback handler is not set, it will be ignored in the code.

Example

// TP API object.
tp_t tp;
// Callback handler function declaration.
void touch_callback( tp_event_t event, tp_coord_t x, tp_coord_t y,
// Callback handler setting.
tp_press_callback_setup( &tp, touch_callback );

◆ tp_gesture_callback_setup()

void tp_gesture_callback_setup ( tp_t ctx,
tp_gesture_callback_t  cb 
)

This function sets callback handler for gesture event.

Parameters
[out]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[in]cb: Callback function (handler). See tp_gesture_callback_t structure definition for detailed explanation.
Returns
Nothing.
Note
If callback handler is not set, it will be ignored in the code.

Example

// TP API object.
tp_t tp;
// Callback handler function declaration.
void gesture_callback( tp_event_t event );
// Callback handler setting.
tp_gesture_callback_setup( &tp, gesture_callback );

◆ tp_rotate()

void tp_rotate ( tp_t ctx,
tp_rotate_t  rotate 
)

This function sets the Touch Panel orientation.

Parameters
[out]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[in]rotate: Selects the orientation angle. See tp_rotate_t for valid values.
Returns
Nothing.

Example

// TP API object.
tp_t tp;
// TP rotation setting.

◆ tp_get_orientation()

tp_rotate_t tp_get_orientation ( tp_t ctx)

This function checks the Touch Panel orientation state.

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
Returns
Touch Panel orientation value. See tp_rotate_t structure definition for detailed explanation.

Example

// TP API object.
tp_t tp;
// TP placement state.
// TP placement checking.
state = tp_get_orientation( &tp );

◆ tp_get_size()

void tp_get_size ( tp_t ctx,
uint16_t *  width,
uint16_t *  height 
)

This function checks the Touch Panel size.

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[out]width: Touch Panel width size.
[out]height: Touch Panel height size.
Returns
Nothing.

Example

// TP API object.
tp_t tp;
// TP size data.
uint16_t tp_width, tp_height;
// TP size checking.
tp_get_size( &tp, &tp_width, &tp_height );

◆ tp_press_detect()

tp_event_t tp_press_detect ( tp_t ctx)

This function checks the touch pressure detection.

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
Returns
Touch Panel pressure event:
  • 3 - Touch is not detected,
  • 4 - Touch is detected. See tp_event_t structure definition for detailed explanation.
Note
tp_process function must be called to update all events.

Example

// TP API object.
tp_t tp;
// Touch detection event.
tp_event_t event;
// Touch detection checking.
event = tp_press_detect( &tp );

◆ tp_press_coordinates()

tp_err_t tp_press_coordinates ( tp_t ctx,
tp_touch_item_t touch_item 
)

This function allows user to get the informations about the number of pressed touch points, coordinates and touch event for each pressed touch point.

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[out]touch_item: Touch item data. See tp_touch_item_t structure definition for detailed explanation.
Returns
  • 0 - OK,
  • 4 - Touch coordinates are out of range. See tp_err_t structure definition for detailed explanation.
Note
tp_process function must be called to update all events.

Example

// TP API object.
tp_t tp;
// TP error code.
tp_err_t error;
// Touch pressure item data.
// Touch pressure item getting.
error = tp_press_coordinates( &tp, &tp_item );

◆ tp_gesture()

void tp_gesture ( tp_t ctx,
tp_event_t event 
)

This function allows user to get the informations about the gesture (slide direction).

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
[out]event: Touch Panel gesture event. See tp_event_t structure definition for detailed explanation.
Returns
Nothing.
Note
tp_process function must be called to update all events.

Example

// TP API object.
tp_t tp;
// TP gesture event.
tp_event_t event;
// TP gesture event checking.
tp_gesture( &tp, &event );

◆ tp_process()

tp_err_t tp_process ( tp_t ctx)

This function detects a touch pressure, and if any touch pressure was detected, then collects all data information and events about the pressed touch and slide direction (gesture), and calls a callback handlers, if they are set.

Parameters
[in]ctx: Touch Panel context object. See tp_t structure definition for detailed explanation.
Returns
  • 0 - OK,
  • 4 - Touch coordinates are out of range,
  • 5 - Number of pressed touches is out of range. See tp_err_t structure definition for detailed explanation.
Note
To get all possible events, just need to call this function, but callback handlers must be set first. This function is not blocking function.

Example

// TP API object.
tp_t tp;
// TP error code.
tp_err_t error;
// TP events and data processing.
error = tp_process( &tp );
tp_t
Touch Panel Context Object.
Definition: tp.h:222
TP_ROTATE_0
Definition: tp.h:117
FT5XX6_MAP_PINS
#define FT5XX6_MAP_PINS(cfg)
FT5xx6 Pin Mapping.
Definition: ft5xx6.h:514
tp_touch_id_t
tp_touch_id_t
Touch Point ID Definition.
Definition: tp.h:100
tp_press_detect
tp_event_t tp_press_detect(tp_t *ctx)
Touch Panel Pressure Detector Function.
tp_cfg_t::start_pos
tp_rotate_t start_pos
Definition: tp.h:214
ft5xx6_default_cfg
void ft5xx6_default_cfg(ft5xx6_t *ctx)
FT5xx6 Default Configuration Function.
tp_cfg_t::height
uint16_t height
Definition: tp.h:213
tp_gesture
void tp_gesture(tp_t *ctx, tp_event_t *event)
Touch Panel Gesture Check Function.
tp_event_t
tp_event_t
Touch Panel Event Code Definition.
Definition: tp.h:79
ft5xx6_init
tp_err_t ft5xx6_init(ft5xx6_t *ctx, ft5xx6_cfg_t *cfg, tp_drv_t *drv)
FT5xx6 Initialization Function.
tp_touch_item_t
Touch Item Definition.
Definition: tp.h:149
tp_gesture_callback_setup
void tp_gesture_callback_setup(tp_t *ctx, tp_gesture_callback_t cb)
Touch Panel Callback Setup Function.
TP_ROTATE_180
Definition: tp.h:119
ft5xx6_t
FT5xx6 Context Object.
Definition: ft5xx6.h:588
tp_err_t
tp_err_t
Touch Panel Error Code Definition.
Definition: tp.h:63
tp_rotate_t
tp_rotate_t
Touch Panel Placement (Orientation) Definition.
Definition: tp.h:115
FT5X26_CONTROLLER
const ft5xx6_controller_t FT5X26_CONTROLLER
FT5x26 Touch Controllers Descriptor.
tp_rotate
void tp_rotate(tp_t *ctx, tp_rotate_t rotate)
Touch Panel Rotate Function.
tp_process
tp_err_t tp_process(tp_t *ctx)
Touch Panel Process Function.
tp_coord_t
uint16_t tp_coord_t
Touch Point Coordinates Data Type.
Definition: tp.h:129
tp_cfg_setup
void tp_cfg_setup(tp_cfg_t *cfg)
Touch Panel Configuration Function.
tp_init
tp_err_t tp_init(tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx)
Touch Panel Initialization Function.
ft5xx6_cfg_setup
void ft5xx6_cfg_setup(ft5xx6_cfg_t *cfg, const ft5xx6_controller_t *controller)
FT5xx6 Configuration Object Setup Function.
ft5xx6_controller_t
FT5xx6 Gesture Items.
Definition: ft5xx6.h:564
tp_get_orientation
tp_rotate_t tp_get_orientation(tp_t *ctx)
Touch Panel Orientation Check Function.
tp_press_callback_setup
void tp_press_callback_setup(tp_t *ctx, tp_press_callback_t cb)
Touch Panel Callback Setup Function.
tp_cfg_t
Touch Panel Size And Placement Configuration Object.
Definition: tp.h:210
tp_get_size
void tp_get_size(tp_t *ctx, uint16_t *width, uint16_t *height)
Touch Panel Size Check Function.
tp_drv_t
Touch Panel Driver Interface Items.
Definition: tp.h:197
ft5xx6_cfg_t
FT5xx6 Configuration Object.
Definition: ft5xx6.h:574
tp_press_coordinates
tp_err_t tp_press_coordinates(tp_t *ctx, tp_touch_item_t *touch_item)
Touch Panel Pressure Coordinates Check Function.
tp_cfg_t::width
uint16_t width
Definition: tp.h:212