SPI T6963C Graphic Lcd Library

The mikroPascal PRO for dsPIC30/33 and PIC24 provides a library for working with Glcds based on TOSHIBA T6963C controller via SPI interface. The Toshiba T6963C is a very popular Lcd controller for the use in small graphics modules. It is capable of controlling displays with a resolution up to 240x128. Because of its low power and small outline it is most suitable for mobile applications such as PDAs, MP3 players or mobile measurement equipment. Although this controller is small, it has a capability of displaying and merging text and graphics and it manages all interfacing signals to the displays Row and Column drivers.

For creating a custom set of Glcd images use Glcd Bitmap Editor Tool.

  Important :

Some mikroElektronika's adapter boards have pinout different from T6369C datasheets. Appropriate relations between these labels are given in the table below:

Adapter Board T6369C datasheet
RS C/D
R/W /RD
E /WR

Library Dependency Tree

SPI T6963C Library Dependency Tree

External dependencies of SPI T6963C Graphic Lcd Library

The implementation of SPI T6963C Graphic Lcd Library routines is based on Port Expander Library routines.

External dependencies are the same as Port Expander Library external dependencies.

Library Routines

SPI_T6963C_config

Prototype

procedure SPI_T6963C_config(width, height, fntW : word; DeviceAddress : byte; wr, rd, cd, rst : byte);

Description

Initializes T6963C Graphic Lcd controller.

Display RAM organization:
The library cuts RAM into panels : a complete panel is one graphics panel followed by a text panel (see schematic below).

+---------------------+ /\
+ GRAPHICS PANEL #0   +  |
+                     +  |
+                     +  |
+                     +  |
+---------------------+  | PANEL 0
+ TEXT PANEL #0       +  |
+                     + \/
+---------------------+ /\
+ GRAPHICS PANEL #1   +  |
+                     +  |
+                     +  |
+                     +  |
+---------------------+  | PANEL 1
+ TEXT PANEL #1       +  |
+                     +  |
+---------------------+ \/            	
            
Parameters
  • width: width of the Glcd panel
  • height: height of the Glcd panel
  • fntW: font width
  • DeviceAddress: SPI expander hardware address, see schematic at the bottom of this page
  • wr: write signal pin on Glcd control port
  • rd: read signal pin on Glcd control port
  • cd: command/data signal pin on Glcd control port
  • rst: reset signal pin on Glcd control port
Returns

Nothing.

Requires Global variables :
  • SPExpanderCS: Chip Select line
  • SPExpanderRST: Reset line
  • SPExpanderCS_Direction: Direction of the Chip Select pin
  • SPExpanderRST_Direction: Direction of the Reset pin
must be defined before using this function.


The SPI module needs to be initialized. See the SPIx_Init and SPIx_Init_Advanced routines.

Example
// Port Expander module connections
   SPExpanderRST : sbit at LATF0_bit;
   SPExpanderCS  : sbit at LATF1_bit;
   SPExpanderRST_Direction : sbit at TRISF0_bit;
   SPExpanderCS_Direction  : sbit at TRISF1_bit;
// End Port Expander module connections
...
// Initialize SPI module
SPI1_Init();
SPI_T6963C_config(240, 64, 8, 0, 0, 1, 3, 4);
Notes

None.

SPI_T6963C_writeData

Prototype

procedure SPI_T6963C_writeData(data_ : byte);

Description

Writes data to T6963C controller via SPI interface.

Parameters
  • data_: data to be written
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_writeData(data_);
Notes

None.

SPI_T6963C_writeCommand

Prototype

procedure SPI_T6963C_writeCommand(data_ : byte);

Description

Writes command to T6963C controller via SPI interface.

Parameters
  • data_: command to be written
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_writeCommand(SPI_T6963C_CURSOR_POINTER_SET);
Notes

None.

SPI_T6963C_setPtr

Prototype

procedure SPI_T6963C_setPtr(p : word; c : byte);

Description

Sets the memory pointer p for command p.

Parameters
  • p: address where command should be written
  • c: command to be written
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_setPtr(SPI_T6963C_grHomeAddr + start, SPI_T6963C_ADDRESS_POINTER_SET);
Notes

None.

SPI_T6963C_Set_Ext_Buffer

Prototype

procedure SPI_T6963C_Set_Ext_Buffer(getExtDataPtr : ^TSPI_T6963C_Get_Ext_Data_Ptr);

Returns

Nothing.

Description

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

Parameters :

  • TSPI_T6963C_Get_Ext_Data_Ptr - pointer to the user function.

User function prototype should be in the following format: function External(offset : dword; count : word; var num : word) : ^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

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
T6963C_Set_Ext_Buffer(@ReadExternalBuffer);

SPI_T6963C_waitReady

Prototype

procedure SPI_T6963C_waitReady();

Description

Pools the status byte, and loops until Toshiba Glcd module is ready.

Parameters

None.

Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_waitReady();
Notes

None.

SPI_T6963C_fill

Prototype

procedure SPI_T6963C_fill(v : byte; start, len : word);

Description

Fills controller memory block with given byte.

Parameters
  • v: byte to be written
  • start: starting address of the memory block
  • len: length of the memory block in bytes
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_fill(0x33,0x00FF,0x000F);
Notes

None.

SPI_T6963C_dot

Prototype

procedure SPI_T6963C_dot(x, y : integer; color : byte);

Description

Draws a dot in the current graphic panel of Glcd at coordinates (x, y).

Parameters
  • x: dot position on x-axis
  • y: dot position on y-axis
  • color: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_dot(x0, y0, SPI_T6963C_BLACK);
Notes

None.

SPI_T6963C_Set_Font_Adv

Prototype

procedure SPI_T6963C_Set_Font_Adv(activeFont : ^const far byte; font_color : word; font_orientation : byte);

Description

Sets font that will be used with SPI_T6963C_Write_Char_Adv and SPI_T6963C_Write_Text_Adv routines.

Parameters
  • activeFont: font to be set. Needs to be formatted as an array of char.
  • font_color: sets font color.
  • font_orientation: sets font orientation.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_Set_Font_Adv(@myfont, 0, 0);
Notes

None.

SPI_T6963C_Set_Ext_Font_Adv

Prototype

procedure SPI_T6963C_Set_Ext_Font_Adv(activeFont : dword; font_color : word; font_orientation : word);

Description

Sets font that will be used with SPI_T6963C_Write_Char_Adv and SPI_T6963C_Write_Text_Adv routines. Font is located in an external resource.

Parameters
  • activeFont: font to be set. This parameter represents the address in the exteral resource from where the font data begins.
  • font_color: sets font color.
  • font_orientation: sets font orientation.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_Set_Ext_Font_Adv(173296, 0, 0);
Notes

None.

SPI_T6963C_write_char

Prototype

procedure SPI_T6963C_write_char(c, x, y, mode : byte);

Description

Writes a char in the current text panel of Glcd at coordinates (x, y).

Parameters
  • c: char to be written
  • x: char position on x-axis
  • y: char position on y-axis
  • mode: mode parameter. Valid values: SPI_T6963C_ROM_MODE_OR, SPI_T6963C_ROM_MODE_XOR, SPI_T6963C_ROM_MODE_AND and SPI_T6963C_ROM_MODE_TEXT

Mode parameter explanation:

  • OR Mode: In the OR-Mode, text and graphics can be displayed and the data is logically "OR-ed". This is the most common way of combining text and graphics for example labels on buttons.
  • XOR-Mode: In this mode, the text and graphics data are combined via the logical "exclusive OR". This can be useful to display text in the negative mode, i.e. white text on black background.
  • AND-Mode: The text and graphic data shown on display are combined via the logical "AND function".
  • TEXT-Mode: This option is only available when displaying just a text. The Text Attribute values are stored in the graphic area of display memory.
For more details see the T6963C datasheet.

Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_write_char('A',22,23,SPI_T6963C_ROM_MODE_AND);
Notes

None.

SPI_T6963C_write_char_adv

Prototype

procedure SPI_T6963C_Write_Char_Adv(ch, x, y : word);

Description

Writes a char in the current text panel of Glcd at coordinates (x, y).

Parameters
  • c: char to be written
  • x: char position on x-axis
  • y: char position on y-axis
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_write_char_adv('A',22,23);
Notes

None.

SPI_T6963C_write_text

Prototype

procedure SPI_T6963C_write_text(var str : string; x, y, mode : byte);

Description

Writes text in the current text panel of Glcd at coordinates (x, y).

Parameters
  • str: text to be written
  • x: text position on x-axis
  • y: text position on y-axis
  • mode: mode parameter. Valid values: SPI_T6963C_ROM_MODE_OR, SPI_T6963C_ROM_MODE_XOR, SPI_T6963C_ROM_MODE_AND and SPI_T6963C_ROM_MODE_TEXT

Mode parameter explanation:

  • OR Mode: In the OR-Mode, text and graphics can be displayed and the data is logically "OR-ed". This is the most common way of combining text and graphics for example labels on buttons.
  • XOR-Mode: In this mode, the text and graphics data are combined via the logical "exclusive OR". This can be useful to display text in the negative mode, i.e. white text on black background.
  • AND-Mode: The text and graphic data shown on display are combined via the logical "AND function".
  • TEXT-Mode: This option is only available when displaying just a text. The Text Attribute values are stored in the graphic area of display memory.
For more details see the T6963C datasheet.

Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_write_text('GLCD LIBRARY DEMO, WELCOME !', 0, 0, SPI_T6963C_ROM_MODE_XOR);
Notes

None.

SPI_T6963C_Write_Text_Adv

Prototype

procedure SPI_T6963C_Write_Text_Adv(var text : string; x, y : word);

Description

Writes text in the current text panel of Glcd at coordinates (x, y).

Parameters
  • str: text to be written
  • x: text position on x-axis
  • y: text position on y-axis
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_Write_Text_Adv("Glcd LIBRARY DEMO, WELCOME !", 0, 0);	
Notes

None.

SPI_T6963C_Write_Const_Text_Adv

Prototype

procedure SPI_T6963C_Write_Const_Text_Adv(text : ^const far byte; x, y : word);

Description

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

Parameters
  • str: text to be written
  • x: text position on x-axis
  • y: text position on y-axis
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
const ctext = 'mikroElektronika'; 
...
SPI_T6963C_Write_Const_Text_Adv(@ctext, 0, 0);
Notes

None.

SPI_T6963C_line

Prototype

procedure SPI_T6963C_line(x0, y0, x1, y1 : integer; pcolor : byte);

Description

Draws a line from (x0, y0) to (x1, y1).

Parameters
  • x0: x coordinate of the line start
  • y0: y coordinate of the line end
  • x1: x coordinate of the line start
  • y1: y coordinate of the line end
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_line(0, 0, 239, 127, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_rectangle

Prototype

procedure SPI_T6963C_rectangle(x0, y0, x1, y1 : integer; pcolor : byte);

Description

Draws a rectangle on Glcd.

Parameters
  • x0: x coordinate of the upper left rectangle corner
  • y0: y coordinate of the upper left rectangle corner
  • x1: x coordinate of the lower right rectangle corner
  • y1: y coordinate of the lower right rectangle corner
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_rectangle(20, 20, 219, 107, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_rectangle_round_edges

Prototype

procedure SPI_T6963C_rectangle_round_edges(x0 : integer; y0 : integer; x1 : integer; y1 : integer; radius : integer; pcolor : byte);

Description

Draws a rounded edge rectangle on Glcd.

Parameters
  • x0: x coordinate of the upper left rectangle corner
  • y0: y coordinate of the upper left rectangle corner
  • x1: x coordinate of the lower right rectangle corner
  • y1: y coordinate of the lower right rectangle corner
  • round_radius: radius of the rounded edge.
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_rectangle_round_edges(20, 20, 219, 107, 12, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_rectangle_round_edges_fill

Prototype

procedure SPI_T6963C_rectangle_round_edges_fill(x0 : integer; y0 : integer; x1 : integer; y1 : integer; radius : integer; pcolor : byte);

Description

Draws a filled rounded edge rectangle on Glcd.

Parameters
  • x0: x coordinate of the upper left rectangle corner
  • y0: y coordinate of the upper left rectangle corner
  • x1: x coordinate of the lower right rectangle corner
  • y1: y coordinate of the lower right rectangle corner
  • round_radius: radius of the rounded edge
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_rectangle_round_edges_fill(20, 20, 219, 107, 12, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_box

Prototype

procedure SPI_T6963C_box(x0, y0, x1, y1 : integer; pcolor : byte);

Description

Draws a box on the Glcd

Parameters
  • x0: x coordinate of the upper left box corner
  • y0: y coordinate of the upper left box corner
  • x1: x coordinate of the lower right box corner
  • y1: y coordinate of the lower right box corner
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_box(0, 119, 239, 127, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_circle

Prototype

procedure SPI_T6963C_circle(x, y : integer; r : longint; pcolor : word);

Description

Draws a circle on the Glcd.

Parameters
  • x: x coordinate of the circle center
  • y: y coordinate of the circle center
  • r: radius size
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_circle(120, 64, 110, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_circle_fill

Prototype

procedure SPI_T6963C_circle_fill(x : integer; y : integer; r : longint; pcolor : word);

Description

Draws a filled circle on the Glcd.

Parameters
  • x: x coordinate of the circle center
  • y: y coordinate of the circle center
  • r: radius size
  • pcolor: color parameter. Valid values: SPI_T6963C_BLACK, SPI_T6963C_WHITE or SPI_T6963C_INVERT
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_circle_fill(120, 64, 110, SPI_T6963C_WHITE);
Notes

None.

SPI_T6963C_image

Prototype

procedure SPI_T6963C_image(pic : ^ const far byte);

Description

Displays bitmap on Glcd.

Parameters
  • pic: image to be displayed. Bitmap array can be located in both code and RAM memory (due to the mikroPascal PRO for dsPIC30/33 and PIC24 pointer to const and pointer to RAM equivalency).
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_image(@my_image);
Notes

Image dimension must match the display dimension.

Use the integrated Glcd Bitmap Editor (menu option Tools › Glcd Bitmap Editor) to convert image to a constant array suitable for displaying on Glcd.

SPI_T6963C_Ext_Image

Prototype

procedure SPI_T6963C_Ext_Image(image : dword);

Description

Displays a bitmap from an external resource.

Parameters
  • pic: image to be displayed. This parameter represents the address in the exteral resource from where the image data begins.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_Ext_image(153608);
Notes

Image dimension must match the display dimension.

Use the integrated Glcd Bitmap Editor (menu option Tools › Glcd Bitmap Editor) to convert image to a constant array suitable for displaying on Glcd.

SPI_T6963C_PartialImage

Prototype

procedure SPI_T6963C_PartialImage(x_left, y_top, width, height, picture_width, picture_height : word; const image : ^byte);

Description

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

Parameters
  • x_left: x coordinate of the desired location (upper left coordinate).
  • y_top: y coordinate of the desired location (upper left coordinate).
  • width: desired image width.
  • height: desired image height.
  • picture_width: width of the original image.
  • picture_height: height of the original image.
  • image: image to be displayed. Bitmap array can be located in both code and RAM memory (due to the mikroPascal PRO for PIC pointer to const and pointer to RAM equivalency).
Description

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

Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// Draws a 10x15 part of the image starting from the upper left corner on the coordinate (10,12). Original image size is 16x32. 
SPI_T6963C_PartialImage(10, 12, 10, 15, 16, 32, @image);
Notes

Image dimension must match the display dimension.

Use the integrated Glcd Bitmap Editor (menu option Tools › Glcd Bitmap Editor) to convert image to a constant array suitable for displaying on Glcd.

SPI_T6963C_Ext_PartialImage

Prototype

procedure SPI_T6963C_Ext_PartialImage(x_left, y_top, width, height, picture_width, picture_height : word; image : dword);

Description

Displays a partial area of the image (from an external resource) on a desired location.

Parameters
  • x_left: x coordinate of the desired location (upper left coordinate).
  • y_top: y coordinate of the desired location (upper left coordinate).
  • width: desired image width.
  • height: desired image height.
  • picture_width: width of the original image.
  • picture_height: height of the original image.
  • image: image to be displayed. This parameter represents the address in the exteral resource from where the image data begins.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_Ext_PartialImage(10, 12, 10, 15, 16, 32, 0);
Notes

Image dimension must match the display dimension.

Use the integrated Glcd Bitmap Editor (menu option Tools › Glcd Bitmap Editor) to convert image to a constant array suitable for displaying on Glcd.

SPI_T6963C_sprite

Prototype

procedure SPI_T6963C_sprite(px, py : byte; const pic : ^byte; sx, sy : byte);

Description

Fills graphic rectangle area (px, py) to (px+sx, py+sy) with custom size picture.

Parameters
  • px: x coordinate of the upper left picture corner. Valid values: multiples of the font width
  • py: y coordinate of the upper left picture corner
  • pic: picture to be displayed
  • sx: picture width. Valid values: multiples of the font width
  • sy: picture height
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_sprite(76, 4, einstein, 88, 119); // draw a sprite
Notes

If px and sx parameters are not multiples of the font width they will be scaled to the nearest lower number that is a multiple of the font width.

SPI_T6963C_set_cursor

Prototype

procedure SPI_T6963C_set_cursor(x, y : byte);

Description

Sets cursor to row x and column y.

Parameters
  • x: cursor position row number
  • y: cursor position column number
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_set_cursor(cposx, cposy);
Notes

None.

SPI_T6963C_clearBit

Prototype

procedure SPI_T6963C_clearBit(b : byte);

Description

Clears control port bit(s).

Parameters
  • b: bit mask. The function will clear bit x on control port if bit x in bit mask is set to 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// clear bits 0 and 1 on control port
SPI_T6963C_clearBit(0x03);
Notes

None.

SPI_T6963C_setBit

Prototype

procedure SPI_T6963C_setBit(b : byte);

Description

Sets control port bit(s).

Parameters
  • b: bit mask. The function will set bit x on control port if bit x in bit mask is set to 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// set bits 0 and 1 on control port
SPI_T6963C_setBit(0x03);
Notes

None.

SPI_T6963C_negBit

Prototype

procedure SPI_T6963C_negBit(b : byte);

Description

Negates control port bit(s).

Parameters
  • b: bit mask. The function will negate bit x on control port if bit x in bit mask is set to 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// negate bits 0 and 1 on control port
SPI_T6963C_negBit(0x03);
Notes

None.

SPI_T6963C_displayGrPanel

Prototype

procedure SPI_T6963C_displayGrPanel(n : word);

Description

Display selected graphic panel.

Parameters
  • n: graphic panel number. Valid values: 0 and 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// display graphic panel 1
SPI_T6963C_displayGrPanel(1);
Notes

None.

SPI_T6963C_displayTxtPanel

Prototype

procedure SPI_T6963C_displayTxtPanel(n : word);

Description

Display selected text panel.

Parameters
  • n: text panel number. Valid values: 0 and 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// display text panel 1
SPI_T6963C_displayTxtPanel(1);
Notes

None.

SPI_T6963C_setGrPanel

Prototype

procedure SPI_T6963C_setGrPanel(n : word);

Description

Compute start address for selected graphic panel and set appropriate internal pointers. All subsequent graphic operations will be preformed at this graphic panel.

Parameters
  • n: graphic panel number. Valid values: 0 and 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// set graphic panel 1 as current graphic panel.
SPI_T6963C_setGrPanel(1);
Notes

None.

SPI_T6963C_setTxtPanel

Prototype

procedure SPI_T6963C_setTxtPanel(n : word);

Description

Compute start address for selected text panel and set appropriate internal pointers. All subsequent text operations will be preformed at this text panel.

Parameters
  • n: text panel number. Valid values: 0 and 1.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// set text panel 1 as current text panel.
SPI_T6963C_setTxtPanel(1);
Notes

None.

SPI_T6963C_panelFill

Prototype

procedure SPI_T6963C_panelFill(v : word);

Description

Fill current panel in full (graphic+text) with appropriate value (0 to clear).

Parameters
  • v: value to fill panel with.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
clear current panel
SPI_T6963C_panelFill(0);
Notes

None.

SPI_T6963C_grFill

Prototype

procedure SPI_T6963C_grFill(v: word);

Description

Fill current graphic panel with appropriate value (0 to clear).

Parameters
  • v: value to fill graphic panel with.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// clear current graphic panel
SPI_T6963C_grFill(0);
Notes

None.

SPI_T6963C_txtFill

Prototype

procedure SPI_T6963C_txtFill(v : word);

Description

Fill current text panel with appropriate value (0 to clear).

Parameters
  • v: this value increased by 32 will be used to fill text panel.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// clear current text panel
SPI_T6963C_txtFill(0);
Notes

None.

SPI_T6963C_cursor_height

Prototype

procedure SPI_T6963C_cursor_height(n: byte);

Description

Set cursor size.

Parameters
  • n: cursor height. Valid values: 0..7.
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
SPI_T6963C_cursor_height(7);
Notes

None.

SPI_T6963C_graphics

Prototype

procedure SPI_T6963C_graphics(n : word);

Description

Enable/disable graphic displaying.

Parameters
  • n: graphic enable/disable parameter. Valid values: 0 (disable graphic dispaying) and 1 (enable graphic displaying).
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// enable graphic displaying
SPI_T6963C_graphics(1);
Notes

None.

SPI_T6963C_text

Prototype

procedure SPI_T6963C_text(n : word);

Description

Enable/disable text displaying.

Parameters
  • n: text enable/disable parameter. Valid values: 0 (disable text dispaying) and 1 (enable text displaying).
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// enable text displaying
SPI_T6963C_text(1);
Notes

None.

SPI_T6963C_cursor

Prototype

procedure SPI_T6963C_cursor(n : word);

Description

Set cursor on/off.

Parameters
  • n: on/off parameter. Valid values: 0 (set cursor off) and 1 (set cursor on).
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// set cursor on
SPI_T6963C_cursor(1);
Notes

None.

Prototype

procedure SPI_T6963C_cursor_blink(n : word);

Description

Enable/disable cursor blinking.

Parameters
  • n: cursor blinking enable/disable parameter. Valid values: 0 (disable cursor blinking) and 1 (enable cursor blinking).
Returns

Nothing.

Requires

Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine.

Example
// enable cursor blinking
SPI_T6963C_cursor_blink(1);
Notes

None.

Library Example

The following drawing demo tests advanced routines of the SPI T6963C Glcd library. Hardware configurations in this example are made for the EasydsPIC4A board and dsPIC30F4013.

Copy Code To ClipboardCopy Code To Clipboard
program SPI_T6963C_240x128;

uses __Lib_SPIT6963C_Const;

var
// Port Expander module connections
   SPExpanderRST : sbit at LATF0_bit;  // for writing to output pin always use latch (PIC18 family)
   SPExpanderCS  : sbit at LATF1_bit;  // for writing to output pin always use latch (PIC18 family)
   SPExpanderRST_Direction : sbit at TRISF0_bit;
   SPExpanderCS_Direction  : sbit at TRISF1_bit;
// End Port Expander module connections

var   panel : byte;         // current panel
          i : word;         // general purpose register
      curs  : byte;         // cursor visibility
      cposx,
      cposy : word;         // cursor x-y position
      txt, txt1 : string[29];

begin

  txt1 := ' EINSTEIN WOULD HAVE LIKED mE';
  txt  := ' GLCD LIBRARY DEMO, WELCOME !';

  {$DEFINE COMPLETE_EXAMPLE}// comment this line to make simpler/smaller example
  ADPCFG := 0xFFFF;                              // initialize AN pins as digital

  TRISB8_bit := 1;              // Set RB8 as input
  TRISB9_bit := 1;              // Set RB9 as input
  TRISB10_bit := 1;             // Set RB10 as input
  TRISB11_bit := 1;             // Set RB11 as input
  TRISB12_bit := 1;             // Set RB12 as input

  {*
  * init display for 240 pixel width and 128 pixel height
  * 8 bits character width
  * data bus on MCP23S17 portB
  * control bus on MCP23S17 portA
  * bit 2 is !WR
  * bit 1 is !RD
  * bit 0 is !CD
  * bit 4 is RST
  * chip enable, reverse on, 8x8 font internaly set in library
  *}

  // If Port Expander Library uses SPI1 module
  SPI1_Init();                                   // Initialize SPI module used with PortExpander

  {*
   * init display for 240 pixel width and 128 pixel height
   * 8 bits character width
   * data bus on MCP23S17 portB
   * control bus on MCP23S17 portA
   * bit 2 is !WR
   * bit 1 is !RD
   * bit 0 is !CD
   * bit 4 is RST
   * chip enable, reverse on, 8x8 font internaly set in library
   *}

  SPI_T6963C_Config(240, 128, 8, 0, 2, 1, 0, 4);
  Delay_ms(1000);

  {*
   * Enable both graphics and text display at the same time
   *}

  SPI_T6963C_graphics(1);
  SPI_T6963C_text(1);

  panel := 0;
  i := 0;
  curs := 0;
  cposx := 0;
  cposy := 0;

  {*
   * Text messages
   *}
  SPI_T6963C_write_text(txt, 0, 0, SPI_T6963C_ROM_MODE_XOR);
  SPI_T6963C_write_text(txt1, 0, 15, SPI_T6963C_ROM_MODE_XOR);

  {*
   * Cursor
   *}
  SPI_T6963C_cursor_height(8);       // 8 pixel height
  SPI_T6963C_set_cursor(0, 0);       // Move cursor to top left
  SPI_T6963C_cursor(0);              // Cursor off

  {*
   * Draw rectangles
   *}
  SPI_T6963C_rectangle(0, 0, 239, 127, SPI_T6963C_WHITE);
  SPI_T6963C_rectangle(20, 20, 219, 107, SPI_T6963C_WHITE);
  SPI_T6963C_rectangle(40, 40, 199, 87, SPI_T6963C_WHITE);
  SPI_T6963C_rectangle(60, 60, 179, 67, SPI_T6963C_WHITE);

  {*
   * Draw a cross
   *}
  SPI_T6963C_line(0, 0, 239, 127, SPI_T6963C_WHITE);
  SPI_T6963C_line(0, 127, 239, 0, SPI_T6963C_WHITE);

  {*
   * Draw solid boxes
   *}
  SPI_T6963C_box(0, 0, 239, 8, SPI_T6963C_WHITE);
  SPI_T6963C_box(0, 119, 239, 127, SPI_T6963C_WHITE);

  {*
   * Draw circles
   *}
  {$IFDEF COMPLETE_EXAMPLE}
  SPI_T6963C_circle(120, 64, 10, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 30, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 50, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 70, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 90, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 110, SPI_T6963C_WHITE);
  SPI_T6963C_circle(120, 64, 130, SPI_T6963C_WHITE);

  SPI_T6963C_sprite(76, 4, @einstein_bmp, 88, 119);  // Draw a sprite
  SPI_T6963C_setGrPanel(1);                          // Select other graphic panel
  SPI_T6963C_image(@mikroE_240x128_bmp);             // Fill the graphic screen with a picture
  {$ENDIF}

  while (TRUE) do                                     // Endless loop
    begin

      {*
       * If RB8 is pressed, toggle the display between graphic panel 0 and graphic 1
       *}
      if(RB8_bit <> 0) then
        begin
          SPI_T6963C_graphics(1);
          SPI_T6963C_text(0);
          Delay_ms(300);
        end

      {*
       * If RB9 is pressed, display only graphic panel
       *}
     {$IFDEF COMPLETE_EXAMPLE}
      else
        if (RB9_bit <> 0) then
          begin
            Inc(panel);
            panel := panel and 1;
            SPI_T6963C_displayGrPanel(panel);
            Delay_ms(300);
          end
      {$ENDIF}
      {*
       * If RB10 is pressed, display only text panel
       *}
        else
          if (RB10_bit <> 0) then
            begin
              SPI_T6963C_graphics(0);
              SPI_T6963C_text(1);
              Delay_ms(300);
            end

      {*
       * If RB11 is pressed, display text and graphic panels
       *}
          else
            if (RB11_bit <> 0) then
              begin
                SPI_T6963C_graphics(1);
                SPI_T6963C_text(1);
                Delay_ms(300);
              end

      {*
       * If RB12 is pressed, change cursor
       *}
            else
              if(RB12_bit <> 0) then
                begin
                  Inc(curs);
                  if (curs = 3) then
                    curs := 0;
                  case curs of
                    0:
                       // no cursor
                       SPI_T6963C_cursor(0);

                    1: begin
                         // blinking cursor
                         SPI_T6963C_cursor(1);
                         SPI_T6963C_cursor_blink(1);
                       end;
                    2: begin
                         // non blinking cursor
                         SPI_T6963C_cursor(1);
                         SPI_T6963C_cursor_blink(0);
                       end;
                  end;
                  Delay_ms(300);
                end;

      {*
       * Move cursor, even if not visible
       *}
      Inc(cposx);
      if (cposx = SPI_T6963C_txtCols) then
        begin
          cposx := 0;
          Inc(cposy);
          if (cposy = SPI_T6963C_grHeight div SPI_T6963C_CHARACTER_HEIGHT) then
            cposy := 0;
        end;
      SPI_T6963C_set_cursor(cposx, cposy);

      Delay_ms(100);
    end;
end.

HW Connection

SPI T6963C Glcd HW connection

SPI T6963C Glcd 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