Touch Panel TFT Library
The mikroPascal PRO for ARM provides a library for working with Touch Panel for TFT.
Library Dependency Tree

Stellaris
The following variables must be defined in all projects using Touch Panel TFT Library: | Description : | Example : |
---|---|---|
var DriveX_Left : sbit; sfr; external; |
DriveX_Left line. | var DriveX_Left : sbit at GPIO_PORTB_DATA4_bit; |
var DriveX_Right : sbit; sfr; external; |
DriveX_Right line. | var DriveX_Right : sbit at GPIO_PORTE_DATA0_bit; |
var DriveY_Up : sbit; sfr; external; |
DriveY_Up line. | var DriveY_Up : sbit at GPIO_PORTE_DATA1_bit; |
var DriveY_Down : sbit; sfr; external; |
DriveY_Down line. | var DriveY_Down : sbit at GPIO_PORTB_DATA5_bit; |
var DriveX_Left_Direction : sbit; sfr; external; |
Direction of the DriveX_Left pin. | var DriveX_Left_Direction : sbit at GPIO_PORTB_DIR4_bit; |
var DriveX_Right_Direction : sbit; sfr; external; |
Direction of the DriveX_Right pin. | var DriveX_Right_Direction : sbit at GPIO_PORTE_DIR0_bit; |
var DriveY_Up_Direction : sbit; sfr; external; |
Direction of the DriveY_Up pin. | var DriveY_Up_Direction : sbit at GPIO_PORTE_DIR1_bit; |
var DriveY_Down_Direction : sbit; sfr; external; |
Direction of the DriveY_Down pin. | var DriveY_Down_Direction : sbit at GPIO_PORTB_DIR5_bit; |
STM32
The following variables must be defined in all projects using Touch Panel TFT Library: | Description : | Example : |
---|---|---|
var DriveX_Left : sbit; sfr; external; |
DriveX_Left line. | var DriveX_Left : sbit at GPIOB_ODR.B1; |
var DriveX_Right : sbit; sfr; external; |
DriveX_Right line. | var DriveX_Right : sbit at GPIOB_ODR.B8; |
var DriveY_Up : sbit; sfr; external; |
DriveY_Up line. | var DriveY_Up : sbit at GPIOB_ODR.B9; |
var DriveY_Down : sbit; sfr; external; |
DriveY_Down line. | var DriveY_Down : sbit at GPIOB_ODR.B10; |
External dependencies of Touch Panel TFT Library
Library Routines
- TP_TFT_Init
- TP_TFT_Rotate
- TP_TFT_Set_ADC_Threshold
- TP_TFT_Press_Detect
- TP_TFT_Get_Coordinates
- TP_TFT_Calibrate_Min
- TP_TFT_Calibrate_Max
- TP_TFT_Get_Calibration_Consts
- TP_TFT_Set_Calibration_Consts
TP_TFT_Init
Prototype |
procedure TP_TFT_Init(display_width : word; display_height : word; readX_ChNo : byte; readY_ChNo : byte); |
---|---|
Description |
Initialize TFT touch panel display. Default touch panel ADC threshold value is set to 900. |
Parameters |
|
Returns |
Nothing. |
Requires |
Before calling this function initialize ADC module. |
Example |
ADC1_Init(); // Initalize ADC module TP_TFT_Init(320, 240, 13, 12); // Initialize touch panel |
Notes |
None. |
TP_TFT_Rotate
Prototype |
procedure TP_TFT_Rotate(rotate : byte); |
---|---|
Description |
Rotates touch panel by 180 degrees. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TP_TFT_Rotate(1); // rotate Touch Panel by 180 degrees |
Notes |
None. |
TP_TFT_Set_ADC_Threshold
Prototype |
procedure TP_TFT_Set_ADC_Threshold(threshold : word); |
---|---|
Description |
Set custom ADC threshold value, call this function after |
Parameters |
|
Returns |
Nothing. |
Requires |
|
Example |
TP_TFT_Set_ADC_Threshold(900); // Set touch panel ADC threshold |
Notes |
None. |
TP_TFT_Press_Detect
Prototype |
function TP_TFT_Press_Detect() : byte; |
---|---|
Description |
Detects if the touch panel has been pressed. |
Parameters |
None. |
Returns |
|
Requires |
External dependencies of the library from the top of the page must be defined before using this function. |
Example |
Stellaris// Touch Panel module connections var DriveX_Left : sbit at GPIO_PORTB_DATA4_bit; var DriveX_Right : sbit at GPIO_PORTE_DATA0_bit; var DriveY_Up : sbit at GPIO_PORTE_DATA1_bit; var DriveY_Down : sbit at GPIO_PORTB_DATA5_bit; var DriveX_Left_Direction : sbit at GPIO_PORTB_DIR4_bit; var DriveX_Right_Direction : sbit at GPIO_PORTE_DIR0_bit; var DriveY_Up_Direction : sbit at GPIO_PORTE_DIR1_bit; var DriveY_Down_Direction : sbit at GPIO_PORTB_DIR5_bit; // End Touch Panel module connections if (TP_TFT_Press_Detect() <> 0) then begin ... end; STM32// Touch Panel module connections var DriveX_Left : sbit at GPIOB_ODR.B1; var DriveX_Right : sbit at GPIOB_ODR.B8; var DriveY_Up : sbit at GPIOB_ODR.B9; var DriveY_Down : sbit at GPIOB_ODR.B0; // End Touch Panel module connections if (TP_TFT_Press_Detect() <> 0) then begin ... end; |
Notes |
None. |
TP_TFT_Get_Coordinates
Prototype |
function TP_TFT_Get_Coordinates(x_coordinate : ^word; y_coordinate : ^word) : byte; |
---|---|
Description |
Get touch panel coordinates and store them in |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
if (TP_TFT_Get_Coordinates(@x_coord, @y_coord) = 0) then begin ... end; |
Notes |
None. |
TP_TFT_Calibrate_Min
Prototype |
procedure 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 |
procedure 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 |
procedure TP_TFT_Get_Calibration_Consts(x_min : ^word; x_max : ^word; y_min : ^word; y_max : ^word); |
---|---|
Description |
Gets calibration constants after calibration is done and stores them in |
Parameters |
|
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 |
procedure TP_TFT_Set_Calibration_Consts(x_min : word; x_max : word; y_min : word; y_max : word); |
---|---|
Description |
Sets calibration constants. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TP_TFT_Set_Calibration_Consts(173, 776, 75, 760); // Set calibration constants |
Notes |
None. |
What do you think about this topic ? Send us feedback!