Unit TFT Framebuffer

From Ultibo.org
Revision as of 05:04, 31 August 2021 by Ultibo (Talk | contribs)

Jump to: navigation, search

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.


function TFTFramebufferSetProperties(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;
Description: Implementation of FramebufferDeviceSetProperties API for TFT Framebuffer
Note Not intended to be called directly by applications, use FramebufferDeviceSetProperties 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