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

External dependencies of Touch Panel Library
Stellaris
The following variables must be defined in all projects using Touch Panel Library: | Description : | Example : |
---|---|---|
extern sfr sbit DriveA; |
DriveA line. | sbit DriveA at GPIO_PORTB_DATA4_bit; |
extern sfr sbit DriveB; |
DriveB line. | sbit DriveB at GPIO_PORTE_DATA0_bit; |
extern sfr sbit DriveA_Direction; |
Direction of the DriveA pin. | sbit DriveA_Direction at GPIO_PORTB_DIR4_bit; |
extern sfr sbit DriveB_Direction; |
Direction of the DriveB pin. | sbit DriveB_Direction at GPIO_PORTE_DIR0_bit; |
MSP432
The following variables must be defined in all projects using Touch Panel Library: | Description : | Example : |
---|---|---|
extern sfr sbit DriveA; |
DriveA line. | sbit DriveA at DIO_P6OUT.B0; |
extern sfr sbit DriveB; |
DriveB line. | sbit DriveB at DIO_P6OUT.B1; |
extern sfr sbit DriveA_Direction; |
Direction of the DriveA pin. | sbit DriveA_Direction at DIO_P6DIR.B0; |
extern sfr sbit DriveB_Direction; |
Direction of the DriveB pin. | sbit DriveB_Direction at DIO_P6DIR.B1; |
STM32
The following variables must be defined in all projects using Touch Panel Library: | Description : | Example : |
---|---|---|
extern sfr sbit DriveA; |
DriveA line. | sbit DriveA at GPIOB_ODR.B1; |
extern sfr sbit DriveB; |
DriveB line. | sbit DriveB at GPIOB_ODR.B0; |
CEC1x02
The following variables must be defined in all projects using Touch Panel Library: | Description : | Example : |
---|---|---|
extern sfr sbit DriveA; |
DriveA line. | sbit DriveA at GPIO_OUTPUT_PIN_047_bit; |
extern sfr sbit DriveB; |
DriveB line. | sbit DriveB at GPIO_OUTPUT_PIN_147_bit; |
Library Routines
- TP_Init
- TP_Set_ADC_Threshold
- TP_Press_Detect
- TP_Get_Coordinates
- TP_Calibrate_Bottom_Left
- TP_Calibrate_Upper_Right
- TP_Get_Calibration_Consts
- TP_Set_Calibration_Consts
TP_Init
Prototype |
void TP_Init(unsigned int display_width, unsigned int display_height, unsigned int readX_ChNo, unsigned int readY_ChNo); |
---|---|
Description |
Initialize touch panel display. Default touch panel ADC threshold value is set to 3900. |
Parameters |
|
Returns |
Nothing. |
Requires |
Before calling this function initialize ADC module. |
Example |
ADC1_Init(); // Initalize ADC module TP_Init(128, 64, 6, 7); // Initialize touch panel, dimensions 128x64 |
Notes |
None. |
TP_Set_ADC_Threshold
Prototype |
void TP_Set_ADC_Threshold(unsigned int threshold); |
---|---|
Description |
Set custom ADC threshold value, call this function after |
Parameters |
|
Returns |
Nothing. |
Requires |
|
Example |
TP_Set_ADC_Threshold(3900); // Set touch panel ADC threshold |
Notes |
None. |
TP_Press_Detect
Prototype |
char TP_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 DriveA at GPIO_PORTB_DATA4_bit; sbit DriveB at GPIO_PORTE_DATA0_bit; sbit DriveA_Direction at GPIO_PORTB_DIR4_bit; sbit DriveB_Direction at GPIO_PORTE_DIR0_bit; // End Touch Panel module connections if (TP_Press_Detect()) { ... } MSP432// Touch Panel module connections sbit DriveA at DIO_P6OUT.B0; sbit DriveB at DIO_P6OUT.B1; sbit DriveA_Direction at DIO_P6DIR.B0; sbit DriveB_Direction at DIO_P6DIR.B1; // End Touch Panel module connections if (TP_Press_Detect()) { ... } STM32// Touch Panel module connections sbit DriveA at GPIOB_ODR.B1; sbit DriveB at GPIOB_ODR.B0; // End Touch Panel module connections if (TP_Press_Detect()) { ... } CEC1x02// Touch Panel module connections sbit DriveA at GPIO_OUTPUT_PIN_047_bit; sbit DriveB at GPIO_OUTPUT_PIN_147_bit; // End Touch Panel module connections if (TP_Press_Detect()) { ... } |
Notes |
None. |
TP_Get_Coordinates
Prototype |
char TP_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_Get_Coordinates(&x_coord, &y_coord) == 0) { ... } |
Notes |
None. |
TP_Calibrate_Bottom_Left
Prototype |
void TP_Calibrate_Bottom_Left(); |
---|---|
Description |
Calibrate bottom left corner of the touch Panel. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TP_Calibrate_Bottom_Left(); // Calibration of bottom left corner |
Notes |
None. |
TP_Calibrate_Upper_Right
Prototype |
void TP_Calibrate_Upper_Right(); |
---|---|
Description |
Calibrate upper right corner of the touch panel. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TP_Calibrate_Upper_Right(); // Calibration of upper right corner |
Notes |
None. |
TP_Get_Calibration_Consts
Prototype |
void TP_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_Get_Calibration_Consts(&x_min, &x_max, &y_min, &y_max); // Get calibration constants |
Notes |
None. |
TP_Set_Calibration_Consts
Prototype |
void TP_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_Set_Calibration_Consts(148, 3590, 519, 3370); // Set calibration constants |
Notes |
None. |
What do you think about this topic ? Send us feedback!