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

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 );
void tp_cfg_setup(tp_cfg_t *cfg)
Touch Panel Configuration Function.
Touch Panel Size And Placement Configuration Object.
Definition tp.h:212

◆ tp_gesture()

void tp_gesture ( tp_t * ctx,
tp_event_t * event )

This function allows user to get the information 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 );
void tp_gesture(tp_t *ctx, tp_event_t *event)
Touch Panel Gesture Check Function.
Touch Panel Context Object.
Definition tp.h:224
tp_event_t
Touch Panel Event Code Definition.
Definition tp.h:81

◆ 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 );
void tp_gesture_callback_setup(tp_t *ctx, tp_gesture_callback_t cb)
Touch Panel Callback Setup Function.

◆ 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_rotate_t tp_get_orientation(tp_t *ctx)
Touch Panel Orientation Check Function.
tp_rotate_t
Touch Panel Placement (Orientation) Definition.
Definition tp.h:117

◆ 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 );
void tp_get_size(tp_t *ctx, uint16_t *width, uint16_t *height)
Touch Panel Size Check Function.

◆ 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 );
const ft5xx6_controller_t FT5X26_CONTROLLER
FT5x26 Touch Controllers Descriptor.
#define FT5XX6_MAP_PINS(cfg)
FT5xx6 Pin Mapping.
Definition ft5xx6.h:510
tp_err_t ft5xx6_init(ft5xx6_t *ctx, ft5xx6_cfg_t *cfg, tp_drv_t *drv)
FT5xx6 Initialization Function.
void ft5xx6_cfg_setup(ft5xx6_cfg_t *cfg, const ft5xx6_controller_t *controller)
FT5xx6 Configuration Object Setup Function.
void ft5xx6_default_cfg(ft5xx6_t *ctx)
FT5xx6 Default Configuration Function.
tp_err_t tp_init(tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx)
Touch Panel Initialization Function.
FT5xx6 Configuration Object.
Definition ft5xx6.h:571
FT5xx6 Gesture Items.
Definition ft5xx6.h:561
FT5xx6 Context Object.
Definition ft5xx6.h:585
uint16_t height
Definition tp.h:214
uint16_t width
Definition tp.h:213
tp_rotate_t start_pos
Definition tp.h:215
Touch Panel Driver Interface Items.
Definition tp.h:199
@ TP_ROTATE_180
Definition tp.h:120

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.
tp_mikroe_t tpMikroe;
// TP API setup.
tp_cfg_setup( &tp_cfg );
tp_cfg.width = 320;
tp_cfg.height = 240;
// TP API initialization.
tp_init( &tp, &tp_cfg, &tp_interface, &tpMikroe );
TP_MIKROE Context Object.
Definition tp_mikroe.h:163
@ TP_ROTATE_0
Definition tp.h:118

◆ 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 );
void tp_press_callback_setup(tp_t *ctx, tp_press_callback_t cb)
Touch Panel Callback Setup Function.
uint16_t tp_coord_t
Touch Point Coordinates Data Type.
Definition tp.h:130
tp_touch_id_t
Touch Point ID Definition.
Definition tp.h:102

◆ tp_press_coordinates() [1/2]

tp_err_t tp_press_coordinates ( tp_t * ctx,
tp_touch_coord_t * touch_item )

This function allows user to get the information about the coordinates and touch event for 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_coord_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_err_t tp_press_coordinates(tp_t *ctx, tp_touch_item_t *touch_item)
Touch Panel Pressure Coordinates Check Function.
Touch Point Object Definition.
Definition tp.h:137
tp_err_t
Touch Panel Error Code Definition.
Definition tp.h:65

◆ tp_press_coordinates() [2/2]

tp_err_t tp_press_coordinates ( tp_t * ctx,
tp_touch_item_t * touch_item )

This function allows user to get the information 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 );
Touch Item Definition.
Definition tp.h:151

◆ 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_event_t tp_press_detect(tp_t *ctx)
Touch Panel Pressure Detector Function.

◆ 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_err_t tp_process(tp_t *ctx)
Touch Panel Process Function.

This function detects touch pressure, and if any touch pressure was detected, collects all data information and events about the pressed touch, and calls 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 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_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.
void tp_rotate(tp_t *ctx, tp_rotate_t rotate)
Touch Panel Rotate Function.