TSC2006 Touch Panel Library
The mikroPascal PRO for ARM provides a library for working with TSC2006 Touch Panel controller.
External dependencies of TSC2006 Touch Panel Library
The following variables must be defined in all projects using Touch Panel TSC2006 Library: | Description : | Example : |
---|---|---|
var TSC2006_CS : sbit; sfr; external; |
Chip Select line. | var TSC2006_CS : sbit at GPIO_PORTB_DATA4_bit; |
var TSC2006_RST : sbit; sfr; external; |
Reset line. | var TSC2006_RST : sbit at GPIO_PORTE_DATA0_bit; |
var TSC2006_CS_Direction : sbit; sfr; external; |
Direction of the Chip Select pin. | var TSC2006_CS_Direction : sbit at GPIO_PORTB_DIR4_bit; |
var TSC2006_RST_Direction : sbit; sfr; external; |
Direction of the Reset pin. | var TSC2006_RST_Direction : sbit at GPIO_PORTE_DIR0_bit; |
Library Routines
- TSC2006_Init
- TSC2006_Reset
- TSC2006_CalibratePoint
- TSC2006_SetCalibrationConsts
- TSC2006_GetCalibrationConsts
- TSC2006_PressDetect
- TSC2006_GetCoordinates
- TSC2006_SetDisplaySize
- TSC2006_SetDefaultMode
- TSC2006_SetTouchPressureThreshold
- TSC2006_Rotate180
- TSC2006_SetTPRotation
- TSC2006_GetTPRotation
- TSC2006_ReadCB0
- TSC2006_WriteCB0
- TSC2006_WriteCB1
TSC2006_Init
Prototype |
function TSC2006_Init() : byte; |
---|---|
Description |
Initialize the TSC2006 touch panel controller. |
Parameters |
None. |
Returns |
|
Requires |
External dependencies of the library from the top of the page must be defined before using this function. The appropriate hardware SPI module must be previously initialized.
|
Example |
var TSC2006_CS : sbit at GPIO_PORTB_DATA4_bit; var TSC2006_RST : sbit at GPIO_PORTE_DATA0_bit; var TSC2006_CS_Direction : sbit at GPIO_PORTB_DIR4_bit var TSC2006_RST_Direction : sbit at GPIO_PORTE_DIR0_bit; ... SPI1_Init(); TSC2006_Init(;) |
Notes |
None. |
TSC2006_Reset
Prototype |
procedure TSC2006_Reset(); |
---|---|
Description |
This function performs hardware reset of the TSC2006 touch panel controller. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_Reset(); |
Notes |
None. |
TSC2006_CalibratePoint
Prototype |
procedure TSC2006_CalibratePoint(dispCorner : byte); |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function performs calibration of a corner point displayed on the screen. |
||||||||||
Parameters |
|
||||||||||
Returns |
Nothing. |
||||||||||
Requires |
Nothing. |
||||||||||
Example |
TSC2006_CalibratePoint(_TSC2006_DISP_0_0); |
||||||||||
Notes |
All four corner points should be calibrated, starting from the (0,0) up to the (0,YMAX). |
TSC2006_PressDetect
Prototype |
function TSC2006_PressDetect() : byte; |
---|---|
Description |
Detects if there is a change on the X and Y axis. |
Parameters |
None. |
Returns |
|
Requires |
Nothing. |
Example |
if (TSC2006_PressDetect() = 1) then ... |
Notes |
None. |
TSC2006_SetCalibrationConsts
Prototype |
procedure TSC2006_SetCalibrationConsts(xMin, xMax, yMin, yMax : word); |
---|---|
Description |
Sets calibration constants. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetCalibrationConsts(148, 3590, 519, 3370); // Set calibration constants |
Notes |
None. |
TSC2006_GetCalibrationConsts
Prototype |
procedure TSC2006_GetCalibrationConsts(xMin, xMax, yMin, yMax : ^word); |
---|---|
Description |
Gets calibration constants after calibration is done and stores them in |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_GetCalibrationConsts(@x_min, @x_max, @y_min, @y_max); // Get calibration constants |
Notes |
None. |
TSC2006_GetCoordinates
Prototype |
function TSC2006_GetCoordinates(xCoord, yCoord : ^word) : byte; |
---|---|
Description |
Get touch panel coordinates and store them in |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
if (TSC2006_GetCoordinates(@xCoord, @yCoord) = 0) then ... |
Notes |
None. |
TSC2006_SetDisplaySize
Prototype |
procedure TSC2006_SetDisplaySize(width, height : word); |
---|---|
Description |
Sets the display size. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetDisplaySize(320, 240); |
Notes |
None. |
TSC2006_SetDefaultMode
Prototype |
procedure TSC2006_SetDefaultMode(); |
---|---|
Description |
Sets the touch panel in default mode (threshold set to 6000, 0 degrees rotation). |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetDefaultMode(); |
Notes |
None. |
TSC2006_SetTouchPressureThreshold
Prototype |
procedure TSC2006_SetTouchPressureThreshold(threshold : word); |
---|---|
Description |
Sets the touch panel pressure threshold value. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetTouchPressureThreshold(6000); |
Notes |
None. |
TSC2006_Rotate180
Prototype |
procedure TSC2006_Rotate180(); |
---|---|
Description |
Rotates the touch panel by 180 degrees. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_Rotate180(); |
Notes |
None. |
TSC2006_SetTPRotation
Prototype |
procedure TSC2006_SetTPRotation(rotation : byte); |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Rotates the touch panel clockwise by a given parameter angle. |
||||||||||
Parameters |
|
||||||||||
Returns |
Nothing. |
||||||||||
Requires |
Nothing. |
||||||||||
Example |
TSC2006_SetTPRotation(_TSC2006_ROTATE_180); |
||||||||||
Notes |
None. |
TSC2006_GetTPRotation
Prototype |
function TSC2006_GetTPRotation() : byte; |
---|---|
Description |
Gets the angle by which the touch panel is rotated. |
Parameters |
None. |
Returns |
|
Requires |
Nothing. |
Example |
rotation_angle := TSC2006_GetTPRotation(); |
Notes |
None. |
TSC2006_ReadCB0
Prototype |
function TSC2006_ReadCB0(cb0 : byte) : word; |
---|---|
Description |
Reads the value stored in touch panel controller register using the control byte 0 command format (read data registers and non-conversion-related controls). |
Parameters |
|
Returns |
Value stored in register. |
Requires |
Nothing. |
Example |
read_value := TSC2006_ReadCB0(cb0); |
Notes |
None. |
TSC2006_WriteCB0
Prototype |
procedure TSC2006_WriteCB0(cb0 : byte; value : word); |
---|---|
Description |
Stores the value in touch panel controller register using the control byte 0 command format (write data registers and non-conversion-related controls). |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_WriteCB0(cb0, value); |
Notes |
None. |
TSC2006_WriteCB1
Prototype |
procedure TSC2006_WriteCB1(cb1 : byte); |
---|---|
Description |
Stores the value in touch panel controller register using the control byte 1 command format (start conversion and channel select and conversion-related configuration). |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_WriteCB1(cb1, value); |
Notes |
None. |