mikroSDK Reference Manual
TP_MIKROE Touch Controllers Driver

TP_MIKROE Touch Controller Driver API Reference. More...

Data Structures

struct  tp_mikroe_calibration_data_t
 Calibration data structure. More...
 
struct  tp_mikroe_pressure_threshold_t
 Pressure threshold data structure. More...
 
struct  tp_mikroe_cfg_t
 TP_MIKROE Configuration Object. More...
 
struct  tp_mikroe_t
 TP_MIKROE Context Object. More...
 

Macros

#define VREF_VALUE   3.3f
 Defines value for vref.
 
#define TP_MIKROE_CALIBRATION_XMIN   0
 
#define TP_MIKROE_CALIBRATION_XMAX   0
 
#define TP_MIKROE_CALIBRATION_YMIN   0
 
#define TP_MIKROE_CALIBRATION_YMAX   0
 
#define TP_MIKROE_PRESSURE_THRESHOLD_LOWER   0
 
#define TP_MIKROE_PRESSURE_THRESHOLD_UPPER   0
 
#define TP_MIKROE_MAP_PINS(tp_mikroe_cfg)
 Mapping for ADC config structure.
 
#define TP_MIKROE_ADC_CONFIG(cfg)
 
#define SET_PEN()    gl_set_pen( GL_WHITE, 4 );
 Macros used to draw arrows during tp_mikroe_calibration.
 
#define DRAW_ARROW_TOP_LEFT()
 
#define DRAW_ARROW_TOP_RIGHT()
 
#define DRAW_ARROW_BOTTOM_LEFT()
 
#define DRAW_ARROW_BOTTOM_RIGHT()
 

Functions list

tp_err_t tp_mikroe_process (tp_mikroe_t *ctx)
 Function processing events.
 
void tp_mikroe_gesture (tp_mikroe_t *ctx, tp_event_t *event)
 Read gesture information.
 
tp_event_t tp_mikroe_press_detect (tp_mikroe_t *ctx)
 Press detection function.
 
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.
 
void tp_mikroe_calibrate (tp_t *tp_instance)
 Calibrates variables used for converting raw TP_MIKROE ADC values to pixel coordinates.
 
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.
 
void tp_mikroe_set_calibration_data (tp_mikroe_t *ctx, const tp_mikroe_calibration_data_t *cdata)
 Utility function used for setting calibration data.
 
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.
 
bool tp_mikroe_check_pressure (tp_mikroe_t *ctx, uint16_t *x_pos, uint16_t *y_pos)
 Function for reading raw ADC data.
 
void tp_mikroe_set_threshold (tp_mikroe_t *ctx, uint16_t threshold_upper, uint16_t threshold_lower)
 Utility function used for setting threshold levels.
 
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.
 
void tp_mikroe_calibrate_point (tp_mikroe_t *ctx, bool calibration_points_uninitialized)
 Utility function used for calibration.
 
char tp_mikroe_pressure_level_detect (tp_mikroe_t *ctx)
 Function used for checking pressure levels.
 
void tp_mikroe_cfg_setup (tp_mikroe_cfg_t *cfg)
 TP_MIKROE Configuration setup Function.
 
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.
 
void tp_mikroe_default_cfg_adc (tp_mikroe_t *ctx)
 TP_MIKROE ADC pin configuration function.
 

Macro Definition Documentation

◆ DRAW_ARROW_BOTTOM_LEFT

#define DRAW_ARROW_BOTTOM_LEFT ( )
Value:
gl_draw_line( 0, 240, 0, 230 ); \
gl_draw_line( 0, 240, 10, 240 ); \
gl_draw_line( 0, 240, 15, 225 );
@ GL_BLACK
Definition gl_colors.h:100
void gl_clear(gl_color_t color)
Paint hole display with color. If driver is not set then function do nothing.

◆ DRAW_ARROW_BOTTOM_RIGHT

#define DRAW_ARROW_BOTTOM_RIGHT ( )
Value:
gl_draw_line( 320, 240, 320, 230 ); \
gl_draw_line( 320, 240, 310, 240 ); \
gl_draw_line( 320, 240, 305, 225 );

◆ DRAW_ARROW_TOP_LEFT

#define DRAW_ARROW_TOP_LEFT ( )
Value:
gl_draw_line( 0, 0, 10, 0 ); \
gl_draw_line( 0, 0, 0, 10 ); \
gl_draw_line( 0, 0, 15, 15 );

◆ DRAW_ARROW_TOP_RIGHT

#define DRAW_ARROW_TOP_RIGHT ( )
Value:
gl_draw_line( 320, 0, 320, 10 ); \
gl_draw_line( 320, 0, 310, 0 ); \
gl_draw_line( 320, 0, 305, 15 );

◆ TP_MIKROE_ADC_CONFIG

#define TP_MIKROE_ADC_CONFIG ( cfg)
Value:
cfg->analog_in_cfg_read_x.resolution = ANALOG_IN_RESOLUTION_CMAKE; \
cfg->analog_in_cfg_read_y.resolution = ANALOG_IN_RESOLUTION_CMAKE; \
cfg->analog_in_cfg_read_x.input_pin = TP_READ_X_CMAKE; \
cfg->analog_in_cfg_read_y.input_pin = TP_READ_Y_CMAKE; \
cfg->analog_in_cfg_read_x.vref_input = ANALOG_IN_VREF_CMAKE; \
cfg->analog_in_cfg_read_y.vref_input = ANALOG_IN_VREF_CMAKE; \
cfg->analog_in_cfg_read_x.vref_value = VREF_VALUE; \
cfg->analog_in_cfg_read_y.vref_value = VREF_VALUE;
#define VREF_VALUE
Defines value for vref.
Definition tp_mikroe.h:73

◆ TP_MIKROE_MAP_PINS

#define TP_MIKROE_MAP_PINS ( tp_mikroe_cfg)
Value:
tp_mikroe_cfg.left = TP_MIKROE_XL;\
tp_mikroe_cfg.right = TP_MIKROE_XR;\
tp_mikroe_cfg.up = TP_MIKROE_YU;\
tp_mikroe_cfg.down = TP_MIKROE_YD;

Function Documentation

◆ 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.
Return values
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.
Return values
Nothing.

◆ 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.
Return values
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.
Return values

b True(1) or False(0) based on pressure level.

◆ 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.

◆ 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.
Return values
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.
Return values
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.
Return values

li TP_OK OK, 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]tp_instanceTP instance. See tp_t structure definition for detailed explanation.
[in]touch_item
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.
Return values

li 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_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
Return values
Trueif press is detected, False if not.

◆ 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_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.
Return values
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.
Return values
Nothing.

◆ tp_mikroe_set_threshold()

void tp_mikroe_set_threshold ( tp_mikroe_t * ctx,
uint16_t threshold_upper,
uint16_t threshold_lower )
Parameters
[in]cfxInitialized 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.
Return values
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.
Return values
Nothing.