Difference between revisions of "Unit RPIFT5406"

From Ultibo.org
Jump to: navigation, search
 
(13 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
This is the touchscreen driver for the Official Raspberry Pi 7" Touchscreen. While this device uses a FocalTech FT5406 10 point capactive touchscreen controller it is actually connected to the GPU and not directly accessible to the ARM processor.
+
'''Raspberry Pi FT5406 Touch Driver unit'''
+
 
 +
This is the touchscreen driver for the Official Raspberry Pi 7" Touchscreen. While this device uses a FocalTech FT5406 10 point capacitive touchscreen controller it is actually connected to the GPU and not directly accessible to the ARM processor.
 +
 
 
In order to make the touchscreen data available the GPU provides a memory based interface that can be read by polling an address returned from a mailbox call.
 
In order to make the touchscreen data available the GPU provides a memory based interface that can be read by polling an address returned from a mailbox call.
 
   
 
   
 
The Linux driver uses a thread to poll the data approximately 60 times per second so this driver does something similar.
 
The Linux driver uses a thread to poll the data approximately 60 times per second so this driver does something similar.
 +
 +
The display can be rotated to the desired position by adding the display_lcd_rotate setting to the config.txt file as below, please see the official documentation at https://www.raspberrypi.com/documentation/computers/config_txt.html for more details.
 +
 +
 +
No Rotation (Landscape)
 +
display_lcd_rotate=0
 +
 +
Rotate 90 degrees clockwise (Portrait)
 +
display_lcd_rotate=1
 +
 +
Rotate 180 degrees clockwise (Landscape)
 +
display_lcd_rotate=2
 +
 +
Rotate 270 degrees clockwise (Portrait)
 +
display_lcd_rotate=3
 +
 +
 +
To match the rotation of the touchscreen to the rotation of the display you must call the TouchDeviceControl() API function with the TOUCH_CONTROL_SET_ROTATION request and pass the appropriate touch rotation constant in argument1, eg TOUCH_ROTATION_180.
 +
 +
The touch device representing the touchscreen can be found by calling the API function TouchDeviceFindByDescription() with "Raspberry Pi FT5406 Touch Controller" as the value of the description parameter.
 +
 +
The touchscreen rotation values match with the display rotations as follows:
 +
 +
display_lcd_rotate=0 equals TOUCH_ROTATION_0
 +
display_lcd_rotate=1 equals TOUCH_ROTATION_90
 +
display_lcd_rotate=2 equals TOUCH_ROTATION_180
 +
display_lcd_rotate=3 equals TOUCH_ROTATION_270
 +
 +
Note that if you use the alternate lcd_rotate setting instead which uses the inbuilt flip functionality within the LCD then you do not need to set the touchscreen rotation as the LCD/GPU automatically reverse the values reported. The lcd_rotate only allows flipping the screen 180 degrees so only lcd_rotate=0 and lcd_rotate=2 are valid values.
  
 
=== Constants ===
 
=== Constants ===
 
----
 
----
  
''To be documented''
+
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''RPiFT5406 specific constants''' <code> RPIFT5406_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>RPIFT5406_TOUCH_DESCRIPTION = 'Raspberry Pi FT5406 Touch Controller';</code>
 +
| Description of RPiFT5406 Touch device
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>RPIFT5406_THREAD_NAME = 'RPiFT5406 Touch';</code>
 +
| Name of the RPiFT5406 Touch polling thread
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>RPIFT5406_MAX_POINTS = 10;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_MAX_X = $FFF;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_MAX_Y = $FFF;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_MAX_Z = 0;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>RPIFT5406_SCREEN_WIDTH  = 800;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_SCREEN_HEIGHT = 480;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>RPIFT5406_TOUCH_DOWN = 0;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_TOUCH_UP = 1;</code>
 +
| &nbsp;
 +
|-
 +
| <code>RPIFT5406_TOUCH_CONTACT = 2;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''RPiFT5406 touch point'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRPiFT5406TouchPoint = ^TRPiFT5406TouchPoint;</code>
 +
 
 +
<code>TRPiFT5406TouchPoint = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>xh:Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>xl:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>yh:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>yl:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>res1:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>res2:Byte;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''RPiFT5406 registers'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRPiFT5406Registers = ^TRPiFT5406Registers;</code>
 +
 
 +
<code>TRPiFT5406Registers = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>DeviceMode:Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>GestureId:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>NumPoints:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Point:array[0..RPIFT5406_MAX_POINTS - 1] of TRPiFT5406TouchPoint;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''RPiFT5406 touch'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRPiFT5406Touch = ^TRPiFT5406Touch;</code>
 +
 
 +
<code>TRPiFT5406Touch = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Touch Properties''
 +
|-
 +
| <code>Touch:TTouchDevice;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|''General Properties''
 +
|-
 +
| <code>MaxX:Word;</code>
 +
| Maximum X value for this device
 +
|-
 +
| <code>MaxY:Word;</code>
 +
| Maximum Y value for this device
 +
|-
 +
| <code>MaxZ:Word;</code>
 +
| Maximum Z value for this device
 +
|-
 +
| <code>Width:Word;</code>
 +
| Screen width for this device
 +
|-
 +
| <code>Height:Word;</code>
 +
| Screen height for this device
 +
|-
 +
| <code>MaxPoints:LongWord;</code>
 +
| Maximum touch points for this device
 +
|-
 +
|colspan="2"|''RPiFT5406 Properties''
 +
|-
 +
| <code>Thread:TThreadHandle;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Terminate:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Registers:PRPiFT5406Registers;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
''None defined''
  
 
=== Function declarations ===
 
=== Function declarations ===
Line 38: Line 220:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Called only during system startup
 
| Called only during system startup
 
|-
 
|-
Line 53: Line 235:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use TouchDeviceStart instead
+
| Not intended to be called directly by applications, use TouchDeviceStart instead.
 
|-
 
|-
 
|}
 
|}
Line 65: Line 247:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use TouchDeviceStop instead
+
| Not intended to be called directly by applications, use TouchDeviceStop instead.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function RPiFT5406TouchUpdate(Touch:PTouchDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of TouchDeviceUpdate API for RPiFT5406 Touch device</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| Not intended to be called directly by applications, use TouchDeviceUpdate instead.
 
|-
 
|-
 
|}
 
|}
Line 77: Line 271:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 
|-
 
|-

Latest revision as of 05:33, 13 September 2022

Return to Unit Reference


Description


Raspberry Pi FT5406 Touch Driver unit

This is the touchscreen driver for the Official Raspberry Pi 7" Touchscreen. While this device uses a FocalTech FT5406 10 point capacitive touchscreen controller it is actually connected to the GPU and not directly accessible to the ARM processor.

In order to make the touchscreen data available the GPU provides a memory based interface that can be read by polling an address returned from a mailbox call.

The Linux driver uses a thread to poll the data approximately 60 times per second so this driver does something similar.

The display can be rotated to the desired position by adding the display_lcd_rotate setting to the config.txt file as below, please see the official documentation at https://www.raspberrypi.com/documentation/computers/config_txt.html for more details.


No Rotation (Landscape)

display_lcd_rotate=0

Rotate 90 degrees clockwise (Portrait)

display_lcd_rotate=1

Rotate 180 degrees clockwise (Landscape)

display_lcd_rotate=2

Rotate 270 degrees clockwise (Portrait)

display_lcd_rotate=3


To match the rotation of the touchscreen to the rotation of the display you must call the TouchDeviceControl() API function with the TOUCH_CONTROL_SET_ROTATION request and pass the appropriate touch rotation constant in argument1, eg TOUCH_ROTATION_180.

The touch device representing the touchscreen can be found by calling the API function TouchDeviceFindByDescription() with "Raspberry Pi FT5406 Touch Controller" as the value of the description parameter.

The touchscreen rotation values match with the display rotations as follows:

display_lcd_rotate=0 equals TOUCH_ROTATION_0
display_lcd_rotate=1 equals TOUCH_ROTATION_90
display_lcd_rotate=2 equals TOUCH_ROTATION_180
display_lcd_rotate=3 equals TOUCH_ROTATION_270

Note that if you use the alternate lcd_rotate setting instead which uses the inbuilt flip functionality within the LCD then you do not need to set the touchscreen rotation as the LCD/GPU automatically reverse the values reported. The lcd_rotate only allows flipping the screen 180 degrees so only lcd_rotate=0 and lcd_rotate=2 are valid values.

Constants



RPiFT5406 specific constants RPIFT5406_*
RPIFT5406_TOUCH_DESCRIPTION = 'Raspberry Pi FT5406 Touch Controller'; Description of RPiFT5406 Touch device
 
RPIFT5406_THREAD_NAME = 'RPiFT5406 Touch'; Name of the RPiFT5406 Touch polling thread
 
RPIFT5406_MAX_POINTS = 10;  
RPIFT5406_MAX_X = $FFF;  
RPIFT5406_MAX_Y = $FFF;  
RPIFT5406_MAX_Z = 0;  
 
RPIFT5406_SCREEN_WIDTH = 800;  
RPIFT5406_SCREEN_HEIGHT = 480;  
 
RPIFT5406_TOUCH_DOWN = 0;  
RPIFT5406_TOUCH_UP = 1;  
RPIFT5406_TOUCH_CONTACT = 2;  


Type definitions



RPiFT5406 touch point

PRPiFT5406TouchPoint = ^TRPiFT5406TouchPoint;

TRPiFT5406TouchPoint = record

xh:Byte;  
xl:Byte;  
yh:Byte;  
yl:Byte;  
res1:Byte;  
res2:Byte;  

RPiFT5406 registers

PRPiFT5406Registers = ^TRPiFT5406Registers;

TRPiFT5406Registers = record

DeviceMode:Byte;  
GestureId:Byte;  
NumPoints:Byte;  
Point:array[0..RPIFT5406_MAX_POINTS - 1] of TRPiFT5406TouchPoint;  

RPiFT5406 touch

PRPiFT5406Touch = ^TRPiFT5406Touch;

TRPiFT5406Touch = record

Touch Properties
Touch:TTouchDevice;  
General Properties
MaxX:Word; Maximum X value for this device
MaxY:Word; Maximum Y value for this device
MaxZ:Word; Maximum Z value for this device
Width:Word; Screen width for this device
Height:Word; Screen height for this device
MaxPoints:LongWord; Maximum touch points for this device
RPiFT5406 Properties
Thread:TThreadHandle;  
Terminate:Boolean;  
Registers:PRPiFT5406Registers;  


Public variables


None defined

Function declarations



Initialization functions

procedure RPiFT5406Init;
Description: Initialize the RPiFT5406 unit and create, register and start the device
Note Called only during system startup


RPiFT5406 touch functions

function RPiFT5406TouchStart(Touch:PTouchDevice):LongWord;
Description: Implementation of TouchDeviceStart API for RPiFT5406
Note Not intended to be called directly by applications, use TouchDeviceStart instead.


function RPiFT5406TouchStop(Touch:PTouchDevice):LongWord;
Description: Implementation of TouchDeviceStop API for RPiFT5406
Note Not intended to be called directly by applications, use TouchDeviceStop instead.


function RPiFT5406TouchUpdate(Touch:PTouchDevice):LongWord;
Description: Implementation of TouchDeviceUpdate API for RPiFT5406 Touch device
Note Not intended to be called directly by applications, use TouchDeviceUpdate instead.


function RPiFT5406TouchExecute(Touch:PRPiFT5406Touch):PtrInt;
Description: Thread function for the RPiFT5406 Touch controller driver. The thread polls the memory touch buffer approximately 60 times per second for new touch data and inserts received touch points into the buffer of the passed device
Note Not intended to be called directly by applications


Return to Unit Reference