SPI T6963C Graphic Lcd Library
The mikroBasic PRO for ARM 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 :
- When using this library with ARM family MCUs be aware of their voltage incompatibility with certain number of T6963C based Glcd modules. So, additional external power supply for these modules may be required.
- Glcd size based initialization routines can be found in setup library files located in the Uses folder.
- The user must make sure that used MCU has appropriate ports and pins. If this is not the case the user should adjust initialization routines.
- The library uses the SPI module for communication. The user must initialize the appropriate SPI module before using the SPI T6963C Glcd Library.
- For MCUs with multiple SPI modules it is possible to initialize both of them and then switch by using the
SPI_Set_Active()routine. See the SPI Library functions. - This Library is designed to work with mikroElektronika's Serial Glcd 240x128 and 240x64 Adapter Boards pinout, see schematic at the bottom of this page for details.
- To use constants located in
__Lib_SPIT6963C_Const.mbasfile, user must include it the source file :include __Lib_SPIT6963C_Const.
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
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
- SPI_T6963C_writeData
- SPI_T6963C_writeCommand
- SPI_T6963C_setPtr
- SPI_T6963C_Set_Ext_Buffer
- SPI_T6963C_waitReady
- SPI_T6963C_fill
- SPI_T6963C_dot
- SPI_T6963C_Set_Font_Adv
- SPI_T6963C_Set_Font_Ext_Adv
- SPI_T6963C_write_char
- SPI_T6963C_Write_Char_Adv
- SPI_T6963C_Write_Text
- SPI_T6963C_Write_Text_Adv
- SPI_T6963C_line
- SPI_T6963C_rectangle
- SPI_T6963C_rectangle_round_edges
- SPI_T6963C_rectangle_round_edges_fill
- SPI_T6963C_box
- SPI_T6963C_circle
- SPI_T6963C_circle_fill
- SPI_T6963C_image
- SPI_T6963C_Ext_Image
- SPI_T6963C_PartialImage
- SPI_T6963C_Ext_PartialImage
- SPI_T6963C_sprite
- SPI_T6963C_set_cursor
- SPI_T6963C_clearBit
- SPI_T6963C_setBit
- SPI_T6963C_negBit
- SPI_T6963C_displayGrPanel
- SPI_T6963C_displayTxtPanel
- SPI_T6963C_setGrPanel
- SPI_T6963C_setTxtPanel
- SPI_T6963C_panelFill
- SPI_T6963C_grFill
- SPI_T6963C_txtFill
- SPI_T6963C_cursor_height
- SPI_T6963C_graphics
- SPI_T6963C_text
- SPI_T6963C_cursor
- SPI_T6963C_cursor_blink
SPI_T6963C_config
| Prototype |
sub procedure SPI_T6963C_config(dim width, height, fntW as word, dim DeviceAddress as byte, dim wr, rd, cd, rst as byte) |
|---|---|
| Description |
Initializes T6963C Graphic Lcd controller. Display RAM organization:
+---------------------+ /\
+ GRAPHICS PANEL #0 + |
+ + |
+ + |
+ + |
+---------------------+ | PANEL 0
+ TEXT PANEL #0 + |
+ + \/
+---------------------+ /\
+ GRAPHICS PANEL #1 + |
+ + |
+ + |
+ + |
+---------------------+ | PANEL 1
+ TEXT PANEL #1 + |
+ + |
+---------------------+ \/
|
| Parameters |
|
| Returns |
Nothing. |
| Requires |
External dependencies are the same as Port Expander Library external dependencies.
|
| Example |
Stellarisdim ' Port Expander module connections SPExpanderRST as sbit at GPIO_PORTA_DATA.B0 ' for writing to output pin always use latch SPExpanderCS as sbit at GPIO_PORTA_DATA.B1 ' for writing to output pin always use latch SPExpanderRST_Direction as sbit at GPIO_PORTA_DIR.B0 SPExpanderCS_Direction as sbit at GPIO_PORTA_DIR.B1 ' End Port Expander module connections ... ' Initialize SPI module SPI1_Init() SPI_T6963C_Config(240, 64, 8, 0, 0, 1, 3, 4) STM32
' Port Expander module connections
dim SPExpanderRST as sbit at GPIOB_ODR.B0
SPExpanderCS as sbit at GPIOB_ODR.B1
' 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 |
sub procedure SPI_T6963C_writeData(dim data_ as byte) |
|---|---|
| Description |
Writes data to T6963C controller via SPI interface. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_writeCommand(dim data_ as byte) |
|---|---|
| Description |
Writes command to T6963C controller via SPI interface. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_setPtr(dim p as word, dim c as byte) |
|---|---|
| Description |
Sets the memory pointer |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_Set_Ext_Buffer(dim getExtDataPtr as ^TSPI_T6963C_Get_Ext_Data_Ptr) |
|---|---|
| Returns |
Nothing. |
| Description |
Function sets pointer to the user function which manipulates the external resource. Parameters :
User function prototype should be in the following format: Parameters used in the function have the following meaning :
|
| Requires |
Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine. |
| Example |
SPI_T6963C_Set_Ext_Buffer(@ReadExternalBuffer) |
SPI_T6963C_waitReady
| Prototype |
sub 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 |
sub procedure SPI_T6963C_fill(dim v as byte, dim start, len as word) |
|---|---|
| Description |
Fills controller memory block with given byte. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_dot(dim x, y as integer, dim color as byte) |
|---|---|
| Description |
Draws a dot in the current graphic panel of Glcd at coordinates (x, y). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_Set_Font_Adv(dim activeFont as ^const byte, dim font_color as word, dim font_orientation as byte) |
|---|---|
| Description |
Sets font that will be used with SPI_T6963C_Write_Char_Adv and SPI_T6963C_Write_Text_Adv routines. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine. |
| Example |
SPI_T6963C_Set_Font_Adv(@myfont, 1, 0) |
| Notes |
None. |
SPI_T6963C_Set_Ext_Font_Adv
| Prototype |
sub procedure SPI_T6963C_Set_Ext_Font_Adv(dim activeFont as longword, dim font_color as word, dim font_orientation as 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 |
|
| 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 |
sub procedure SPI_T6963C_write_char(dim c, x, y, mode as byte) |
|---|---|
| Description |
Writes a char in the current text panel of Glcd at coordinates (x, y). |
| Parameters |
Mode parameter explanation:
|
| 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 |
sub procedure SPI_T6963C_write_char_adv(dim ch, x, y as word) |
|---|---|
| Description |
Writes a char in the current text panel of Glcd at coordinates (x, y). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_write_text(dim byref str as byte[10], dim x, y, mode as byte) |
|---|---|
| Description |
Writes text in the current text panel of Glcd at coordinates (x, y). |
| Parameters |
Mode parameter explanation:
|
| 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 |
sub procedure SPI_T6963C_Write_Text_Adv(dim byref text as string, dim x, y as word) |
|---|---|
| Description |
Writes text in the current text panel of Glcd at coordinates (x, y). |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Toshiba Glcd module needs to be initialized. See SPI_T6963C_Config routine. |
| Example |
T6963C_Write_Text_Adv("Glcd LIBRARY DEMO, WELCOME !", 0, 0)
|
| Notes |
None. |
SPI_T6963C_line
| Prototype |
sub procedure SPI_T6963C_line(dim x0, y0, x1, y1 as integer, dim pcolor as byte) |
|---|---|
| Description |
Draws a line from (x0, y0) to (x1, y1). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_rectangle(dim x0, y0, x1, y1 as integer, dim pcolor as byte) |
|---|---|
| Description |
Draws a rectangle on Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_rectangle_round_edges(dim x0 as integer, dim y0 as integer, dim x1 as integer, dim y1 as integer, dim radius as integer, dim pcolor as byte) |
|---|---|
| Description |
Draws a rounded edge rectangle on Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_rectangle_round_edges_fill(dim x0 as integer, dim y0 as integer, dim x1 as integer, dim y1 as integer, dim radius as integer, dim pcolor as byte) |
|---|---|
| Description |
Draws a filled rounded edge rectangle on Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_box(dim x0, y0, x1, y1 as integer, dim pcolor as byte) |
|---|---|
| Description |
Draws a box on the Glcd |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_circle(dim x, y as integer, dim r as longint, dim pcolor as word) |
|---|---|
| Description |
Draws a circle on the Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_circle_fill(dim x as integer, dim y as integer, dim r as longint, dim pcolor as byte) |
|---|---|
| Description |
Draws a filled circle on the Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_image(dim pic as ^ const byte) |
|---|---|
| Description |
Displays bitmap on Glcd. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_Ext_Image(dim image as longword) |
|---|---|
| Description |
Displays a bitmap from an external resource. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_PartialImage(dim x_left, y_top, width, height, picture_width, picture_height as word, const image as ^byte) |
|---|---|
| Description |
Displays a partial area of the image on a desired location. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_Ext_PartialImage(dim x_left, y_top, width, height, picture_width, picture_height as word, dim image as longword) |
|---|---|
| Description |
Displays a partial area of the image (from an external resource) on a desired location. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_sprite(dim px, py as byte, dim const pic as ^byte, dim sx, sy as byte) |
|---|---|
| Description |
Fills graphic rectangle area (px, py) to (px+sx, py+sy) with custom size picture. |
| Parameters |
|
| 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 |
SPI_T6963C_set_cursor
| Prototype |
sub procedure SPI_T6963c_set_cursor(dim x, y as byte) |
|---|---|
| Description |
Sets cursor to row x and column y. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_clearBit(dim b as byte) |
|---|---|
| Description |
Clears control port bit(s). |
| Parameters |
|
| 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(0x0003) |
| Notes |
None. |
SPI_T6963C_setBit
| Prototype |
sub procedure SPI_T6963C_setBit(dim b as byte) |
|---|---|
| Description |
Sets control port bit(s). |
| Parameters |
|
| 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(0x0003) |
| Notes |
None. |
SPI_T6963C_negBit
| Prototype |
sub procedure SPI_T6963C_negBit(dim b as byte) |
|---|---|
| Description |
Negates control port bit(s). |
| Parameters |
|
| 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(0x0003) |
| Notes |
None. |
SPI_T6963C_displayGrPanel
| Prototype |
sub procedure SPI_T6963C_displayGrPanel(dim n as word) |
|---|---|
| Description |
Display selected graphic panel. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_displayTxtPanel(dim n as word) |
|---|---|
| Description |
Display selected text panel. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_setGrPanel(dim n as 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 |
|
| 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 |
sub procedure SPI_T6963C_setTxtPanel(dim n as 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 |
|
| 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 |
sub procedure SPI_T6963C_panelFill(dim v as word) |
|---|---|
| Description |
Fill current panel in full (graphic+text) with appropriate value (0 to clear). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_grFill(dim v as word) |
|---|---|
| Description |
Fill current graphic panel with appropriate value (0 to clear). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_txtFill(dim v as word) |
|---|---|
| Description |
Fill current text panel with appropriate value (0 to clear). |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_cursor_height(dim n as byte) |
|---|---|
| Description |
Set cursor size. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_graphics(dim n as word) |
|---|---|
| Description |
Enable/disable graphic displaying. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_text(dim n as word) |
|---|---|
| Description |
Enable/disable text displaying. |
| Parameters |
|
| 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 |
sub procedure SPI_T6963C_cursor(dim n as word) |
|---|---|
| Description |
Set cursor on/off. |
| Parameters |
|
| 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. |
SPI_T6963C_cursor_blink
| Prototype |
sub procedure SPI_T6963C_cursor_blink(dim n as word) |
|---|---|
| Description |
Enable/disable cursor blinking. |
| Parameters |
|
| 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.
Stellaris
program SPI_T6963C_240x128
include __Lib_SPIT6963C_Const
dim
' Port Expander module connections
SPExpanderRST as sbit at GPIO_PORTA_DATA.B0 ' for writing to output pin always use latch
SPExpanderCS as sbit at GPIO_PORTA_DATA.B1 ' for writing to output pin always use latch
SPExpanderRST_Direction as sbit at GPIO_PORTA_DIR.B0
SPExpanderCS_Direction as sbit at GPIO_PORTA_DIR.B1
' End Port Expander module connections
dim panel as byte ' current panel
i as word ' general purpose register
curs as byte ' cursor visibility
cposx,
cposy as word ' cursor x-y position
txt, txt1 as string[29]
txt2 as string[21]
main:
#DEFINE COMPLETE_EXAMPLE
#DEFINE LINE_DEMO ' Uncomment to demonstrate line drawing routines
#DEFINE FILL_DEMO ' Uncomment to demonstrate fill routines
#DEFINE PARTIAL_IMAGE_DEMO ' Uncomment to demonstrate partial image routine
txt1 = " EINSTEIN WOULD HAVE LIKED mE"
txt = " GLCD LIBRARY DEMO, WELCOME !"
txt2 = " Partial image demo! "
GPIO_Digital_Input(@GPIO_PORTJ_DATA, %00111111)
' If Port Expander Library uses SPI2 module
' Initialize SPI module used with PortExpander
SPI0_Init_Advanced(8000000,_SPI_MASTER, _SPI_CLK_IDLE_LOW or _SPI_SECOND_CLK_EDGE_TRANSITION or _SPI_8_BIT, @_GPIO_MODULE_SPI0_A245)
' SPI0_Init();
' * init display for 240 pixel width and 128 pixel height
' * 8 bits character width
' * data bus on MCP23S17 GPIO_PORTB
' * control bus on MCP23S17 GPIO_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
' Initialize SPI Toshiba 240x128
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 solid boxes
'*
SPI_T6963C_box(0, 0, 239, 8, SPI_T6963C_WHITE)
SPI_T6963C_box(0, 119, 239, 127, SPI_T6963C_WHITE)
' *
' * Draw rectangles
' *
#IFDEF LINE_DEMO
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)
#ENDIF
' *
' * Draw rounded edge rectangle
' *
#IFDEF LINE_DEMO
SPI_T6963C_Rectangle_Round_Edges(10, 10, 229, 117, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges(30, 30, 209, 97, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges(50, 50, 189, 77, 12, SPI_T6963C_WHITE)
#ENDIF
' *
' * Draw filled rounded edge rectangle
' *
#IFDEF FILL_DEMO
SPI_T6963C_Rectangle_Round_Edges_Fill(10, 10, 229, 117, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges_Fill(20, 20, 219, 107, 12, SPI_T6963C_BLACK)
SPI_T6963C_Rectangle_Round_Edges_Fill(30, 30, 209, 97, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges_Fill(40, 40, 199, 87, 12, SPI_T6963C_BLACK)
SPI_T6963C_Rectangle_Round_Edges_Fill(50, 50, 189, 77, 12, SPI_T6963C_WHITE)
#ENDIF
' *
' * Draw a cross
' *
#IFDEF LINE_DEMO
SPI_T6963C_line(0, 0, 239, 127, SPI_T6963C_WHITE)
SPI_T6963C_line(0, 127, 239, 0, SPI_T6963C_WHITE)
#ENDIF
' *
' * Draw circles
' *
#IFDEF LINE_DEMO
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)
#ENDIF
' *
' * Draw filled circles
' *
#IFDEF FILL_DEMO
SPI_T6963C_circle_fill(120, 64, 60, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 55, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 64, 50, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 45, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 64, 40, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 35, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 64, 30, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 25, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 64, 20, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 15, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 64, 10, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 64, 5, SPI_T6963C_BLACK)
#ENDIF
Delay_ms(1000)
SPI_T6963C_sprite(76, 4, @einstein_bmp, 88, 119) ' Draw a sprite
Delay_ms(1000)
SPI_T6963C_setGrPanel(1) ' Select other graphic panel
SPI_T6963C_image(@mikroE_240x128_bmp)
SPI_T6963C_displayGrPanel(1)
Delay_ms(1000)
#IFDEF PARTIAL_IMAGE_DEMO
SPI_T6963C_grFill(0)
SPI_T6963C_PartialImage(0, 0, 64, 64, 240, 128, @mikroE_240x128_bmp) ' Display partial image
Delay_ms(1000)
SPI_T6963C_graphics(0)
#ENDIF
SPI_T6963C_image(@mikroE_240x128_bmp)
SPI_T6963C_graphics(1)
SPI_T6963C_displayGrPanel(0)
while TRUE ' Endless loop
'*
'* If PJ0 is pressed, toggle the display between graphic panel 0 and graphic 1
'*
if( GPIO_PORTJ_DATA0_bit <> 0) then
Inc(panel)
panel = panel and 1
SPI_T6963C_setPtr((SPI_T6963C_grMemSize + SPI_T6963C_txtMemSize) * panel, SPI_T6963C_GRAPHIC_HOME_ADDRESS_SET)
Delay_ms(300)
'*
'* If PJ1 is pressed, display only graphic panel
'*
else
if ( GPIO_PORTJ_DATA1_bit <> 0) then
SPI_T6963C_graphics(1)
SPI_T6963C_text(0)
Delay_ms(300)
'*
'* If PJ2 is pressed, display only text panel
'*
else
if ( GPIO_PORTJ_DATA2_bit <> 0) then
SPI_T6963C_graphics(0)
SPI_T6963C_text(1)
Delay_ms(300)
'*
'* If PJ3 is pressed, display text and graphic panels
'*
else
if ( GPIO_PORTJ_DATA3_bit <> 0) then
SPI_T6963C_graphics(1)
SPI_T6963C_text(1)
Delay_ms(300)
'*
'* If PJ4 is pressed, change cursor
'*
else
if( GPIO_PORTJ_DATA4_bit <> 0) then
Inc(curs)
if (curs = 3) then
curs = 0
end if
select case curs
case 0
' no cursor
SPI_T6963C_cursor(0)
case 1
' blinking cursor
SPI_T6963C_cursor(1)
SPI_T6963C_cursor_blink(1)
case 2
' non blinking cursor
SPI_T6963C_cursor(1)
SPI_T6963C_cursor_blink(0)
end select
Delay_ms(300)
end if
'*
'* If PJ5 is pressed, perform the "Partial image" demonstration
'*
#IFDEF PARTIAL_IMAGE_DEMO
if( GPIO_PORTJ_DATA5_bit = 1) then
SPI_T6963C_setGrPanel(0)
SPI_T6963C_setTxtPanel(0)
SPI_T6963C_txtFill(0)
SPI_T6963C_setGrPanel(1)
SPI_T6963C_setTxtPanel(0)
SPI_T6963C_graphics(1)
SPI_T6963C_text(1)
SPI_T6963C_displayGrPanel(1)
SPI_T6963C_write_text(txt2, 5, 15, SPI_T6963C_ROM_MODE_XOR)
Delay_1sec()
SPI_T6963C_grFill(0)
SPI_T6963C_PartialImage(0, 0, 64, 64, 240, 128, @mikroE_240x128_bmp)
Delay_ms(1500)
SPI_T6963C_PartialImage(0, 0, 128, 128, 240, 128, @mikroE_240x128_bmp)
Delay_ms(1500)
SPI_T6963C_PartialImage(0, 0, 240, 128, 240, 128, @mikroE_240x128_bmp)
Delay_ms(1500)
SPI_T6963C_txtFill(0)
SPI_T6963C_write_text(txt, 0, 0, SPI_T6963C_ROM_MODE_XOR)
SPI_T6963C_write_text(txt1, 0, 15, SPI_T6963C_ROM_MODE_XOR)
end if
#ENDIF
end if
end if
end if
end if
'*
'* Move cursor, even if not visible
'*
Inc(cposx)
if (cposx = SPI_T6963C_txtCols) then
cposx = 0
Inc(cposy)
if (cposy = SPI_T6963C_grHeight div SPI_T6963C_CHARACTER_HEIGHT) then
cposy = 0
end if
end if
SPI_T6963C_set_cursor(cposx, cposy)
Delay_ms(100)
wend
end.
STM32
program SPI_T6963C_240x64
include __Lib_SPIT6963C_Const
dim
' Port Expander module connections
SPExpanderRST as sbit at GPIOB_ODR.B0 ' for writing to output pin always use latch
SPExpanderCS as sbit at GPIOB_ODR.B1 ' for writing to output pin always use latch
' End Port Expander module connections
dim panel as byte ' current panel
i as word ' general purpose register
curs as byte ' cursor visibility
cposx,
cposy as word ' cursor x-y position
txt, txt1 as string[29]
txt2 as string[21]
main:
#DEFINE COMPLETE_EXAMPLE
#DEFINE LINE_DEMO ' Uncomment to demonstrate line drawing routines
#DEFINE FILL_DEMO ' Uncomment to demonstrate fill routines
#DEFINE PARTIAL_IMAGE_DEMO ' Uncomment to demonstrate partial image routine
txt1 = " EINSTEIN WOULD HAVE LIKED mE"
txt = " GLCD LIBRARY DEMO, WELCOME !"
txt2 = " Partial image demo! "
GPIO_Digital_Input(@GPIOD_BASE, %00111111)
' If Port Expander Library uses SPI2 module
' Initialize SPI module used with PortExpander
SPI1_Init_Advanced(_SPI_FPCLK_DIV8, _SPI_MASTER or _SPI_8_BIT or
_SPI_CLK_IDLE_LOW or _SPI_FIRST_CLK_EDGE_TRANSITION or
_SPI_MSB_FIRST or _SPI_SS_DISABLE or _SPI_SSM_ENABLE or _SPI_SSI_1,
@_GPIO_MODULE_SPI1_PB345)
GPIO_Alternate_Function_Enable(@_GPIO_MODULE_SWJ_JTAGDISABLE)
' SPI0_Init();
' Initialize SPI Toshiba 240x64
SPI_T6963C_Config(240, 64, 8, 0, 0, 1, 3, 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, 7, 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 solid boxes
'*
SPI_T6963C_box(0, 0, 239, 8, SPI_T6963C_WHITE)
SPI_T6963C_box(0, 55, 239, 63, SPI_T6963C_WHITE)
'*
'* Draw rectangles
'*
#IFDEF LINE_DEMO
SPI_T6963C_rectangle(0, 0, 239, 63, SPI_T6963C_WHITE)
SPI_T6963C_rectangle(20, 11, 219, 53, SPI_T6963C_WHITE)
SPI_T6963C_rectangle(40, 21, 199, 43, SPI_T6963C_WHITE)
SPI_T6963C_rectangle(60, 30, 179, 34, SPI_T6963C_WHITE)
#ENDIF
'*
'* Draw rounded edge rectangle
'*
#IFDEF LINE_DEMO
SPI_T6963C_Rectangle_Round_Edges(30,16, 209, 48, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges(50,25, 189, 39, 5, SPI_T6963C_WHITE)
#ENDIF
'*
'* Draw filled rounded edge rectangle
'*
#IFDEF FILL_DEMO
SPI_T6963C_Rectangle_Round_Edges_Fill(10, 10, 229, 53, 12, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges_Fill(15, 15, 224, 49, 12, SPI_T6963C_BLACK)
SPI_T6963C_Rectangle_Round_Edges_Fill(20, 20, 219, 44, 9, SPI_T6963C_WHITE)
SPI_T6963C_Rectangle_Round_Edges_Fill(25, 25, 214, 39, 7, SPI_T6963C_BLACK)
SPI_T6963C_Rectangle_Round_Edges_Fill(30, 30, 209, 34, 2, SPI_T6963C_WHITE)
#ENDIF
'*
'* Draw a cross
'*
#IFDEF LINE_DEMO
SPI_T6963C_line(0, 0, 239, 63, SPI_T6963C_WHITE)
SPI_T6963C_line(0, 63, 239, 0, SPI_T6963C_WHITE)
#ENDIF
'*
'* Draw circles
'*
#IFDEF LINE_DEMO
SPI_T6963C_circle(120, 32, 10, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 30, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 50, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 70, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 90, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 110, SPI_T6963C_WHITE)
SPI_T6963C_circle(120, 32, 130, SPI_T6963C_WHITE)
#ENDIF
'*
'* Draw filled circles
'*
#IFDEF FILL_DEMO
SPI_T6963C_circle_fill(120, 32, 40, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 32, 35, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 32, 30, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 32, 25, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 32, 20, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 32, 15, SPI_T6963C_BLACK)
SPI_T6963C_circle_fill(120, 32, 10, SPI_T6963C_WHITE)
SPI_T6963C_circle_fill(120, 32, 5, SPI_T6963C_BLACK)
#ENDIF
Delay_ms(1000)
SPI_T6963C_sprite(60, 0, @einstein, 120, 64) ' Draw a sprite
Delay_ms(1000)
SPI_T6963C_setGrPanel(1) ' Select other graphic panel
SPI_T6963C_image(@mikroE_240x64_bmp)
SPI_T6963C_displayGrPanel(1)
Delay_ms(1000)
#IFDEF PARTIAL_IMAGE_DEMO
SPI_T6963C_grFill(0)
SPI_T6963C_PartialImage(0, 0, 64, 64, 240, 64, @mikroE_240x64_bmp) ' Display partial image
Delay_ms(1000)
SPI_T6963C_graphics(0)
#ENDIF
SPI_T6963C_image(@mikroE_240x64_bmp)
SPI_T6963C_graphics(1)
SPI_T6963C_displayGrPanel(0)
while TRUE ' Endless loop
'*
'* If PD0 is pressed, toggle the display between graphic panel 0 and graphic 1
'*
if (GPIOD_IDR.B0 <> 0) then
Inc(panel)
panel = panel and 1
SPI_T6963C_displayGrPanel(panel)
Delay_ms(300)
'*
'* If PD1 is pressed, display only graphic panel
'*
else
if ( GPIOD_IDR.B1 <> 0) then
SPI_T6963C_graphics(1)
SPI_T6963C_text(0)
Delay_ms(300)
'*
'* If PD2 is pressed, display only text panel
'*
else
if ( GPIOD_IDR.B2 <> 0) then
SPI_T6963C_graphics(0)
SPI_T6963C_text(1)
Delay_ms(300)
'*
'* If PD3 is pressed, display text and graphic panels
'*
else
if ( GPIOD_IDR.B3 <> 0) then
SPI_T6963C_graphics(1)
SPI_T6963C_text(1)
Delay_ms(300)
'*
'* If PD4 is pressed, change cursor
'*
else
if( GPIOD_IDR.B4 <> 0) then
Inc(curs)
if (curs = 3) then
curs = 0
end if
select case curs
case 0
' no cursor
SPI_T6963C_cursor(0)
case 1
' blinking cursor
SPI_T6963C_cursor(1)
SPI_T6963C_cursor_blink(1)
case 2
' non blinking cursor
SPI_T6963C_cursor(1)
SPI_T6963C_cursor_blink(0)
end select 'case
Delay_ms(300)
end if
'*
'* If PD5 is pressed, perform the "Partial image" demonstration
'*
#IFDEF PARTIAL_IMAGE_DEMO
if( GPIOD_IDR.B5 = 1) then
SPI_T6963C_setGrPanel(0)
SPI_T6963C_setTxtPanel(0)
SPI_T6963C_txtFill(0)
SPI_T6963C_setGrPanel(1)
SPI_T6963C_PanelFill(0)
SPI_T6963C_setTxtPanel(0)
SPI_T6963C_graphics(1)
SPI_T6963C_text(1)
SPI_T6963C_displayGrPanel(1)
SPI_T6963C_write_text(txt2, 5, 7, SPI_T6963C_ROM_MODE_XOR)
Delay_1sec()
for i = 0 to 3
SPI_T6963C_grFill(0)
SPI_T6963C_PartialImage(i*80 + 10, 0, 64, 64, 240, 64, @mikroE_240x64_bmp) ' Partial image
Delay_ms(500)
next i
SPI_T6963C_txtFill(0)
SPI_T6963C_write_text(txt, 0, 0, SPI_T6963C_ROM_MODE_XOR)
SPI_T6963C_write_text(txt1, 0, 7, SPI_T6963C_ROM_MODE_XOR)
end if
#ENDIF
end if
end if
end if
end if
'*
'* Move cursor, even if not visible
'*
Inc(cposx)
if (cposx = SPI_T6963C_txtCols) then
cposx = 0
Inc(cposy)
if (cposy = SPI_T6963C_grHeight div SPI_T6963C_CHARACTER_HEIGHT) then
cposy = 0
end if
end if
SPI_T6963C_set_cursor(cposx, cposy)
Delay_ms(100)
wend
end.
What do you think about this topic ? Send us feedback!




