Difference between revisions of "Unit ILI9340"

From Ultibo.org
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 27: Line 27:
 
<br />  
 
<br />  
 
<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;">'''ILI9340 SPI constants''' <code> ILI9340_SPI_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''ILI9340 SPI''' <code> ILI9340_SPI_* </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 38: Line 38:
 
<br />  
 
<br />  
 
<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;">'''ILI9340 command constants''' <code> ILI9340_CMD_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''ILI9340 command''' <code> ILI9340_CMD_* </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 125: Line 125:
 
<br />  
 
<br />  
 
<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;">'''ILI9340 memory access control constants''' <code> ILI9340_CMD_MADCTL_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''ILI9340 memory access control''' <code> ILI9340_CMD_MADCTL_* </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 140: Line 140:
 
|-
 
|-
 
| <code>ILI9340_CMD_MADCTL_MV = $20;</code>
 
| <code>ILI9340_CMD_MADCTL_MV = $20;</code>
| Row / Column Exchange
+
| Row/Column Exchange
 
|-
 
|-
 
| <code>ILI9340_CMD_MADCTL_ML = $10;</code>
 
| <code>ILI9340_CMD_MADCTL_ML = $10;</code>
Line 161: Line 161:
 
----
 
----
  
''To be documented''
+
 
 +
'''ILI9340 framebuffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PILI9340Framebuffer = ^TILI9340Framebuffer;</code>
 +
 
 +
<code>TILI9340Framebuffer = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''TFT Properties''
 +
|-
 +
| <code>TFT:TTFTFramebuffer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
Line 180: Line 197:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''SPI'''
+
! SPI
 
| The SPI device that this ILI9340 is connected to
 
| The SPI device that this ILI9340 is connected to
 
|-
 
|-
! '''ChipSelect'''
+
! ChipSelect
 
| The SPI chip select to use when communicating with this device
 
| The SPI chip select to use when communicating with this device
 
|-
 
|-
! '''Name'''
+
! Name
| The text description of this device which will should in the device list (Optional)
+
| The text description of this device which will show in the device list (Optional)
 
|-
 
|-
! '''Rotation'''
+
! Rotation
 
| The rotation value for the framebuffer device (eg FRAMEBUFFER_ROTATION_180)
 
| The rotation value for the framebuffer device (eg FRAMEBUFFER_ROTATION_180)
 
|-
 
|-
! '''Width'''
+
! Width
 
| The width of the framebuffer in pixels
 
| The width of the framebuffer in pixels
 
|-
 
|-
! '''Height'''
+
! Height
 
| The height of the framebuffer in pixels
 
| The height of the framebuffer in pixels
 
|-
 
|-
! '''RST'''
+
! RST
 
| GPIO pin information for the Reset pin (Optional)
 
| GPIO pin information for the Reset pin (Optional)
 
|-
 
|-
! '''DC'''
+
! DC
 
| GPIO pin information for the Data/Command pin
 
| GPIO pin information for the Data/Command pin
 
|-
 
|-
! '''BL'''
+
! BL
 
| GPIO pin information for the Backlight pin (Optional)
 
| GPIO pin information for the Backlight pin (Optional)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to the new Framebuffer device or nil if the framebuffer device could not be created
 
| Pointer to the new Framebuffer device or nil if the framebuffer device could not be created
 
|-
 
|-
Line 219: Line 236:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Framebuffer'''
+
! Framebuffer
 
| The Framebuffer device to destroy
 
| The Framebuffer device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 237: Line 254:
 
{| 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 FramebufferDeviceBlank instead
+
| Not intended to be called directly by applications, use FramebufferDeviceBlank instead.
 
|-
 
|-
 
|}
 
|}
Line 249: Line 266:
 
{| 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 FramebufferDeviceSetBacklight instead
+
| Not intended to be called directly by applications, use FramebufferDeviceSetBacklight instead.
 
|-
 
|-
 
|}
 
|}
Line 264: Line 281:
 
{| 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
 
|-
 
|-
Line 276: Line 293:
 
{| 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
 
|-
 
|-
Line 288: Line 305:
 
{| 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
 
|-
 
|-
Line 300: Line 317:
 
{| 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
 
|-
 
|-
Line 307: Line 324:
 
<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 ILI9340TFTFramebufferWriteMemory(Framebuffer:PTFTFramebuffer; Address,Size:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function ILI9340TFTFramebufferWriteMemory(Framebuffer:PTFTFramebuffer; Address:PtrUInt; Size:LongWord):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of TFTFramebufferWriteMemory API for ILI9340</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of TFTFramebufferWriteMemory API for ILI9340</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
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 327: Line 344:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 339: Line 356:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 351: Line 368:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 363: Line 380:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Latest revision as of 04:52, 17 June 2021

Return to Unit Reference


Description


ILITEK ILI9340 TFT LCD Driver unit

The ILITEK ILI9340 is a 240x320 Resolution RGB 262K color TFT LCD Single Chip Driver that supports color depths of 16 or 18bit. This driver supports the chip only in 16 bit depth using RGB565 format.

The chip provides an SPI interface at up to 32MHz and supports rotations of 0, 90, 180 and 270 degrees.

Constants



ILI9340 specific constants ILI9340_FRAMEBUFFER_*
ILI9340_FRAMEBUFFER_DESCRIPTION = 'ILITEK ILI9340 TFT LCD'; Description of ILI9340 device


ILI9340 SPI ILI9340_SPI_*
ILI9340_SPI_RATE = 32000000; Default SPI clock rate


ILI9340 command ILI9340_CMD_*
ILI9340_CMD_NOP = $00; 8.2.1. NOP: No Operation
ILI9340_CMD_SWRESET = $01; 8.2.2. SWRESET: Software Reset
 
ILI9340_CMD_SLPOUT = $11; 8.2.12. SLPOUT: Sleep Out (This command turns off sleep mode)
 
ILI9340_CMD_GAMSET = $26; 8.2.17. GAMSET: Gamma Set (This command is used to select the desired Gamma curve for the current display)
 
ILI9340_CMD_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)
ILI9340_CMD_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)
 
ILI9340_CMD_CASET = $2A; 8.2.20. CASET: Column Address Set (This command is used to define area of frame memory where MCU can access)
ILI9340_CMD_PASET = $2B; 8.2.21. PASET: Page Address Set (This command is used to define area of frame memory where MCU can access)
ILI9340_CMD_RAMWR = $2C; 8.2.22. Memory Write (This command is used to transfer data from MCU to frame memory)
 
ILI9340_CMD_MADCTL = $36; 8.2.29. MADCTL: Memory Access Control (This command defines read/write scanning direction of frame memory)
 
ILI9340_CMD_COLMOD = $3A; 8.2.33. COLMOD: Pixel Format Set (This command sets the pixel format for the RGB image data used by the interface)
 
ILI9340_CMD_FRMCTR1 = $B1; 8.3.2. FRMCTR1: Frame Rate Control (In Normal Mode/Full Colors)
 
ILI9340_CMD_DISCTRL = $B6; 8.3.7. DISCTRL: Display Function Control
 
ILI9340_CMD_PWCTRL1 = $C0; 8.3.16. PWCTRL1: Power Control 1
ILI9340_CMD_PWCTRL2 = $C1; 8.3.17. PWCTRL2: Power Control 2
 
ILI9340_CMD_VMCTRL1 = $C5; 8.3.21. VMCTRL1: VCOM Control 1
ILI9340_CMD_VMCTRL2 = $C7; 8.3.22. VMCTRL2: VCOM Control 2
 
ILI9340_CMD_PGAMCTRL = $E0; 8.3.27. PGAMCTRL: Positive Gamma Correction (Set the gray scale voltage to adjust the gamma characteristics of the TFT panel)
ILI9340_CMD_NGAMCTRL = $E1; 8.3.28. NGAMCTRL: Negative Gamma Correction (Set the gray scale voltage to adjust the gamma characteristics of the TFT panel)


ILI9340 memory access control ILI9340_CMD_MADCTL_*
See ILI9340 datasheet 8.2.29. Memory Access Control
 
ILI9340_CMD_MADCTL_MY = $80; Row Address Order
ILI9340_CMD_MADCTL_MX = $40; Column Address Order
ILI9340_CMD_MADCTL_MV = $20; Row/Column Exchange
ILI9340_CMD_MADCTL_ML = $10; Vertical Refresh Order
ILI9340_CMD_MADCTL_RGB = $00; Colour selector switch control(0=RGB colour filter panel, 1=BGR colour filter panel)
ILI9340_CMD_MADCTL_BGR = $08;  
ILI9340_CMD_MADCTL_MH = $04; Horizontal Refresh Order


Type definitions



ILI9340 framebuffer

PILI9340Framebuffer = ^TILI9340Framebuffer;

TILI9340Framebuffer = record

TFT Properties
TFT:TTFTFramebuffer;  


Public variables


None defined

Function declarations



ILI9340 functions

function ILI9340FramebufferCreate(SPI:PSPIDevice; ChipSelect:Word; const Name:String; Rotation,Width,Height:LongWord; RST,DC,BL:PGPIOInfo):PFramebufferDevice;
Description: Create, register and allocate a new ILI9340 Framebuffer device which can be accessed using the framebuffer API
SPI The SPI device that this ILI9340 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 ILI9340FramebufferDestroy(Framebuffer:PFramebufferDevice):LongWord;
Description: Release, deregister and destroy an ILI9340 Framebuffer device created by this driver
Framebuffer The Framebuffer device to destroy
Return ERROR_SUCCESS if completed or another error code on failure


ILI9340 framebuffer functions

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


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


ILI9340 TFT framebuffer functions

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


function ILI9340TFTFramebufferDeinitialize(Framebuffer:PTFTFramebuffer):LongWord;
Description: Implementation of TFTFramebufferDeinitialize API for ILI9340
Note Not intended to be called directly by applications


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


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


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


ILI9340 helper functions

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


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


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


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


Return to Unit Reference