| Author
 | 
Matrix Ltd
 | 
| Version
 | 
2.0
 | 
| Category
 | 
Graphical Library
 | 
Touch Screen (XPT2046) component
Low level routines for controlling or interacting with the XPT2046 touch screen controller IC found on a lot of common low cost resistive touch screen products.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_TouchScreen_XPT2046.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_TouchScreen_XPT2046.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Example using the XPT2046 touchscreen driver IC with a 4.3" TFT Display using the SSD1963 Graphical LCD Controller.
GLCD 4.3 Touch
Example using the XPT2046 touchscreen driver IC with a 7" TFT Display using the SSD1963 Graphical LCD Controller.
GLCD 7 Touch
Macro reference
 
 | 
SampleSensor
 | 
| Reads the touch controller and returns true if there is currently a touch in progress. The touch coordinates can be read using the ReadCoord macro. Return 0 = No Touch, 1 = Touch in progress 
 | 
  - BYTE
 | 
Return
 | 
 
 | 
ReadCoord
 | 
| Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
 | 
  - BYTE
 | 
Coordinate
 | 
| 0 = X, 1 = Y, 2 = Pressure 
 | 
  - UINT
 | 
Return
 | 
 
 | 
Initialise
 | 
| Activates the SPI peripheral and claims control over the I/O pins. 
 | 
  - VOID
 | 
Return
 | 
Property reference
 
 | 
Properties
 | 
 
 | 
LinkTo
 | 
|  
 | 
 
 | 
Bus Settings
 | 
 
 | 
Channel
 | 
| SPI Channel selector 
 | 
 
 | 
Prescale
 | 
| Prescale option selector 
 | 
 
 | 
Connections
 | 
 
 | 
MOSI
 | 
| SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
 | 
 
 | 
MISO
 | 
| SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
 | 
 
 | 
CLK
 | 
| SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
 | 
 
 | 
CS / SS
 | 
| Chip Select / Slave Select Pin  Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
 | 
 
 | 
Configuration
 | 
 
 | 
Analogue Mode
 | 
|  
 | 
 
 | 
X Pixel
 | 
|  
 | 
 
 | 
Y Pixel
 | 
|  
 | 
 
 | 
Flip X
 | 
|  
 | 
 
 | 
Flip Y
 | 
|  
 | 
 
 | 
Simulation
 | 
 
 | 
Label
 | 
| Label used to identify the component on the panel. 
 | 
 
 | 
Enable Interrupt
 | 
| Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
 | 
 
 | 
Interrupt Macro
 | 
| Macro called when the simulated display fires an interrupt. 
 | 
 
 | 
Simulate Comms
 | 
| Allows the SPI communications to be simulated and piped through an API to real world hardware. 
 | 
==Macro reference==
 
 | 
SampleSensor
 | 
| Reads the touch controller and returns true if there is currently a touch in progress. The touch coordinates can be read using the ReadCoord macro. Return 0 = No Touch, 1 = Touch in progress 
 | 
  - BYTE
 | 
Return
 | 
 
 | 
ReadCoord
 | 
| Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
 | 
  - BYTE
 | 
Coordinate
 | 
| 0 = X, 1 = Y, 2 = Pressure 
 | 
  - UINT
 | 
Return
 | 
 
 | 
Initialise
 | 
| Activates the SPI peripheral and claims control over the I/O pins. 
 | 
  - VOID
 | 
Return
 | 
Property reference
 
 | 
Properties
 | 
 
 | 
LinkTo
 | 
|  
 | 
 
 | 
Bus Settings
 | 
 
 | 
Channel
 | 
| SPI Channel selector 
 | 
 
 | 
Prescale
 | 
| Prescale option selector 
 | 
 
 | 
Connections
 | 
 
 | 
MOSI
 | 
| SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
 | 
 
 | 
MISO
 | 
| SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
 | 
 
 | 
CLK
 | 
| SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
 | 
 
 | 
CS / SS
 | 
| Chip Select / Slave Select Pin  Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
 | 
 
 | 
Configuration
 | 
 
 | 
Analogue Mode
 | 
|  
 | 
 
 | 
X Pixel
 | 
|  
 | 
 
 | 
Y Pixel
 | 
|  
 | 
 
 | 
Flip X
 | 
|  
 | 
 
 | 
Flip Y
 | 
|  
 | 
 
 | 
Simulation
 | 
 
 | 
Label
 | 
| Label used to identify the component on the panel. 
 | 
 
 | 
Enable Interrupt
 | 
| Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
 | 
 
 | 
Interrupt Macro
 | 
| Macro called when the simulated display fires an interrupt. 
 | 
 
 | 
Simulate Comms
 | 
| Allows the SPI communications to be simulated and piped through an API to real world hardware. 
 | 
==Macro reference==
 
 | 
SampleSensor
 | 
| Reads the touch controller and returns true if there is currently a touch in progress. The touch coordinates can be read using the ReadCoord macro. Return 0 = No Touch, 1 = Touch in progress 
 | 
  - BYTE
 | 
Return
 | 
 
 | 
ReadCoord
 | 
| Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
 | 
  - BYTE
 | 
Coordinate
 | 
| 0 = X, 1 = Y, 2 = Pressure 
 | 
  - UINT
 | 
Return
 | 
 
 | 
Initialise
 | 
| Activates the SPI peripheral and claims control over the I/O pins. 
 | 
  - VOID
 | 
Return
 | 
Property reference
 
 | 
Properties
 | 
 
 | 
LinkTo
 | 
|  
 | 
 
 | 
Bus Settings
 | 
 
 | 
Channel
 | 
| SPI Channel selector 
 | 
 
 | 
Prescale
 | 
| Prescale option selector 
 | 
 
 | 
Connections
 | 
 
 | 
MOSI
 | 
| SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
 | 
 
 | 
MISO
 | 
| SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
 | 
 
 | 
CLK
 | 
| SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
 | 
 
 | 
CS / SS
 | 
| Chip Select / Slave Select Pin  Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
 | 
 
 | 
Configuration
 | 
 
 | 
Analogue Mode
 | 
|  
 | 
 
 | 
X Pixel
 | 
|  
 | 
 
 | 
Y Pixel
 | 
|  
 | 
 
 | 
Flip X
 | 
|  
 | 
 
 | 
Flip Y
 | 
|  
 | 
 
 | 
Simulation
 | 
 
 | 
Label
 | 
| Label used to identify the component on the panel. 
 | 
 
 | 
Enable Interrupt
 | 
| Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
 | 
 
 | 
Interrupt Macro
 | 
| Macro called when the simulated display fires an interrupt. 
 | 
 
 | 
Simulate Comms
 | 
| Allows the SPI communications to be simulated and piped through an API to real world hardware. 
 | 
==Macro reference==
 
 | 
SampleSensor
 | 
| Reads the touch controller and returns true if there is currently a touch in progress. The touch coordinates can be read using the ReadCoord macro. Return 0 = No Touch, 1 = Touch in progress 
 | 
  - BYTE
 | 
Return
 | 
 
 | 
ReadCoord
 | 
| Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
 | 
  - BYTE
 | 
Coordinate
 | 
| 0 = X, 1 = Y, 2 = Pressure 
 | 
  - UINT
 | 
Return
 | 
 
 | 
Initialise
 | 
| Activates the SPI peripheral and claims control over the I/O pins. 
 | 
  - VOID
 | 
Return
 | 
Property reference
 
 | 
Properties
 | 
 
 | 
LinkTo
 | 
|  
 | 
 
 | 
Bus Settings
 | 
 
 | 
Channel
 | 
| SPI Channel selector 
 | 
 
 | 
Prescale
 | 
| Prescale option selector 
 | 
 
 | 
Connections
 | 
 
 | 
MOSI
 | 
| SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
 | 
 
 | 
MISO
 | 
| SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
 | 
 
 | 
CLK
 | 
| SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
 | 
 
 | 
CS / SS
 | 
| Chip Select / Slave Select Pin  Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
 | 
 
 | 
Configuration
 | 
 
 | 
Analogue Mode
 | 
|  
 | 
 
 | 
X Pixel
 | 
|  
 | 
 
 | 
Y Pixel
 | 
|  
 | 
 
 | 
Flip X
 | 
|  
 | 
 
 | 
Flip Y
 | 
|  
 | 
 
 | 
Simulation
 | 
 
 | 
Label
 | 
| Label used to identify the component on the panel. 
 | 
 
 | 
Enable Interrupt
 | 
| Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
 | 
 
 | 
Interrupt Macro
 | 
| Macro called when the simulated display fires an interrupt. 
 | 
 
 | 
Simulate Comms
 | 
| Allows the SPI communications to be simulated and piped through an API to real world hardware. 
 |