TFT Library

Thin film transistor liquid crystal display (TFT-LCD) is a variant of liquid crystal display (LCD) which uses thin-film transistor (TFT) technology to improve image quality (e.g., addressability, contrast).
TFT LCD is one type of active matrix LCD, though all LCD-screens are based on TFT active matrix addressing.
TFT LCDs are used in television sets, computer monitors, mobile phones, handheld video game systems, personal digital assistants, navigation systems, projectors, etc.

The mikroBasic PRO for dsPIC30/33 and PIC24 provides a library for working with the following display controllers :


  Note :

External dependencies of TFT Library

The following variables must be defined in all projects using TFT library: Description : Example :
dim TFT_DataPort as byte sfr external TFT Data Port. dim TFT_DataPort as byte at LATE
dim TFT_DataPort_Direction as byte sfr external Direction of the TFT Data Port. dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR as byte sfr external Write signal. dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as byte sfr external Read signal. dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as byte sfr external Chip Select signal. dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as byte sfr external Command/Register Select signal. dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as byte sfr external Reset signal. dim TFT_RST as sbit at LATC1_bit
dim TFT_WR_Direction as byte sfr external Direction of the Write pin. dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as byte sfr external Direction of the Read pin. dim TFT_WR_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as byte sfr external Direction of the Chip Select pin. dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as byte sfr external Direction of the Register Select pin. dim TFT_RS_Direction as sbit at TRISB13_bit
dim TFT_RST_Direction as byte sfr external Direction of the Reset pin. dim TFT_RST_Direction as sbit at TRISC1_bit

Library Routines

TFT_Init

Prototype

sub procedure TFT_Init(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347D display controller in 8-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init(240, 320)

TFT_Init_HX8352A

Prototype

sub procedure TFT_Init_HX8352A(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8352A display controller in 16-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8352A(240, 320)

TFT_Init_HX8347G

Prototype

sub procedure TFT_Init_HX8347G(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347-G display controller display in the 8-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8347G(240, 320)

TFT_Init_HX8347G_16bit

Prototype

sub procedure TFT_Init_HX8347G_16bit(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347-G display controller display in the 16-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8347G_16bit(240, 320)

TFT_Init_SSD1963_8bit

Prototype

sub procedure TFT_Init_SSD1963_8bit(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SSD1963 display controller display in the 8-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SSD1963_8bit(240, 320)

TFT_Init_SSD1963

Prototype

sub procedure TFT_Init_SSD1963(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SSD1963 display controller display in the 16-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SSD1963(240, 320)

TFT_Init_R61526

Prototype

sub procedure TFT_Init_R61526(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes R61526 display controller display in the 8-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_R61526(240, 320)

TFT_Init_SST7715R

Prototype

sub procedure TFT_Init_SST7715R(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SST7715R display controller display in the 8-bit working mode.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SST7715R(240, 320)

TFT_Init_ILI9340

Prototype

sub procedure TFT_Init_ILI9340(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9340 display controller in 16-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9340(240, 320)

TFT_Init_ILI9340_8bit

Prototype

sub procedure TFT_Init_ILI9340_8bit(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9340 display controller in 8-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9340_8bit(240, 320)

TFT_Init_ILI9342

Prototype

sub procedure TFT_Init_ILI9342(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9342 display controller in 16-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9342(240, 320)

TFT_Init_ILI9481

Prototype

sub procedure TFT_Init_ILI9481(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9481 display controller in 16-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9481(240, 320)

TFT_Init_ILI9481_8bit

Prototype

sub procedure TFT_Init_ILI9481_8bit(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9481 display controller in 8-bit working mode.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9481_8bit(240, 320)

TFT_Init_Custom

Prototype

sub procedure TFT_Init_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347D display controller in 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

TFT_Init_Custom(240, 320)

TFT_Init_HX8352A_Custom

Prototype

sub procedure TFT_Init_HX8352A_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8352A display controller in 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8352A_Custom(240, 320)

TFT_Init_HX8347G_Custom

Prototype

sub procedure TFT_Init_HX8347G_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347-G display controller display in the 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8347G_Custom(240, 320)

TFT_Init_HX8347G_16bit_Custom

Prototype

sub procedure TFT_Init_HX8347G_16bit_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes HX8347-G display controller display in the 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_HX8347G_16bit_Custom(240, 320)

TFT_Init_SSD1963_8bit_Custom

Prototype

sub procedure TFT_Init_SSD1963_8bit_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SSD1963 display controller display in the 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SSD1963_8bit_Custom(240, 320)

TFT_Init_SSD1963_Custom

Prototype

sub procedure TFT_Init_SSD1963_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SSD1963 display controller display in the 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SSD1963_Custom(240, 320)

TFT_Init_R61526_Custom

Prototype

sub procedure TFT_Init_R61526_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes R61526 display controller display in the 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_R61526_Custom(240, 320)

TFT_Init_SST7715R_Custom

Prototype

sub procedure TFT_Init_SST7715R_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes SST7715R display controller display in the 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT panel
  • height: height of the TFT panel
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_SST7715R_Custom(240, 320)

TFT_Init_ILI9340_Custom

Prototype

sub procedure TFT_Init_ILI9340_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9340 display controller in 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9340_Custom(240, 320)

TFT_Init_ILI9340_8bit_Custom

Prototype

sub procedure TFT_Init_ILI9340_8bit_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9340 display controller in 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9340_8bit_Custom(240, 320)

TFT_Init_ILI9342_Custom

Prototype

sub procedure TFT_Init_ILI9342_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9342 display controller in 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9342_Custom(240, 320)

TFT_Init_ILI9481_Custom

Prototype

sub procedure TFT_Init_ILI9481_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9481 display controller in 16-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9481_Custom(240, 320)

TFT_Init_ILI9481_8bit_Custom

Prototype

sub procedure TFT_Init_ILI9481_8bit_Custom(dim display_width, display_height as word)

Returns

Nothing.

Description

Initializes ILI9481 display controller in 8-bit working mode with custom Data port initialization.
When using this routine, the port used for TFT_DataPort will remain intact and may be used freely for other purposes.

Parameters :

  • width: width of the TFT display.
  • height: height of the TFT display.
Requires

Global variables :

  • TFT_DataPort: Data Port
  • TFT_WR: Write signal pin
  • TFT_RD: Read signal pin
  • TFT_CS: Chip Select signal pin
  • TFT_RS: Register Select signal pin
  • TFT_RST: Reset signal pin

  • TFT_DataPort_Direction: Direction of Data Port
  • TFT_WR_Direction: Direction of Write signal pin
  • TFT_RD_Direction: Direction of Read signal pin
  • TFT_CS_Direction: Direction of Chip Select signal pin
  • TFT_RS_Direction: Direction of Register Select signal pin
  • TFT_RST_Direction: Direction of Reset signal pin
must be defined before using this function.

Example
' TFT display connections
dim TFT_DataPort as byte at LATE
dim TFT_WR as sbit at LATD13_bit
dim TFT_RD as sbit at LATD12_bit
dim TFT_CS as sbit at LATC3_bit
dim TFT_RS as sbit at LATB15_bit
dim TFT_RST as sbit at LATC1_bit

dim TFT_DataPort_Direction as byte at TRISE
dim TFT_WR_Direction as sbit at TRISD13_bit
dim TFT_RD_Direction as sbit at TRISD12_bit
dim TFT_CS_Direction as sbit at TRISC3_bit
dim TFT_RS_Direction as sbit at TRISB15_bit
dim TFT_RST_Direction as sbit at TRISC1_bit
' End of TFT display connections

' Initialize 240x320 TFT display
TFT_Init_ILI9481_8bit_Custom(240, 320)

TFT_Set_Index

Prototype

sub procedure TFT_Set_Index(dim index as byte)

Returns

Nothing.

Description

Accesses register space of the controller and sets the desired register.

Parameters :

  • index: desired register number.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Access register at the location 0x02
TFT_Set_Index(0x02)

TFT_SSD1963_8bit_Set_Index

Prototype

sub procedure TFT_SSD1963_8bit_Set_Index(dim index as byte)

Returns

Nothing.

Description

Accesses register space of the SSD11963 controller in 8-bit mode and sets the desired register.

Parameters :

  • index: desired register number.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Access register at the location 0x02
TFT_SSD1963_8bit_Set_Index(0x02)

TFT_Write_Command

Prototype

sub procedure TFT_Write_Command(dim cmd as byte)

Returns

Nothing.

Description

Accesses data space and writes a command.

Parameters :

  • cmd: command to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Write a command
TFT_Write_Command(0x02)

TFT_SSD1963YT_8bit_Write_Command

Prototype

sub procedure TFT_SSD1963YT_8bit_Write_Command(dim command as byte)

Returns

Nothing.

Description

Accesses data space of the SSD1963 controller in 8-bit mode and writes a command.

Parameters :

  • command: command to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Write a command
TFT_SSD1963YT_8bit_Write_Command(0x02)

TFT_Write_Data

Prototype

sub procedure TFT_Write_Data(dim _data as word)

Returns

Nothing.

Description

Writes date into display memory.

Parameters :

  • _data:data to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Send data
TFT_Write_Data(0x02)

TFT_SSD1963_8bit_Write_Data

Prototype

sub procedure TFT_SSD1963_8bit_Write_Data(dim _data as word)

Returns

Nothing.

Description

Writes data into display memory of the SSD1963 controller in 8-bit mode.

Parameters :

  • _data:data to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Send data
TFT_SSD1963_8bit_Write_Data(0x02)

TFT_16bit_Write_Data

Prototype

sub procedure TFT_16bit_Write_Data(dim _data as word)

Returns

Nothing.

Description

Writes date into display memory, display controller configured in 16-bit mode.

Parameters :

  • _data:data to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Send data
TFT_16bit_Write_Data(0x02)

TFT_Set_Reg

Prototype

sub procedure TFT_Set_Reg(dim index, value as byte)

Returns

Nothing.

Description

Accesses register space of the controller and writes a value in the desired register.

Parameters :

  • index: desired register.
  • value: value to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' 65K Color Selection
TFT_Set_Reg(0x17, 0x05)

TFT_SSD1963_8bit_Set_Reg

Prototype

sub procedure TFT_SSD1963_8bit_Set_Reg(dim index, value as byte)

Returns

Nothing.

Description

Accesses register space of the controller and writes a value in the desired register, display controller configured in 8-bit mode.

Parameters :

  • index: desired register.
  • value: value to be written.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' 65K Color Selection
TFT_SSD1963_8bit_Set_Reg(0x17, 0x05)

TFT_Set_Ext_Buffer

Prototype

sub procedure TFT_Set_Ext_Buffer(dim getExtDataPtr as ^TTFT_Get_Ext_Data_Ptr)

Returns

Nothing.

Description

Function sets pointer to the user function which manipulates the external resource.

Parameters :

  • TTFT_Get_Ext_Data_Ptr - pointer to the user function.

User function prototype should be in the following format: sub function External(dim offset as longword, dim count as word, dim byref num as word) as ^byte

Parameters used in the function have the following meaning :

  • offset - offset from the beginning of the resource from where the data is requested.
  • count - requested number of bytes.
  • num - variable for holding the returned number of bytes (less or equal to the number of acquired bytes).
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Set_Ext_Buffer(@ReadExternalBuffer)

TFT_Set_Active

Prototype

sub procedure TFT_Set_Active(dim Set_Index_Ptr as ^TTFT_Set_Index_Ptr, dim Write_Command_Ptr as ^TTFT_Write_Command_Ptr, dim Write_Data_Ptr as ^TTFT_Write_Data_Ptr)

Returns

Nothing.

Description

This function sets appropriate pointers to a user-defined basic routines in order to enable multiple working modes.

Parameters :

  • Set_Index_Ptr: Set_Index handler.
  • Write_Command_Ptr: _Write_Command handler.
  • Write_Data_Ptr: Write_Data handler.
Requires

None.

Example
' Example of establishing 16-bit communication between TFT display and PORTD, PORTE of MCU :

sub procedure Set_Index(dim index as byte)
  TFT_RS = 0
  Lo(LATD) = index
  TFT_WR = 0
  TFT_WR = 1
end sub

sub procedure Write_Command(dim cmd as byte)
  TFT_RS = 1
  Lo(LATD) = cmd
  TFT_WR = 0
  TFT_WR = 1
end sub

sub procedure Write_Data(dim _data as byte)
  TFT_RS = 1
  Lo(LATE) = Hi(_data)
  Lo(LATD) = Lo(_data)
  TFT_WR = 0
  TFT_WR = 1
end sub

main :
  TRISE = 0
  TRISD = 0

  TFT_Set_Active(Set_Index,Write_Command,Write_Data)
  TFT_Init(320, 240)

  .....
end.

TFT_Set_Default_Mode

Prototype

sub procedure TFT_Set_Default_Mode()

Returns

Nothing.

Description

This procedure sets TFT in default working mode.

Parameters :

  • None.
Requires

None.

Example
TFT_Set_Default_Mode()
TFT_Init(320, 240)

TFT_Set_Font

Prototype

sub procedure TFT_Set_Font(dim activeFont as ^const far byte, dim font_color as word, dim font_orientation as byte)

Returns

Nothing.

Description

Sets font, its color and font orientation.

Parameters :

  • activeFont: desired font. Currently, only TFT_defaultFont (Tahoma14x16) is supported.
  • font_color: sets font color :

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

  • font_orientation: sets font orientation :

    Value Description
    FO_HORIZONTAL Horizontal orientation
    FO_VERTICAL Vertical orientation

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Set_Font(@TFT_defaultFont, CL_BLACK, FO_HORIZONTAL)

TFT_Set_Ext_Font

Prototype

sub procedure TFT_Set_Ext_Font(dim activeFont as longword, dim font_color as word, dim font_orientation as word)

Returns

Nothing.

Description

Sets font, its color and font orientation. Font is located in an external resource

Parameters :

  • activeFont: desired font. This parameter represents the address in the exteral resource from where the font data begins.
  • font_color: sets font color :

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

  • font_orientation: sets font orientation :

    Value Description
    FO_HORIZONTAL Horizontal orientation
    FO_VERTICAL Vertical orientation

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Set_Ext_Font(173296,CL_BLACK,FO_HORIZONTAL)

TFT_Write_Char

Prototype

sub procedure TFT_Write_Char(dim ch, x, y as word)

Returns

Nothing.

Description

Writes a char on the TFT at coordinates (x, y).

  • c: char to be written.
  • x: char position on x-axis.
  • y: char position on y-axis.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Write_Char("A",22,23)

TFT_Write_Text

Prototype

sub procedure TFT_Write_Text(dim byref text as string, dim x, y as word)

Returns

Nothing.

Description

Writes text on the TFT at coordinates (x, y).

Parameters :

  • text: text to be written.
  • x: text position on x-axis.
  • y: text position on y-axis.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Write_Text("TFT LIBRARY DEMO, WELCOME !", 0, 0)	

TFT_Write_Const_Text

Prototype

sub procedure TFT_Write_Const_Text(dim const text as ^far byte, dim x, y as word)

Returns

Nothing.

Description

Writes text located in the program memory on the TFT at coordinates (x, y).

Parameters :

  • text: text to be written.
  • x: text position on x-axis.
  • y: text position on y-axis.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
const message = "mikroElektronika"
...
TFT_Write_Const_Text(message, 0, 0)

TFT_Fill_Screen

Prototype

sub procedure TFT_Fill_Screen(dim color as word)

Returns

Nothing.

Description

Fills screen memory block with given color.

Parameters :

  • color: color to be filled :

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Fill_Screen(CL_BLACK)

TFT_Dot

Prototype

sub procedure TFT_Dot(dim x, y as integer, dim color as word)

Returns

Nothing.

Description

Draws a dot on the TFT at coordinates (x, y).

Parameters :

  • x: dot position on x-axis.
  • y: dot position on y-axis.
  • color: color parameter. Valid values :

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Dot(50, 50, CL_BLACK)

TFT_Set_Pen

Prototype

sub procedure TFT_Set_Pen(dim pen_color as word, dim pen_width as byte)

Returns

Nothing.

Description

Sets color and thickness parameter for drawing line, circle and rectangle elements.

Parameters :

  • pen_color: Sets color.

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

  • pen_width: sets thickness.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Set_Pen(CL_BLACK, 10)

TFT_Set_Brush

Prototype

sub procedure TFT_Set_Brush(dim brush_enabled as byte, dim brush_color as word, dim gradient_enabled, gradient_orientation as byte, dim gradient_color_from, gradient_color_to as word)

Returns

Nothing.

Description

Sets color and gradient which will be used to fill circles or rectangles.

Parameters :

  • brush_enabled: enable brush fill.

    Value Description
    1 Enable brush fill.
    0 Disable brush fill.

  • brush_color: set brush fill color.

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

  • gradient_enabled: enable gradient

    Value Description
    1 Enable gradient.
    0 Disable gradient.

  • gradient_orientation: sets gradient orientation :

    Value Description
    LEFT_TO_RIGHT Left to right gradient orientation
    TOP_TO_BOTTOM Top to bottom gradient orientation

  • gradient_color_from: sets the starting gradient color.

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

  • gradient_color_to: sets the ending gradient color.

    Value Description
    CL_AQUA Aqua color
    CL_BLACK Black color
    CL_BLUE Blue color
    CL_FUCHSIA Fuchsia color
    CL_GRAY Gray color
    CL_GREEN Green color
    CL_LIME Lime color
    CL_MAROON Maroon color
    CL_NAVY Navy color
    CL_OLIVE Olive color
    CL_PURPLE Purple color
    CL_RED Red color
    CL_SILVER Silver color
    CL_TEAL Teal color
    CL_WHITE White color
    CL_YELLOW Yellow color

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Enable gradient from black to white color, left-right orientation
TFT_Set_Brush(0, 0, 1, LEFT_TO_RIGHT, CL_BLACK, CL_WHITE)

TFT_Line

Prototype

sub procedure TFT_Line(dim x1, y1, x2, y2 as integer)

Returns

Nothing.

Description

Draws a line from (x1, y1) to (x2, y2).

Parameters :

  • x1: x coordinate of the line start.
  • y1: y coordinate of the line end.
  • x2: x coordinate of the line start.
  • y2: y coordinate of the line end.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Line(0, 0, 239, 127)

TFT_H_Line

Prototype

sub procedure TFT_H_Line(dim x_start, x_end, y_pos as integer)

Returns

Nothing.

Description

Draws a horizontal line on TFT.

Parameters :

  • x_start: x coordinate of the line start.
  • x_end: x coordinate of the line end.
  • y_pos: y coordinate of horizontal line.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Draw a horizontal line between dots (10,20) and (50,20)
TFT_H_Line(10, 50, 20)

TFT_V_Line

Prototype

sub procedure TFT_V_Line(dim y_start, y_end, x_pos as integer)

Returns

Nothing.

Description

Draws a vertical line on TFT.

Parameters :

  • y_start: y coordinate of the line start.
  • y_end: y coordinate of the line end.
  • x_pos: x coordinate of vertical line.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Draw a vertical line between dots (10,5) and (10,25)
TFT_V_Line(5, 25, 10)

TFT_Rectangle

Prototype

sub procedure TFT_Rectangle(dim x_upper_left, y_upper_left, x_bottom_right, y_bottom_right as integer)

Returns

Nothing.

Description

Draws a rectangle on TFT.

Parameters :

  • x_upper_left: x coordinate of the upper left rectangle corner.
  • y_upper_left: y coordinate of the upper left rectangle corner.
  • x_bottom_right: x coordinate of the lower right rectangle corner.
  • y_bottom_right: y coordinate of the lower right rectangle corner.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Rectangle(20, 20, 219, 107)

TFT_Rectangle_Round_Edges

Prototype

sub procedure TFT_Rectangle_Round_Edges(dim x_upper_left, y_upper_left, x_bottom_right, y_bottom_right, round_radius as word)

Returns

Nothing.

Description

Draws a rounded edge rectangle on TFT.

Parameters :

  • x_upper_left: x coordinate of the upper left rectangle corner.
  • y_upper_left: y coordinate of the upper left rectangle corner.
  • x_bottom_right: x coordinate of the lower right rectangle corner.
  • y_bottom_right: y coordinate of the lower right rectangle corner.
  • round_radius: radius of the rounded edge.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Rectangle_Round_Edges(20, 20, 219, 107, 12)

TFT_Circle

Prototype

sub procedure TFT_Circle(dim x_center, y_center, radius as integer)

Returns

Nothing.

Description

Draws a circle on TFT.

Parameters :

  • x: x coordinate of the circle center.
  • y: y coordinate of the circle center.
  • r: radius size.

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Circle(120, 64, 110)

TFT_Image

Prototype

sub procedure TFT_Image(dim left, top as word, dim image as ^const far byte, dim stretch as word)

Returns

Nothing.

Description

Displays an image on a desired location.

Parameters :

  • left: position of the image's left edge.
  • top:position of the image's top edge.
  • image: image to be displayed. Bitmap array is located in code memory.
  • stretch: stretches image by a given factor (if 2, it will double the image.).
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Image(0, 0, @image, 1)

TFT_Ext_Image

Prototype

sub procedure TFT_Ext_Image(dim left, top as word, dim image as longword, dim stretch as word)

Returns

Nothing.

Description

Displays an image from an external resource on a desired address.

Parameters :

  • left: position of the image's left edge.
  • top:position of the image's top edge.
  • image: image to be displayed. This parameter represents the address in the exteral resource from where the image data begins.
  • stretch: stretches image by a given factor (if 2, it will double the image.).
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Ext_Image(0, 0, 153608, 1)

TFT_Partial_Image

Prototype

sub procedure TFT_Partial_Image(dim left, top, width, height as word, dim image as ^const far byte, dim stretch as word)

Returns

Nothing.

Description

Displays a partial area of the image on a desired location.

Parameters :

  • left: left coordinate of the image.
  • top: top coordinate of the image.
  • width: desired image width.
  • height: desired image height.
  • image: image to be displayed. Bitmap array is located in code memory.
  • stretch: stretches image by a given factor (if 2, it will double the image.).

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Draws a 10x15 part of the image starting from the upper left corner on the coordinate (10,12)  
TFT_PartialImage(10, 12, 10, 15, @image, 1)

TFT_Ext_Partial_Image

Prototype

sub procedure TFT_Ext_Partial_Image(dim left, top, width, height as word, dim image as longword, dim stretch as word)

Returns

Nothing.

Description

Displays a partial area of the image, located on an external resource, on a desired location of the screen.

Parameters :

  • left: left coordinate of the image.
  • top: top coordinate of the image.
  • width: desired image width.
  • height: desired image height.
  • image: image to be displayed. This parameter represents the address in the exteral resource from where the image data begins.
  • stretch: stretches image by a given factor (if 2, it will double the image.).

Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Ext_Partial_Image(159,0,160,120,0,1)

TFT_Image_Jpeg

Prototype

sub function TFT_Image_Jpeg(dim left, top as word, dim image as ^const far byte) as byte

Returns
  • 0 - if image is loaded and displayed successfully.
  • 1 - if error occured.
Description

Displays a JPEG image on a desired location.

Parameters :

  • left: left coordinate of the image.
  • top: top coordinate of the image.
  • image: image to be displayed. Bitmap array is located in code memory.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Image_Jpeg(0, 0, @image)

TFT_RGBToColor16bit

Prototype

sub function TFT_RGBToColor16bit(dim rgb_red, rgb_green, rgb_blue as byte) as word

Returns

Returns a color value in the following bit-order : 5 bits red, 6 bits green and 5 bits blue color.

Description

Converts 5:6:5 RGB format into true color format.

Parameters :

  • rgb_red: red component of the image.
  • rgb_green: green component of the image.
  • rgb_blue: blue component of the image.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
color16 = TFT_RGBToColor16bit(150, 193, 65)

TFT_Color16bitToRGB

Prototype

sub procedure TFT_Color16bitToRGB(dim color as word, dim rgb_red, rgb_green, rgb_blue as ^byte)

Returns

Nothing.

Description

Converts true color into 5:6:5 RGB format.

Parameters :

  • color: true color to be converted.
  • rgb_red: red component of the input color.
  • rgb_green: green component of the input color.
  • rgb_blue: blue component of the input color.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
TFT_Color16bitToRGB(start_color, @red_start, @green_start, @blue_start)

TFT_Rotate_180

Prototype

sub procedure TFT_Rotate_180(dim rotate as byte)

Returns

Nothing.

Description

Rotates the TFT display.

Parameters :

  • rotate: parameter for rotating display. Valid values :
    • 0 - display will not be rotated.
    • 1 - display will be rotated for 180 degrees.
Requires

TFT module needs to be initialized. Please, see appropriate TFT initialization routine.

Example
' Rotate TFT display for 180 degrees
TFT_Rotate_180(1)

' Initialize TFT display
TFT_Init(240, 320)

HW Connection

TFT HW connection

TFT HW connection

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code