Difference between revisions of "Component: Touch Screen (XPT2046) (Graphical Library)"

From Flowcode Help
Jump to navigationJump to search
 
(8 intermediate revisions by one other user not shown)
Line 16: Line 16:
  
 
==Component Source Code==
 
==Component Source Code==
 +
 +
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_TouchScreen_XPT2046.fcfx FC_Comp_Source_TouchScreen_XPT2046.fcfx]
  
 
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_TouchScreen_XPT2046.fcfx FC_Comp_Source_TouchScreen_XPT2046.fcfx]
 
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_TouchScreen_XPT2046.fcfx FC_Comp_Source_TouchScreen_XPT2046.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
  
  
Line 42: Line 50:
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
  
  
Line 64: Line 78:
 
Example using the XPT2046 touchscreen driver IC with a 4.3" TFT Display using the SSD1963 Graphical LCD Controller.
 
Example using the XPT2046 touchscreen driver IC with a 4.3" TFT Display using the SSD1963 Graphical LCD Controller.
 
{{Fcfile|GLCD4.3_Touch.fcfx|GLCD 4.3 Touch}}
 
{{Fcfile|GLCD4.3_Touch.fcfx|GLCD 4.3 Touch}}
 +
 
Example using the XPT2046 touchscreen driver IC with a 7" TFT Display using the SSD1963 Graphical LCD Controller.
 
Example using the XPT2046 touchscreen driver IC with a 7" TFT Display using the SSD1963 Graphical LCD Controller.
 
{{Fcfile|GLCD7_Touch.fcfx|GLCD 7 Touch}}
 
{{Fcfile|GLCD7_Touch.fcfx|GLCD 7 Touch}}
Line 69: Line 84:
 
==Macro reference==
 
==Macro reference==
  
 +
===Initialise===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SampleSensor'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
|-
| colspan="2" | 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 
+
| colspan="2" | Activates the SPI peripheral and claims control over the I/O pins. 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===ReadCoord===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 100: Line 117:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===SampleSensor===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
| colspan="2" | Activates the SPI peripheral and claims control over the I/O pins. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
 
 
 
==Property reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | LinkTo
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Bus Settings
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
 
|-
 
| colspan="2" | SPI Channel selector 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Prescale
 
|-
 
| colspan="2" | Prescale option selector 
 
|-
 
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | MOSI
 
|-
 
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | MISO
 
|-
 
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | CLK
 
|-
 
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | CS / SS
 
|-
 
| colspan="2" | 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.  
 
|-
 
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Configuration
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Analogue Mode
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
| width="90%" | X Pixel
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
| width="90%" | Y Pixel
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Flip X
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Flip Y
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 
| width="90%" | Label
 
|-
 
| colspan="2" | Label used to identify the component on the panel. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Enable Interrupt
 
|-
 
| colspan="2" | Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-22-icon.png]]
 
| width="90%" | Interrupt Macro
 
|-
 
| colspan="2" | Macro called when the simulated display fires an interrupt. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Simulate Comms
 
|-
 
| colspan="2" | Allows the SPI communications to be simulated and piped through an API to real world hardware. 
 
|}==Macro reference==
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 231: Line 129:
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoord'''
 
|-
 
| colspan="2" | Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Coordinate
 
|-
 
| colspan="2" | 0 = X, 1 = Y, 2 = Pressure 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
| colspan="2" | Activates the SPI peripheral and claims control over the I/O pins. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
  
  

Latest revision as of 08:55, 19 January 2024

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. FC6 Icon.png GLCD 4.3 Touch

Example using the XPT2046 touchscreen driver IC with a 7" TFT Display using the SSD1963 Graphical LCD Controller. FC6 Icon.png GLCD 7 Touch

Macro reference

Initialise

Fc9-comp-macro.png Initialise
Activates the SPI peripheral and claims control over the I/O pins. 
Fc9-void-icon.png - VOID Return


ReadCoord

Fc9-comp-macro.png ReadCoord
Reads a coordinate returned from the Sample Sensor macro. Coordinate is scaled to the X/Y Pixel bounds specified. 
Fc9-u8-icon.png - BYTE Coordinate
0 = X, 1 = Y, 2 = Pressure 
Fc9-u16-icon.png - UINT Return


SampleSensor

Fc9-comp-macro.png 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 
Fc9-u8-icon.png - BYTE Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png LinkTo
 
Fc9-conn-icon.png Bus Settings
Fc9-type-16-icon.png Channel
SPI Channel selector 
Fc9-type-16-icon.png Prescale
Prescale option selector 
Fc9-conn-icon.png Connections
Fc9-type-5-icon.png MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
Fc9-type-5-icon.png MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
Fc9-type-5-icon.png CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
Fc9-type-5-icon.png 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.  
Fc9-conn-icon.png Configuration
Fc9-type-16-icon.png Analogue Mode
 
Fc9-type-21-icon.png X Pixel
 
Fc9-type-21-icon.png Y Pixel
 
Fc9-type-7-icon.png Flip X
 
Fc9-type-7-icon.png Flip Y
 
Fc9-conn-icon.png Simulation
Fc9-type-10-icon.png Label
Label used to identify the component on the panel. 
Fc9-type-7-icon.png Enable Interrupt
Allows the simulated display to fire an interrupt to allow you to action inputs as they happen. 
Fc9-type-22-icon.png Interrupt Macro
Macro called when the simulated display fires an interrupt. 
Fc9-type-7-icon.png Simulate Comms
Allows the SPI communications to be simulated and piped through an API to real world hardware.