Touch Panel TFT Library
The mikroBasic PRO for PIC provides a library for working with Touch Panel for 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 : |
---|---|---|
dim DriveX_Left as sbit sfr external |
DriveX_Left line. | dim DriveX_Left as sbit at LATA0_bit |
dim DriveX_Right as sbit sfr external |
DriveX_Right line. | dim DriveX_Right as sbit at LATA1_bit |
dim DriveY_Up as sbit sfr external |
DriveY_Up line. | dim DriveY_Up as sbit at LATA2_bit |
dim DriveY_Down as sbit sfr external |
DriveY_Down line. | dim DriveY_Down as sbit at LATA3_bit |
dim DriveX_Left_Direction as sbit sfr external |
Direction of the DriveA pin. | dim DriveX_Left_Direction as sbit at TRISA0_bit |
dim DriveX_Right_Direction as sbit sfr external |
Direction of the DriveB pin. | dim DriveX_Right_Direction as sbit at TRISA1_bit |
dim DriveY_Up_Direction as sbit sfr external |
Direction of the DriveA pin. | dim DriveY_Up_Direction as sbit at TRISA2_bit |
dim DriveY_Down_Direction as sbit sfr external |
Direction of the DriveB pin. | dim DriveY_Down_Direction as sbit at TRISA3_bit |
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 |
sub procedure TP_TFT_Inits(dim display_width as word, dim display_height as word, dim readX_ChNo as byte, dim readY_ChNo as 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, dimensions 320x240 |
TP_TFT_Rotate
Prototype |
sub procedure TP_TFT_Rotate(dim rotate as 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 |
sub procedure TP_TFT_Set_ADC_Threshold(dim threshold as 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 |
sub function TP_TFT_Press_Detect() as byte |
---|---|
Description |
Detects if the touch panel has been pressed. |
Parameters |
None. |
Returns |
|
Requires |
Global variables :
|
Example |
' Touch Panel module connections dim DriveX_Left as sbit at LATA0_bit DriveX_Right as sbit at LATA1_bit DriveY_Up as sbit at LATA2_bit DriveY_Down as sbit at LATA3_bit DriveX_Left_Direction as sbit at TRISA0_bit DriveX_Right_Direction as sbit at TRISA1_bit DriveY_Up_Direction as sbit at TRISA2_bit DriveY_Down_Direction as sbit at TRISA3_bit ' End Touch Panel module connections if (TP_TFT_Press_Detect() <> 0) then ... end if |
Notes |
None. |
TP_TFT_Get_Coordinates
Prototype |
sub function TP_TFT_Get_Coordinates(dim byref x_coordinate as word, dim byref y_coordinate as word) as 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 ... end if |
Notes |
None. |
TP_TFT_Calibrate_Min
Prototype |
sub 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 |
sub 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 |
sub procedure TP_TFT_Get_Calibration_Consts(dim byref x_min as word, dim byref x_max as word, dim byref y_min as word, dim byref y_max as 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 |
sub procedure TP_TFT_Set_Calibration_Consts(dim x_min as word, dim x_max as word, dim y_min as word, dim y_max as word) |
---|---|
Description |
Sets calibration constants. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TP_TFT_Set_Calibration_Consts(148, 3590, 519, 3370) ' Set calibration constants |
Notes |
None. |
HW Connection
Touch Panel TFT HW connection
What do you think about this topic ? Send us feedback!