Touch Panel TFT Library
The mikroC PRO for ARM provides a library for working with Touch Panel for TFT.
Library Dependency Tree
External dependencies of Touch Panel TFT Library
Stellaris
| 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_PORTB_DATA4_bit; |
extern sfr sbit DriveX_Right; |
DriveX_Right line. | sbit DriveX_Right at GPIO_PORTE_DATA0_bit; |
extern sfr sbit DriveY_Up; |
DriveY_Up line. | sbit DriveY_Up at GPIO_PORTE_DATA1_bit; |
extern sfr sbit DriveY_Down; |
DriveY_Down line. | sbit DriveY_Down at GPIO_PORTB_DATA5_bit; |
extern sfr sbit DriveX_Left_Direction; |
Direction of the DriveX_Left pin. | sbit DriveX_Left_Direction at GPIO_PORTB_DIR4_bit; |
extern sfr sbit DriveX_Right_Direction; |
Direction of the DriveX_Right pin. | sbit DriveX_Right_Direction at GPIO_PORTE_DIR0_bit; |
extern sfr sbit DriveY_Up_Direction; |
Direction of the DriveY_Up pin. | sbit DriveY_Up_Direction at GPIO_PORTE_DIR1_bit; |
extern sfr sbit DriveY_Down_Direction; |
Direction of the DriveY_Down pin. | sbit DriveY_Down_Direction at GPIO_PORTB_DIR5_bit; |
STM32
| 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 GPIOB_ODR.B1; |
extern sfr sbit DriveX_Right; |
DriveX_Right line. | sbit DriveX_Right at GPIOB_ODR.B8; |
extern sfr sbit DriveY_Up; |
DriveY_Up line. | sbit DriveY_Up at GPIOB_ODR.B9; |
extern sfr sbit DriveY_Down; |
DriveY_Down line. | sbit DriveY_Down at GPIOB_ODR.B10; |
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 |
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 |
|
| 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 |
void TP_TFT_Rotate(char); |
|---|---|
| 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 |
void TP_TFT_Set_ADC_Threshold(unsigned int threshold); |
|---|---|
| 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 |
char TP_TFT_Press_Detect(); |
|---|---|
| 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
sbit DriveX_Left at GPIO_PORTB_DATA4_bit;
sbit DriveX_Right at GPIO_PORTE_DATA0_bit;
sbit DriveY_Up at GPIO_PORTE_DATA1_bit;
sbit DriveY_Down at GPIO_PORTB_DATA5_bit;
sbit DriveX_Left_Direction at GPIO_PORTB_DIR4_bit;
sbit DriveX_Right_Direction at GPIO_PORTE_DIR0_bit;
sbit DriveY_Up_Direction at GPIO_PORTE_DIR1_bit;
sbit DriveY_Down_Direction at GPIO_PORTB_DIR5_bit;
// End Touch Panel module connections
if (TP_TFT_Press_Detect()) {
...
}
STM32
|
| 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 |
| Parameters |
|
| Returns |
|
| 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 |
| 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 |
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 |
|
| 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!



