mikroSDK Reference Manual
TP_MIKROE Touch Controllers Driver

TP_MIKROE Touch Controller Driver API Reference. More...

Functions list

tp_err_t tp_mikroe_process (tp_mikroe_t *ctx)
 Function processing events. More...
 
void tp_mikroe_gesture (tp_mikroe_t *ctx, tp_event_t *event)
 Read gesture information. More...
 
tp_event_t tp_mikroe_press_detect (tp_mikroe_t *ctx)
 Press detection function. More...
 
void tp_mikroe_press_coordinates (tp_mikroe_t *ctx, tp_touch_coord_t *touch_item)
 Copies touch information from context object to touch item object. More...
 
void tp_mikroe_calibrate (tp_t *tp_instance)
 Calibrates variables used for converting raw TP_MIKROE ADC values to pixel coordinates. More...
 
void tp_mikroe_get_calibration_data (tp_mikroe_t *ctx, tp_mikroe_calibration_data_t *cdata)
 Utility function used for getting a copy of current calibration data. More...
 
void tp_mikroe_set_calibration_data (tp_mikroe_t *ctx, const tp_mikroe_calibration_data_t *cdata)
 Utility function used for setting calibration data. More...
 
void tp_mikroe_set_pressure_threshold_level (tp_mikroe_cfg_t *cfg, tp_mikroe_pressure_threshold_t pressure)
 Utility function used for setting threshold levels. More...
 
bool tp_mikroe_check_pressure (tp_mikroe_t *ctx, uint16_t *x_pos, uint16_t *y_pos)
 Function for reading raw ADC data. More...
 
void tp_mikroe_set_threshold (tp_mikroe_t *ctx, uint16_t threshold_upper, uint16_t threshold_lower)
 Utility function used for setting threshold levels. More...
 
void tp_mikroe_update_ctx_coords (tp_mikroe_t *ctx, uint16_t x_pos, uint16_t y_pos)
 Converts x_pos & y_pos raw ADC values to coordinate values and stores them in 'touch point 0' ctx member. More...
 
void tp_mikroe_calibrate_point (tp_mikroe_t *ctx, bool calibration_points_uninitialized)
 Utility function used for calibration. More...
 
char tp_mikroe_pressure_level_detect (tp_mikroe_t *ctx)
 Function used for checking pressure levels. More...
 
void tp_mikroe_cfg_setup (tp_mikroe_cfg_t *cfg)
 TP_MIKROE Configuration setup Function. More...
 
tp_err_t tp_mikroe_init_tp (tp_mikroe_t *ctx, tp_mikroe_cfg_t *cfg, tp_drv_t *drv)
 TP_MIKROE Touch Panel initialization. This function initializes TP_MIKROE context object using configuration values from TP_MIKROE configuration object and allows touch panel driver interface object to be linked with TP_MIKROE driver functions. More...
 
void tp_mikroe_default_cfg_adc (tp_mikroe_t *ctx)
 TP_MIKROE ADC pin configuration function. More...
 

Detailed Description

Function Documentation

◆ tp_mikroe_process()

tp_err_t tp_mikroe_process ( tp_mikroe_t ctx)

This function checks if touch was detected and if it was, reads and stores touch information in context structure and checks if it's touch down or up.

Note
This function is necessary for interfacing with touch panel library as its address is stored in tp_drv_t driver structure during the TP_MIKROE context initialization.
Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
Return values
Alwaysreturns TP_OK. see tp_err_t for more details.

◆ tp_mikroe_gesture()

void tp_mikroe_gesture ( tp_mikroe_t ctx,
tp_event_t event 
)

Since TP_MIKROE does not support gestures this function is purely for interfacing with the tp library. Gesture returned from the function is always no gesture.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
Note
This function is necessary for interfacing with touch panel library as it's address is stored in tp_drv_t driver structure during the TP_MIKROE context initialization.
Parameters
[in]eventTouch panel gesture data, always TP_EVENT_GEST_NONE. See tp_event_t * definition for detailed explanation.
Returns
Nothing.

◆ tp_mikroe_press_detect()

tp_event_t tp_mikroe_press_detect ( tp_mikroe_t ctx)

Retrieves information about press detection from TP_MIKROE.

Note
This function is necessary for interfacing with touch panel library as its address is stored in tp_drv_t driver structure during the TP_MIKROE context initialization.
Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
Returns
  • TP_EVENT_PRESS_NOT_DET - Touch pressure is not detected.
  • TP_EVENT_PRESS_DET - Touch pressure is detected. See tp_err_t structure definition for detailed explanation.

◆ tp_mikroe_press_coordinates()

void tp_mikroe_press_coordinates ( tp_mikroe_t ctx,
tp_touch_coord_t touch_item 
)

This function is necessary for interfacing with touch panel library as it's address is stored in tp_drv_t driver structure during the TP_MIKROE context initialization.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[out]touch_item: Touch item data. See tp_touch_coord_t structure definition for detailed explanation.
Returns
Nothing.

◆ tp_mikroe_calibrate()

void tp_mikroe_calibrate ( tp_t tp_instance)

Function needs the user to touch all four corners as close to the edges as possible to find the extreme values.

Parameters
[in]*tp_instanceTP instance. See tp_mikroe_t for more information about the context structure.
Returns
Nothing.

◆ tp_mikroe_get_calibration_data()

void tp_mikroe_get_calibration_data ( tp_mikroe_t ctx,
tp_mikroe_calibration_data_t cdata 
)

Function copies data that's being used for converting raw ADC values to actual pixel coordinates.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more
[in]cdataPointer to memory where calibration data will be stored.
Returns
Nothing.

◆ tp_mikroe_set_calibration_data()

void tp_mikroe_set_calibration_data ( tp_mikroe_t ctx,
const tp_mikroe_calibration_data_t cdata 
)

Function copies data stored in cdata. That information will be be used for converting raw ADC values to actual pixel coordinates.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]cdataPointer to memory from where new calibration will be copied and set.
Returns
Nothing.

◆ tp_mikroe_set_pressure_threshold_level()

void tp_mikroe_set_pressure_threshold_level ( tp_mikroe_cfg_t cfg,
tp_mikroe_pressure_threshold_t  pressure 
)

Function copies data stored in pressure. That information will be be used for checking if adequate pressure has been applied to the screen.

Parameters
[in]cfgInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]pressureStructure with desired threshold levels set. See tp_mikroe_pressure_threshold_t for more information about the structure.
Returns
Nothing.

◆ tp_mikroe_check_pressure()

bool tp_mikroe_check_pressure ( tp_mikroe_t ctx,
uint16_t *  x_pos,
uint16_t *  y_pos 
)

Function reads X, Y data and checks if adequate pressure has been applied to the screen.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]x_posPointer to where X AD conversion result will be placed.
[in]y_posPointer to where Y AD conversion result will be placed.
Returns
True(1) or False(0) based on pressure level.

◆ tp_mikroe_set_threshold()

void tp_mikroe_set_threshold ( tp_mikroe_t ctx,
uint16_t  threshold_upper,
uint16_t  threshold_lower 
)
Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]threshold_upperDesired upper threshold level.
[in]threshold_lowerDesired lower threshold level.
Returns
Nothing.

◆ tp_mikroe_update_ctx_coords()

void tp_mikroe_update_ctx_coords ( tp_mikroe_t ctx,
uint16_t  x_pos,
uint16_t  y_pos 
)
Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]x_posX coordinate ADC value.
[in]y_posY coordinate ADC value.
Returns
Nothing.

◆ tp_mikroe_calibrate_point()

void tp_mikroe_calibrate_point ( tp_mikroe_t ctx,
bool  calibration_points_uninitialized 
)

Uses tp_mikroe_check_pressure to get raw coordinates and if any of the coordinates passes extreme value updates min_x/max_x/min_y/max_y. If callibration_points_uninitialized is true then initializes ts extremes with read values.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]calibration_points_uninitializedInitial point or not.
Note
calibration_points_uninitialized should be true only for the first point.
Returns
Nothing.

◆ tp_mikroe_pressure_level_detect()

char tp_mikroe_pressure_level_detect ( tp_mikroe_t ctx)

Function reads raw ADC value and checks if it's between lower and upper pressure threshold.

Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more
Returns
True if press is detected, False if not.

◆ tp_mikroe_cfg_setup()

void tp_mikroe_cfg_setup ( tp_mikroe_cfg_t cfg)

Sets ADC configuration structure to appropriate values.

Parameters
[in]cfgTP_MIKROE configuration object. See tp_mikroe_cfg_t structure definition for detailed explanation.
Returns
Nothing.

◆ tp_mikroe_init_tp()

tp_err_t tp_mikroe_init_tp ( tp_mikroe_t ctx,
tp_mikroe_cfg_t cfg,
tp_drv_t drv 
)
Note
By default, TP_MIKROE structure is initialized with calibration constants for MikroE hardware, in case of different hardware tp_mikroe_set_calibration_data is available for seting already determined calibration constants and tp_mikroe_calibrate is available for determining new calibration constants.
Parameters
[in]ctxInitialized TP_MIKROE context structure. See tp_mikroe_t for more information about the context structure.
[in]cfgTP_MIKROE configuration object. See tp_mikroe_cfg_t structure definition for detailed explanation.
[in]drvTP driver interface object. See tp_drv_t structure definition for detailed explanation.
Returns
  • TP_OK OK See tp_err_t structure definition for detailed explanation.

◆ tp_mikroe_default_cfg_adc()

void tp_mikroe_default_cfg_adc ( tp_mikroe_t ctx)

Sets ADC pins to appropriate values.

Parameters
[in]ctxTP_MIKROE context object. See tp_mikroe_t structure definition for detailed explanation.
Return values
Nothing.