Unit ST77XX

From Ultibo.org
Revision as of 05:21, 14 November 2023 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


Description


Sitronix ST77XX TFT LCD Driver unit

The ST77XX is a family of single-chip controllers/drivers for color, graphic type TFT-LCD display.

Instantiate the ST77XX driver by calling ST77XXFramebufferCreate() with the required parameters:

SPI: The SPI device that this ST77XX is connected to

ChipSelect: The SPI chip select to use when communicating with this device

Name: The text description of this device which will show in the device list (Optional)

Rotation: The rotation value for the framebuffer device (eg FRAMEBUFFER_ROTATION_180)

Width: The width of the framebuffer in pixels

Height: The height of the framebuffer in pixels

ColStart:

RST: GPIO pin information for the Reset pin (Optional)

DC: GPIO pin information for the Data/Command pin

BL: GPIO pin information for the Backlight pin (Optional)

Constants



ST77XX specific constants ST77XX_*
ST77XX_FRAMEBUFFER_DESCRIPTION = 'ST77XX TFT LCD DRIVER'; Description of ST77XX device


ST77XX SPI ST77XX_SPI_*
ST77XX_SPI_RATE = 32000000; Default SPI clock rate
ST_CMD_DELAY = $80; Special signifier for command lists


ST77XX control command ST77XX_*
ST77XX_NOP = $00; 8.2.1. NOP: No Operation
ST77XX_SWRESET = $01; 8.2.2. SWRESET: Software Reset
ST77XX_RDDID = $04; new_cmd
ST77XX_RDDST = $09; new_cmd
 
ST77XX_SLPIN = $10; new_cmd
ST77XX_SLPOUT = $11; 8.2.12. SLPOUT: Sleep Out (This command turns off sleep mode)
ST77XX_PTLON = $12; new_cmd
ST77XX_NORON = $13; new_cmd
 
ST77XX_INVOFF = $20; new_cmd
ST77XX_INVON = $21; new_cmd
ST77XX_GAMSET = $26; 8.2.17. GAMSET: Gamma Set (This command is used to select the desired Gamma curve for the current display)
ST77XX_DISPOFF = $28; 8.2.18. DISPOFF: Display OFF (This command is used to enter into DISPLAY OFF mode. In this mode, the output from Frame Memory is disabled and blank page inserted)
ST77XX_DISPON = $29; 8.2.19. DISPON: Display ON (This command is used to recover from DISPLAY OFF mode. Output from the Frame Memory is enabled)
ST77XX_CASET = $2A; 8.2.20. CASET: Column Address Set (This command is used to define area of frame memory where MCU can access)
ST77XX_RASET = $2B; 8.2.21. PASET: Page Address Set (This command is used to define area of frame memory where MCU can access)
ST77XX_RAMWR = $2C; 8.2.22. Memory Write (This command is used to transfer data from MCU to frame memory)
ST77XX_RGBSET = $2D; Color setting for 4096, 64K and 262K colors
ST77XX_RAMRD = $2E; new_cmd
 
ST77XX_RDDPM = $0A; Read display power mode
ST77XX_RDD_MADCTL = $0B; Read display MADCTL
ST77XX_RDD_COLMOD = $0C; Read display pixel format
ST77XX_RDDIM = $0D; Read display image mode
ST77XX_RDDSM = $0E; Read display signal mode
ST77XX_RDDSR = $0F; Read display self-diagnostic result (ST7789V)
 
ST77XX_PTLAR = $30; new_cmd
ST77XX_VSCRDEF = $33; Vertical scrolling definition (ST7789V)
ST77XX_TEOFF = $34; Tearing effect line off
ST77XX_TEON = $35; Tearing effect line on
ST77XX_MADCTL = $36; 8.2.29. MADCTL: Memory Access Control (This command defines read/write scanning direction of frame memory)
ST77XX_IDMOFF = $38; Idle mode off
ST77XX_IDMON = $39; Idle mode on
ST77XX_RAMWRC = $3C; Memory write continue (ST7789V)
ST77XX_RAMRDC = $3E; Memory read continue (ST7789V)
ST77XX_COLMOD = $3A; 8.2.33. COLMOD: Pixel Format Set (This command sets the pixel format for the RGB image data used by the interface)


ST77XX memory access control ST77XX_*CTL_*
See ST77XX datasheet 8.2.29. Memory Access Control
ST77XX_MADCTL_MY = $80; Row Address Order
ST77XX_MADCTL_MX = $40; Column Address Order
ST77XX_MADCTL_MV = $20; Row / Column Exchange
ST77XX_MADCTL_ML = $10; Row / Column Exchange
ST77XX_MADCTL_MH = $04; Horizontal Refresh Order
ST77XX_MADCTL_RGB = $00; Colour selector switch control (0=RGB colour filter panel, 1=BGR colour filter panel)
ST77XX_MADCTL_BGR = $08;  
 
ST77XX_RAMCTRL = $B0; RAM control
ST77XX_RGBCTRL = $B1; RGB control
ST77XX_PORCTRL = $B2; Porch control
ST77XX_FRCTR1 = $B3; 8.3.2. FRCTR1: Frame Rate Control (In Normal Mode/Full Colors)
ST77XX_PARCTRL = $B5; Partial mode control
ST77XX_GCTRL = $B7; Gate control
ST77XX_GTADJ = $B8; Gate on timing adjustment
ST77XX_DGMEN = $BA; Digital gamma enable
ST77XX_VCOMS = $BB; VCOMS setting
ST77XX_DISCTRL = $B6; 8.3.7. DISCTRL: Display Function Control
 
ST77XX_LCMCTRL = $C0; LCM control
ST77XX_IDSET = $C1; ID setting
ST77XX_VDVVRHEN = $C2; VDV and VRH command enable
ST77XX_VRHS = $C3; VRH set
ST77XX_VDVSET = $C4; VDV setting
ST77XX_VCMOFSET = $C5; VCOMS offset set
ST77XX_FRCTR2 = $C6; FR Control 2
ST77XX_CABCCTRL = $C7; CABC control
ST77XX_REGSEL1 = $C8; Register value section 1
ST77XX_REGSEL2 = $CA; Register value section 2
ST77XX_PWMFRSEL = $CC; PWM frequency selection
 
ST77XX_PWCTRL1 = $D0; 8.3.16. PWCTRL1: Power Control 1
ST77XX_VAPVANEN = $D2; Enable VAP/VAN signal output
ST77XX_CMD2EN = $DF; Command 2 enable
 
ST77XX_VMCTRL1 = $C5; 8.3.21. VMCTRL1: VCOM Control 1
ST77XX_VMCTRL2 = $C7; 8.3.22. VMCTRL2: VCOM Control 2
 
ST77XX_PGAMCTRL = $E0; Positive voltage gamma control
ST77XX_NGAMCTRL = $E1; Negative voltage gamma control
ST77XX_DGMLUTR = $E2; Digital gamma look-up table for red
ST77XX_DGMLUTB = $E3; Digital gamma look-up table for blue
ST77XX_GATECTRL = $E4; Gate control
ST77XX_SPI2EN = $E7; SPI2 enable
ST77XX_PWCTRL2 = $E8; Power control 2
ST77XX_EQCTRL = $E9; Equalize time control
ST77XX_PROMCTRL = $EC; Program control
 
ST77XX_PROMEN = $FA; Program mode enable
ST77XX_NVMSET = $FC; NVM setting
ST77XX_PROMACT = $FE; Program action
 
ST77XX_COLOR_MODE_16bit =$55;  
ST77XX_COLOR_MODE_18bit =$66;  


Type definitions



ST77XX specific types

PST77XXFramebuffer = ^TST77XXFramebuffer;

TST77XXFramebuffer = record

TFT Properties
TFT:TTFTFramebuffer;  


Public variables


None defined

Function declarations



ST77XX functions

function ST77XXFramebufferCreate(SPI:PSPIDevice; ChipSelect:Word; const Name:String; Rotation,Width,Height,ColStart:LongWord; RST,DC,BL:PGPIOInfo):PFramebufferDevice;
Description: Create, register and allocate a new ST77XX Framebuffer device which can be accessed using the framebuffer API
SPI The SPI device that this ST77XX is connected to
ChipSelect The SPI chip select to use when communicating with this device
Name The text description of this device which will show in the device list (Optional)
Rotation The rotation value for the framebuffer device (eg FRAMEBUFFER_ROTATION_180)
Width The width of the framebuffer in pixels
Height The height of the framebuffer in pixels
RST GPIO pin information for the Reset pin (Optional)
DC GPIO pin information for the Data/Command pin
BL GPIO pin information for the Backlight pin (Optional)
Return Pointer to the new Framebuffer device or nil if the framebuffer device could not be created


function ST77XXFramebufferDestroy(Framebuffer:PFramebufferDevice):LongWord;
Description: Release, deregister and destroy an ST77XX Framebuffer device created by this driver
Framebuffer The Framebuffer device to destroy
Return ERROR_SUCCESS if completed or another error code on failure


ST77XX framebuffer functions

function ST77XXFramebufferBlank(Framebuffer:PFramebufferDevice; Blank:Boolean):LongWord;
Description: Implementation of FramebufferDeviceBlank API for ST77XX
Note Not intended to be called directly by applications, use FramebufferDeviceBlank instead


function ST77XXFramebufferSetBacklight(Framebuffer:PFramebufferDevice; Brightness:LongWord):LongWord;
Description: Implementation of FramebufferDeviceSetBacklight API for ST77XX
Note Not intended to be called directly by applications, use FramebufferDeviceSetBacklight instead


ST77XX TFTFramebuffer functions

function ST77XXTFTFramebufferInitialize(Framebuffer:PTFTFramebuffer; Defaults:PFramebufferProperties):LongWord;
Description: Implementation of TFTFramebufferInitialize API for ST77XX
Note Not intended to be called directly by applications


FUNCTION
Description: Implementation of TFTFramebufferDeinitialize API for ST77XX
Note Not intended to be called directly by applications


function ST77XXTFTFramebufferGetDefaults(Framebuffer:PTFTFramebuffer; Properties,Defaults:PFramebufferProperties):LongWord;
Description: Implementation of TFTFramebufferGetDefaults API for ST77XX
Note Not intended to be called directly by applications


function ST77XXTFTFramebufferSetWriteAddress(Framebuffer:PTFTFramebuffer; X1,Y1,X2,Y2:LongWord):LongWord;
Description: Implementation of TFTFramebufferSetWriteAddress API for ST77XX
Note Not intended to be called directly by applications


function ST77XXTFTFramebufferWriteMemory(Framebuffer:PTFTFramebuffer; Address:PtrUInt; Size:LongWord):LongWord;
Description: Implementation of TFTFramebufferWriteMemory API for ST77XX
Note Not intended to be called directly by applications


ST77XX helper functions

function ST77XXWriteCommand(Framebuffer:PTFTFramebuffer; Value:Byte):LongWord;
Description: Write a single command value to the ST77XX
Note None documented


function ST77XXWriteCommandEx(Framebuffer:PTFTFramebuffer; const Values:array of Byte):LongWord;
Description: Write multiple command values to the ST77XX
Note None documented


function ST77XXWriteData(Framebuffer:PTFTFramebuffer; Value:Byte):LongWord;
Description: Write a single data value to the ST77XX
Note None documented


function ST77XXWriteDataEx(Framebuffer:PTFTFramebuffer; const Values:array of Byte):LongWord;
Description: Write multiple data values to the ST77XX
Note None documented


Return to Unit Reference