Touch Panel TFT Library

The mikroC PRO for FT90x provides a library for working with Touch Panel for TFT.

Library Dependency Tree

Touch Panel TFT Library Dependency Tree

External dependencies of Touch Panel TFT Library

The following variables must be defined in all projects using Touch Panel TFT Library: Description : Example :
extern sfr sbit DriveX_Left; DriveX_Left line. sbit DriveX_Left at GPIO_PIN7_bit;
extern sfr sbit DriveX_Right; DriveX_Right line. sbit DriveX_Right at GPIO_PIN9_bit;
extern sfr sbit DriveY_Up; DriveY_Up line. sbit DriveY_Up at GPIO_PIN11_bit;
extern sfr sbit DriveY_Down; DriveY_Down line. sbit DriveY_Down at GPIO_PIN6_bit;

Library Routines

TP_TFT_Init

Prototype

void TP_TFT_Init(unsigned int display_width, unsigned int display_height, unsigned int readX_ChNo, unsigned int readY_ChNo);

Description

Initialize TFT touch panel display. Default touch panel ADC threshold value is set to 900.

Parameters
  • display_width: set display width.
  • display_height: set display height.
  • readX_ChNo: read X coordinate from desired ADC channel.
  • readY_ChNo: read Y coordinate from desired ADC channel.
Returns

Nothing.

Requires

Before calling this function initialize ADC module.

Example
// set ADC input channels
ADC_Set_Input_Channel(_ADC_CHANNEL_0 | _ADC_CHANNEL_1);
ADC1_Init();                   // Initalize ADC module
TP_TFT_Init(320, 240, 13, 12); // Initialize touch panel
Notes

None.

TP_TFT_Rotate_180

Prototype

void TP_TFT_Rotate_180(char);

Description

Rotates touch panel by 180 degrees.

Parameters
  • rotate: set display width. Valid values : 0 - don't rotate, 1 - rotate by 180 degrees.
Returns

Nothing.

Requires

Nothing.

Example
TP_TFT_Rotate_180(1);   // rotate Touch Panel by 180 degrees
Notes

None.

TP_TFT_Set_ADC_Threshold

Prototype

void TP_TFT_Set_ADC_Threshold(unsigned int threshold);

Description

Set custom ADC threshold value, call this function after TP_TFT_Init.

Parameters
  • threshold: custom ADC threshold value.
Returns

Nothing.

Requires

TP_TFT_Init has to be called before using this routine.

Example
TP_TFT_Set_ADC_Threshold(900);    // Set touch panel ADC threshold
Notes

None.

TP_TFT_Press_Detect

Prototype

char TP_TFT_Press_Detect();

Description

Detects if the touch panel has been pressed.

Parameters

None.

Returns
  • 1 - if touch panel is pressed.
  • 0 - otherwise.
Requires

External dependencies of the library from the top of the page must be defined before using this function.

Example
if (TP_TFT_Press_Detect()) {
...
}
Notes

None.

TP_TFT_Get_Coordinates

Prototype

char TP_TFT_Get_Coordinates(unsigned int *x_coordinate, unsigned int *y_coordinate);

Description

Get touch panel coordinates and store them in x_coordinate and y_coordinate parameters.

Parameters
  • x_coordinate: x coordinate of the place of touch.
  • y_coordinate: y coordinate of the place of touch.
Returns
  • 0 - if reading is within display dimension range.
  • 1 - if reading is out of display dimension range.
Requires

Nothing.

Example
if (TP_TFT_Get_Coordinates(&x_coord, &y_coord) == 0) {
 ...
}
Notes

None.

TP_TFT_Calibrate_Min

Prototype

void TP_TFT_Calibrate_Min();

Description

Calibrate bottom left corner of the touch Panel.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
TP_TFT_Calibrate_Min();    // Calibration of bottom left corner
Notes

None.

TP_TFT_Calibrate_Max

Prototype

void TP_TFT_Calibrate_Max();

Description

Calibrate upper right corner of the touch panel.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
TP_TFT_Calibrate_Max();    // Calibration of upper right corner
Notes

None.

TP_TFT_Get_Calibration_Consts

Prototype

void TP_TFT_Get_Calibration_Consts(unsigned int *x_min, unsigned int *x_max, unsigned int *y_min, unsigned int *y_max);

Description

Gets calibration constants after calibration is done and stores them in x_min, x_max, y_min and y_max parameters.

Parameters
  • x_min: x coordinate of the bottom left corner of the working area.
  • x_max: x coordinate of the upper right corner of the working area.
  • y_min: y coordinate of the bottom left corner of the working area.
  • y_max: y coordinate of the upper right corner of the working area.
Returns

Nothing.

Requires

Nothing.

Example
TP_TFT_Get_Calibration_Consts(&x_min, &y_min, &x_max, &y_max);    // Get calibration constants
Notes

None.

TP_TFT_Set_Calibration_Consts

Prototype

void TP_TFT_Set_Calibration_Consts(unsigned int x_min, unsigned int x_max, unsigned int y_min, unsigned int y_max);

Description

Sets calibration constants.

Parameters
  • x_min: x coordinate of the bottom left corner of the working area.
  • x_max: x coordinate of the upper right corner of the working area.
  • y_min: y coordinate of the bottom left corner of the working area.
  • y_max: y coordinate of the upper right corner of the working area.
Returns

Nothing.

Requires

Nothing.

Example
TP_TFT_Set_Calibration_Consts(173, 776, 75, 760);    // Set calibration constants
Notes

None.

Copyright (c) 2002-2015 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code