TSC2006 Touch Panel Library
The mikroC 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 : |
---|---|---|
extern sfr sbit TSC2006_CS; |
Chip Select line. | sbit TSC2006_CS at GPIO_PORTB_DATA4_bit; |
extern sfr sbit TSC2006_RST; |
Reset line. | sbit DriveB at TSC2006_RST; |
extern sfr sbit TSC2006_CS_Direction; |
Direction of the Chip Select pin. | sbit TSC2006_CS_Direction at GPIO_PORTB_DIR4_bit; |
extern sfr sbit TSC2006_RST_Direction; |
Direction of the Reset pin. | sbit TSC2006_RST_Direction 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 |
uint8_t TSC2006_Init(); |
---|---|
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 |
sbit TSC2006_CS at GPIO_PORTB_DATA4_bit; sbit TSC2006_RST at GPIO_PORTE_DATA0_bit; sbit TSC2006_CS_Direction at GPIO_PORTB_DIR4_bit sbit TSC2006_RST_Direction at GPIO_PORTE_DIR0_bit; ... SPI1_Init(); TSC2006_Init(;) |
Notes |
None. |
TSC2006_Reset
Prototype |
void 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 |
void TSC2006_CalibratePoint(uint8_t dispCorner); |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 |
uint8_t TSC2006_PressDetect(); |
---|---|
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 |
void TSC2006_SetCalibrationConsts(uint16_t xMin, uint16_t xMax, uint16_t yMin, uint16_t yMax); |
---|---|
Description |
Sets calibration constants. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetCalibrationConsts(148, 3590, 519, 3370); // Set calibration constants |
Notes |
None. |
TSC2006_GetCalibrationConsts
Prototype |
void TSC2006_GetCalibrationConsts(uint16_t *xMin, uint16_t *xMax, uint16_t *yMin, uint16_t *yMax); |
---|---|
Description |
Gets calibration constants after calibration is done and stores them in |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_GetCalibrationConsts(&x_min, &y_min, &x_max, &y_max); // Get calibration constants |
Notes |
None. |
TSC2006_GetCoordinates
Prototype |
char TSC2006_GetCoordinates(uint16_t *xCoord, uint16_t *yCoord); |
---|---|
Description |
Get touch panel coordinates and store them in |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
if (TSC2006_GetCoordinates(&xCoord, &yCoord) == 0) { ... } |
Notes |
None. |
TSC2006_SetDisplaySize
Prototype |
void TSC2006_SetDisplaySize(uint16_t width, uint16_t height); |
---|---|
Description |
Sets the display size. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetDisplaySize(320, 240); |
Notes |
None. |
TSC2006_SetDefaultMode
Prototype |
void 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 |
void TSC2006_SetTouchPressureThreshold(uint16_t threshold); |
---|---|
Description |
Sets the touch panel pressure threshold value. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_SetTouchPressureThreshold(6000); |
Notes |
None. |
TSC2006_Rotate180
Prototype |
void TSC2006_Rotate180(); |
---|---|
Description |
Rotates the touch panel by 180 degrees. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
TSC2006_Rotate180(); |
Notes |
None. |
TSC2006_SetTPRotation
Prototype |
void TSC2006_SetTPRotation(uint8_t rotation); |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 |
uint8_t TSC2006_GetTPRotation(); |
---|---|
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 |
uint16_t TSC2006_ReadCB0(uint8_t cb0); |
---|---|
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 |
void TSC2006_WriteCB0(uint8_t cb0, uint16_t value); |
---|---|
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 |
void TSC2006_WriteCB1(uint8_t cb1); |
---|---|
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. |
What do you think about this topic ? Send us feedback!