Difference between revisions of "Unit TFT Framebuffer"

From Ultibo.org
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo TFT Framebuffer driver library unit'''
+
'''Ultibo TFT Framebuffer Driver Library unit'''
  
 
This is a generic framebuffer device support unit for SPI based TFT screens using common chipsets.
 
This is a generic framebuffer device support unit for SPI based TFT screens using common chipsets.
 
   
 
   
This unit implements the shared functionality that is common to all devices and provides a set of functions that device specific drivers must implement. For each supported device a driver unit is
+
This unit implements the shared functionality that is common to all devices and provides a set of functions that device specific drivers must implement. For each supported device a driver unit is required that implements the SPI communications to initialize the device, setup resolution and color depth as well as refreshing the framebuffer data to the device memory on change.
required that implements the SPI communications to initialize the device, setup resolution and color depth as well as refreshing the framebuffer data to the device memory on change.
+
 
    
 
    
 
The resulting device created by the combination of this unit and a device specific driver is registered with Ultibo as a framebuffer device that can be accessed using all of the standard framebuffer API functions.
 
The resulting device created by the combination of this unit and a device specific driver is registered with Ultibo as a framebuffer device that can be accessed using all of the standard framebuffer API functions.
Line 21: Line 20:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''TFTFramebuffer specific constants''' <code> TFT_FRAMEBUFFER_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''TFT framebuffer specific constants''' <code> TFT_FRAMEBUFFER_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 35: Line 34:
 
----
 
----
  
''To be documented''
+
 
 +
'''TFT framebuffer initialize'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTFTFramebufferInitialize = function(Framebuffer:PTFTFramebuffer; Defaults:PFramebufferProperties):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TFT framebuffer deinitialize'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTFTFramebufferDeinitialize = function(Framebuffer:PTFTFramebuffer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TFT framebuffer get defaults'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTFTFramebufferGetDefaults = function(Framebuffer:PTFTFramebuffer; Properties,Defaults:PFramebufferProperties):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TFT framebuffer set write address'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTFTFramebufferSetWriteAddress = function(Framebuffer:PTFTFramebuffer; X1,Y1,X2,Y2:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TFT framebuffer write memory'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTFTFramebufferWriteMemory = function(Framebuffer:PTFTFramebuffer; Address:PtrUInt; Size:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TFT framebuffer device'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTFTFramebuffer = ^TTFTFramebuffer;</code>
 +
 
 +
<code>TTFTFramebuffer = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Framebuffer Properties''
 +
|-
 +
| <code>Framebuffer:TFramebufferDevice;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''TFT Properties''
 +
|-
 +
| <code>SPI:PSPIDevice;</code>
 +
| The SPI device this Framebuffer is connected to
 +
|-
 +
| <code>ChipSelect:Word;</code>
 +
| The SPI chip select of the device
 +
|-
 +
| <code>RST:TGPIOInfo;</code>
 +
| The GPIO information for the reset line
 +
|-
 +
| <code>DC:TGPIOInfo;</code>
 +
| The GPIO information for the data/command line
 +
|-
 +
| <code>BL:TGPIOInfo;</code>
 +
| The GPIO information for the backlight line
 +
|-
 +
| <code>Initialize:TTFTFramebufferInitialize;</code>
 +
| A device specific Initialize method (Optional)
 +
|-
 +
| <code>Deinitialize:TTFTFramebufferDeinitialize;</code>
 +
| A device specific Deinitialize method (Optional)
 +
|-
 +
| <code>GetDefaults:TTFTFramebufferGetDefaults;</code>
 +
| A device specific GetDefaults method (Mandatory)
 +
|-
 +
| <code>SetWriteAddress:TTFTFramebufferSetWriteAddress;</code>
 +
| A device specific SetWriteAddress method (Mandatory)
 +
|-
 +
| <code>WriteMemory:TTFTFramebufferWriteMemory;</code>
 +
| A device specific WriteMemory method (Mandatory)
 +
|-
 +
|colspan="2"|''Driver Properties''
 +
|-
 +
| <code>Width:LongWord;</code>
 +
| Framebuffer Width in Pixels
 +
|-
 +
| <code>Height:LongWord;</code>
 +
| Framebuffer Height in Pixels
 +
|-
 +
| <code>Rotation:LongWord;</code>
 +
| Framebuffer Rotation (eg FRAMEBUFFER_ROTATION_180)
 +
|-
 +
| <code>DirtyY1:LongWord;</code>
 +
| First line of dirty region (or Height - 1 if none dirty)
 +
|-
 +
| <code>DirtyY2:LongWord;</code>
 +
| Last line of dirty region (or 0 if none dirty)
 +
|-
 +
| <code>Ready:LongBool;</code>
 +
| If True timer should be enabled during Mark operation
 +
|-
 +
| <code>Lock:TMutexHandle;</code>
 +
| Lock for dirty region redraw
 +
|-
 +
| <code>Timer:TTimerHandle;</code>
 +
| Handle for dirty region redraw timer
 +
|-
 +
| <code>FrameRate:LongWord;</code>
 +
| Frame rate for display refresh (in Frames Per Second)
 +
|-
 +
| <code>TransferSize:LongWord;</code>
 +
| Maximum transfer size for the SPI device (or -1 if No Maximum)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
''None defined''
  
 
=== Function declarations ===
 
=== Function declarations ===
Line 54: Line 179:
 
{| 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 FramebufferDeviceAllocate instead
+
| Not intended to be called directly by applications, use FramebufferDeviceAllocate instead.
 
|-
 
|-
 
|}
 
|}
Line 66: Line 191:
 
{| 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 FramebufferDeviceRelease instead
+
| Not intended to be called directly by applications, use FramebufferDeviceRelease instead.
 
|-
 
|-
 
|}
 
|}
Line 78: Line 203:
 
{| 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 FramebufferDeviceMark instead. Marks full lines only, X and Width are ignored for TFT Framebuffer.
+
| Not intended to be called directly by applications, use FramebufferDeviceMark instead.
 +
Marks full lines only, X and Width are ignored for TFT Framebuffer.
 
|-
 
|-
 
|}
 
|}
Line 85: Line 211:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 TFTFramebufferCommit(Framebuffer:PFramebufferDevice; Address,Size,Flags:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function TFTFramebufferCommit(Framebuffer:PFramebufferDevice; Address:PtrUInt; Size,Flags:LongWord):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of FramebufferDeviceCommit API for TFT Framebuffer</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of FramebufferDeviceCommit API for TFT Framebuffer</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| 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 FramebufferDeviceCommit instead
+
| Not intended to be called directly by applications, use FramebufferDeviceCommit 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 TFTFramebufferSetProperties(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of FramebufferDeviceSetProperties API for TFT Framebuffer</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 FramebufferDeviceSetProperties instead
+
 
|-
 
|-
 
|}
 
|}
Line 114: Line 228:
 
{| 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:08, 23 November 2022

Return to Unit Reference


Description


Ultibo TFT Framebuffer Driver Library unit

This is a generic framebuffer device support unit for SPI based TFT screens using common chipsets.

This unit implements the shared functionality that is common to all devices and provides a set of functions that device specific drivers must implement. For each supported device a driver unit is required that implements the SPI communications to initialize the device, setup resolution and color depth as well as refreshing the framebuffer data to the device memory on change.

The resulting device created by the combination of this unit and a device specific driver is registered with Ultibo as a framebuffer device that can be accessed using all of the standard framebuffer API functions.

For examples of drivers that use this support unit see the HX8357D and ILI9340 units.

Constants



TFT framebuffer specific constants TFT_FRAMEBUFFER_*
TFT_FRAMEBUFFER_FRAME_RATE_DEFAULT = 20; Default frame rate of 20 frames per second refresh


Type definitions



TFT framebuffer initialize

TTFTFramebufferInitialize = function(Framebuffer:PTFTFramebuffer; Defaults:PFramebufferProperties):LongWord;

TFT framebuffer deinitialize

TTFTFramebufferDeinitialize = function(Framebuffer:PTFTFramebuffer):LongWord;

TFT framebuffer get defaults

TTFTFramebufferGetDefaults = function(Framebuffer:PTFTFramebuffer; Properties,Defaults:PFramebufferProperties):LongWord;

TFT framebuffer set write address

TTFTFramebufferSetWriteAddress = function(Framebuffer:PTFTFramebuffer; X1,Y1,X2,Y2:LongWord):LongWord;

TFT framebuffer write memory

TTFTFramebufferWriteMemory = function(Framebuffer:PTFTFramebuffer; Address:PtrUInt; Size:LongWord):LongWord;

TFT framebuffer device

PTFTFramebuffer = ^TTFTFramebuffer;

TTFTFramebuffer = record

Framebuffer Properties
Framebuffer:TFramebufferDevice;  
TFT Properties
SPI:PSPIDevice; The SPI device this Framebuffer is connected to
ChipSelect:Word; The SPI chip select of the device
RST:TGPIOInfo; The GPIO information for the reset line
DC:TGPIOInfo; The GPIO information for the data/command line
BL:TGPIOInfo; The GPIO information for the backlight line
Initialize:TTFTFramebufferInitialize; A device specific Initialize method (Optional)
Deinitialize:TTFTFramebufferDeinitialize; A device specific Deinitialize method (Optional)
GetDefaults:TTFTFramebufferGetDefaults; A device specific GetDefaults method (Mandatory)
SetWriteAddress:TTFTFramebufferSetWriteAddress; A device specific SetWriteAddress method (Mandatory)
WriteMemory:TTFTFramebufferWriteMemory; A device specific WriteMemory method (Mandatory)
Driver Properties
Width:LongWord; Framebuffer Width in Pixels
Height:LongWord; Framebuffer Height in Pixels
Rotation:LongWord; Framebuffer Rotation (eg FRAMEBUFFER_ROTATION_180)
DirtyY1:LongWord; First line of dirty region (or Height - 1 if none dirty)
DirtyY2:LongWord; Last line of dirty region (or 0 if none dirty)
Ready:LongBool; If True timer should be enabled during Mark operation
Lock:TMutexHandle; Lock for dirty region redraw
Timer:TTimerHandle; Handle for dirty region redraw timer
FrameRate:LongWord; Frame rate for display refresh (in Frames Per Second)
TransferSize:LongWord; Maximum transfer size for the SPI device (or -1 if No Maximum)


Public variables


None defined

Function declarations



TFT framebuffer functions

function TFTFramebufferAllocate(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;
Description: Implementation of FramebufferDeviceAllocate API for TFT Framebuffer
Note Not intended to be called directly by applications, use FramebufferDeviceAllocate instead.


function TFTFramebufferRelease(Framebuffer:PFramebufferDevice):LongWord;
Description: Implementation of FramebufferDeviceRelease API for TFT Framebuffer
Note Not intended to be called directly by applications, use FramebufferDeviceRelease instead.


function TFTFramebufferMark(Framebuffer:PFramebufferDevice; X,Y,Width,Height,Flags:LongWord):LongWord;
Description: Implementation of FramebufferDeviceMark API for TFT Framebuffer
Note Not intended to be called directly by applications, use FramebufferDeviceMark instead.

Marks full lines only, X and Width are ignored for TFT Framebuffer.


function TFTFramebufferCommit(Framebuffer:PFramebufferDevice; Address:PtrUInt; Size,Flags:LongWord):LongWord;
Description: Implementation of FramebufferDeviceCommit API for TFT Framebuffer
Note Not intended to be called directly by applications, use FramebufferDeviceCommit instead.


procedure TFTFramebufferUpdateDisplay(Framebuffer:PTFTFramebuffer);
Description: Timer function for display dirty region redraw
Note Not intended to be called directly by applications


Return to Unit Reference