T6963C Graphic Lcd Library
The mikroC PRO for 8051 provides a library for working with Glcds based on TOSHIBA T6963C controller. 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 small, this contoller has a capability of displaying and merging text and graphics and it manages all the interfacing signals to the displays Row and Column drivers.
For creating a custom set of Glcd images use Glcd Bitmap Editor Tool.
Note:
- ChipEnable(CE), FontSelect(FS) and Reverse(MD) have to be set to appropriate levels by the user outside of the
T6963C_Init
function. See the Library Example code at the bottom of this page. - 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 |
External dependencies of T6963C Graphic Lcd Library
The following variables must be defined in all projects using T6963C Graphic Lcd library: | Description : | Example : |
---|---|---|
extern unsigned char sfr T6963C_dataPort; |
T6963C Data Port. | char T6963C_dataPort at P0; |
extern sfr sbit bdata T6963C_ctrlwr; |
Write signal. | sbit T6963C_ctrlwr at P1_2_bit; |
extern sfr sbit bdata T6963C_ctrlrd; |
Read signal. | sbit T6963C_ctrlrd at P1_1_bit; |
extern sfr sbit bdata T6963C_ctrlcd; |
Command/Data signal. | sbit T6963C_ctrlcd at P1_0_bit; |
extern sfr sbit bdata T6963C_ctrlrst; |
Reset signal. | sbit T6963C_ctrlrst at P1_4_bit; |
Library Routines
- T6963C_Init
- T6963C_WriteData
- T6963C_WriteCommand
- T6963C_SetPtr
- T6963C_WaitReady
- T6963C_Fill
- T6963C_Dot
- T6963C_Write_Char
- T6963C_Write_Text
- T6963C_Line
- T6963C_Rectangle
- T6963C_Box
- T6963C_Circle
- T6963C_Image
- T6963C_Sprite
- T6963C_Set_Cursor
Note: The following low level library routines are implemented as macros. These macros can be found in the T6963C.h
header
file which is located in the T6963C example projects folders.
- T6963C_ClearBit
- T6963C_SetBit
- T6963C_NegBit
- T6963C_DisplayGrPanel
- T6963C_DisplayTxtPanel
- T6963C_SetGrPanel
- T6963C_SetTxtPanel
- T6963C_PanelFill
- T6963C_GrFill
- T6963C_TxtFill
- T6963C_Cursor_Height
- T6963C_Graphics
- T6963C_Text
- T6963C_Cursor
- T6963C_Cursor_Blink
T6963C_Init
Prototype |
void T6963C_Init(unsigned int width, unsigned char height, unsigned char fntW); |
---|---|
Returns |
Nothing. |
Description |
Initalizes the Graphic Lcd controller. Parameters :
Display RAM organization: schematic: +---------------------+ /\ + GRAPHICS PANEL #0 + | + + | + + | + + | +---------------------+ | PANEL 0 + TEXT PANEL #0 + | + + \/ +---------------------+ /\ + GRAPHICS PANEL #1 + | + + | + + | + + | +---------------------+ | PANEL 1 + TEXT PANEL #1 + | + + | +---------------------+ \/ |
Requires |
Global variables :
|
Example |
// T6963CGlcd pinout definition char T6963C_dataPort at P0_bit; // pointer to DATA BUS port sbit T6963C_ctrlwr at P1_2_bit; // WR write signal sbit T6963C_ctrlrd at P1_1_bit; // RD read signal sbit T6963C_ctrlcd at P1_0_bit; // CD command/data signal sbit T6963C_ctrlrst at P1_4_bit; // RST reset signal ... // init display for 240 pixel width, 128 pixel height and 8 bits character width T6963C_Init(240, 128, 8); |
T6963C_WriteData
Prototype |
void T6963C_WriteData(unsigned char mydata); |
---|---|
Returns |
Nothing. |
Description |
Writes data to T6963C controller. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_WriteData(AddrL); |
T6963C_WriteCommand
Prototype |
void T6963C_WriteCommand(unsigned char mydata); |
---|---|
Returns |
Nothing. |
Description |
Writes command to T6963C controller. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_WriteCommand(T6963C_CURSOR_POINTER_SET); |
T6963C_SetPtr
Prototype |
void T6963C_SetPtr(unsigned int p, unsigned char c); |
---|---|
Returns |
Nothing. |
Description |
Sets the memory pointer p for command c. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_SetPtr(T6963C_grHomeAddr + start, T6963C_ADDRESS_POINTER_SET); |
T6963C_WaitReady
Prototype |
void T6963C_WaitReady(void); |
---|---|
Returns |
Nothing. |
Description |
Pools the status byte, and loops until Toshiba Glcd module is ready. |
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_WaitReady(); |
T6963C_Fill
Prototype |
void T6963C_Fill(unsigned char v, unsigned int start, unsigned int len); |
---|---|
Returns |
Nothing. |
Description |
Fills controller memory block with given byte. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Fill(0x33,0x00FF,0x000F); |
T6963C_Dot
Prototype |
void T6963C_Dot(int x, int y, unsigned char color); |
---|---|
Returns |
Nothing. |
Description |
Draws a dot in the current graphic panel of Glcd at coordinates (x, y). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Dot(x0, y0, pcolor); |
T6963C_Write_Char
Prototype |
void T6963C_Write_Char(unsigned char c, unsigned char x, unsigned char y, unsigned char mode); |
---|---|
Returns |
Nothing. |
Description |
Writes a char in the current text panel of Glcd at coordinates (x, y). Parameters :
Mode parameter explanation:
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Write_Char('A',22,23,AND); |
T6963C_Write_Text
Prototype |
void T6963C_Write_Text(unsigned char *str, unsigned char x, unsigned char y, unsigned char mode); |
---|---|
Returns |
Nothing. |
Description |
Writes text in the current text panel of Glcd at coordinates (x, y). Parameters :
Mode parameter explanation:
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Write_Text(" GLCD LIBRARY DEMO, WELCOME !", 0, 0, T6963C_ROM_MODE_XOR); |
T6963C_Line
Prototype |
void T6963C_Line(int x0, int y0, int x1, int y1, unsigned char pcolor); |
---|---|
Returns |
Nothing. |
Description |
Draws a line from (x0, y0) to (x1, y1). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Line(0, 0, 239, 127, T6963C_WHITE); |
T6963C_Rectangle
Prototype |
void T6963C_Rectangle(int x0, int y0, int x1, int y1, unsigned char pcolor); |
---|---|
Returns |
Nothing. |
Description |
Draws a rectangle on Glcd. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Rectangle(20, 20, 219, 107, T6963C_WHITE); |
T6963C_Box
Prototype |
void T6963C_Box(int x0, int y0, int x1, int y1, unsigned char pcolor); |
---|---|
Returns |
Nothing. |
Description |
Draws a box on Glcd Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Box(0, 119, 239, 127, T6963C_WHITE); |
T6963C_Circle
Prototype |
void T6963C_Circle(int x, int y, long r, unsigned char pcolor); |
---|---|
Returns |
Nothing. |
Description |
Draws a circle on Glcd. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Circle(120, 64, 110, T6963C_WHITE); |
T6963C_Image
Prototype |
void T6963C_Image(const code char *pic); |
---|---|
Returns |
Nothing. |
Description |
Displays bitmap on Glcd. Parameters :
Use the integrated Glcd Bitmap Editor (menu option Tools › Glcd Bitmap Editor) to convert image to a constant array suitable for displaying on Glcd. Note: Image dimension must match the display dimension. |
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Image(mc); |
T6963C_Sprite
Prototype |
void T6963C_Sprite(unsigned char px, unsigned char py, const code char *pic, unsigned char sx, unsigned char sy); |
---|---|
Returns |
Nothing. |
Description |
Fills graphic rectangle area (px, py) to (px+sx, py+sy) with custom size picture. Parameters :
Note: If |
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Sprite(76, 4, einstein, 88, 119); // draw a sprite |
T6963C_Set_Cursor
Prototype |
void T6963C_Set_Cursor(unsigned char x, unsigned char y); |
---|---|
Returns |
Nothing. |
Description |
Sets cursor to row x and column y. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Set_Cursor(cposx, cposy); |
T6963C_ClearBit
Prototype |
void T6963C_ClearBit(char b); |
---|---|
Returns |
Nothing. |
Description |
Clears control port bit(s). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// clear bit bit0 of port1 T6963C_ClearBit(P1_0_bit); |
T6963C_SetBit
Prototype |
void T6963C_SetBit(char b); |
---|---|
Returns |
Nothing. |
Description |
Sets control port bit(s). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// set bit 0 of port1 T6963C_SetBit(P1_0_bit); |
T6963C_NegBit
Prototype |
void T6963C_NegBit(char b); |
---|---|
Returns |
Nothing. |
Description |
Negates control port bit(s). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// negate bits 0 and 1 on control port T6963C_NegBit(0x03); |
T6963C_DisplayGrPanel
Prototype |
void T6963C_DisplayGrPanel(char n); |
---|---|
Returns |
Nothing. |
Description |
Display selected graphic panel. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// display graphic panel 1 T6963C_DisplayGrPanel(1); |
T6963C_DisplayTxtPanel
Prototype |
void T6963C_DisplayTxtPanel(char n); |
---|---|
Returns |
Nothing. |
Description |
Display selected text panel. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// display text panel 1 T6963C_DisplayTxtPanel(1); |
T6963C_SetGrPanel
Prototype |
void T6963C_SetGrPanel(char n); |
---|---|
Returns |
Nothing. |
Description |
Computes start address for selected graphic panel and set appropriate internal pointers. All subsequent graphic operations will be preformed at this graphic panel. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// set graphic panel 1 as current graphic panel. T6963C_SetGrPanel(1); |
T6963C_SetTxtPanel
Prototype |
void T6963C_SetTxtPanel(char n); |
---|---|
Returns |
Nothing. |
Description |
Computes start address for selected text panel and set appropriate internal pointers. All subsequent text operations will be preformed at this text panel. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// set text panel 1 as current text panel. T6963C_SetTxtPanel(1); |
T6963C_PanelFill
Prototype |
void T6963C_PanelFill(unsigned char v); |
---|---|
Returns |
Nothing. |
Description |
Fill current panel in full (graphic+text) with appropriate value (0 to clear). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
clear current panel T6963C_PanelFill(0); |
T6963C_GrFill
Prototype |
void T6963C_GrFill(unsigned char v); |
---|---|
Returns |
Nothing. |
Description |
Fill current graphic panel with appropriate value (0 to clear). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// clear current graphic panel T6963C_GrFill(0); |
T6963C_TxtFill
Prototype |
void T6963C_TxtFill(unsigned char v); |
---|---|
Returns |
Nothing. |
Description |
Fill current text panel with appropriate value (0 to clear). Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// clear current text panel T6963C_TxtFill(0); |
T6963C_Cursor_Height
Prototype |
void T6963C_Cursor_Height(unsigned char n); |
---|---|
Returns |
Nothing. |
Description |
Set cursor size. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
T6963C_Cursor_Height(7); |
T6963C_Graphics
Prototype |
void T6963C_Graphics(char n); |
---|---|
Returns |
Nothing. |
Description |
Enable/disable graphic displaying. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// enable graphic displaying T6963C_Graphics(1); |
T6963C_Text
Prototype |
void T6963C_Text(char n); |
---|---|
Returns |
Nothing. |
Description |
Enable/disable text displaying. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// enable text displaying T6963C_Text(1); |
T6963C_Cursor
Prototype |
void T6963C_Cursor(char n); |
---|---|
Returns |
Nothing. |
Description |
Set cursor on/off. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// set cursor on T6963C_Cursor(1); |
T6963C_Cursor_Blink
Prototype |
void T6963C_Cursor_Blink(char n); |
---|---|
Returns |
Nothing. |
Description |
Enable/disable cursor blinking. Parameters :
|
Requires |
Toshiba Glcd module needs to be initialized. See the T6963C_Init routine. |
Example |
// enable cursor blinking T6963C_Cursor_Blink(1); |
Library Example
The following drawing demo tests advanced routines of the T6963C Glcd library. Hardware configurations in this example are made for the T6963C 240x128 display, Easy8051 board and ATMEGA16.
#include "__T6963C.h" // T6963C module connections char T6963C_dataPort at P3; // DATA port sbit T6963C_ctrlwr at P2_2_bit; // WR write signal sbit T6963C_ctrlrd at P2_1_bit; // RD read signal sbit T6963C_ctrlcd at P2_0_bit; // CD command/data signal sbit T6963C_ctrlrst at P2_4_bit; // RST reset signal // Signals not used by library, they are set in main function sbit T6963C_ctrlce at P2_3_bit; // CE signal sbit T6963C_ctrlfs at P2_6_bit; // FS signal sbit T6963C_ctrlmd at P2_5_bit; // MD signal // End T6963C module connections /* * bitmap pictures stored in ROM */ const code char mikroE_240x128_bmp[]; const code char einstein[]; void main() { char idata txt1[] = " EINSTEIN WOULD HAVE LIKED mE"; char idata txt[] = " GLCD LIBRARY DEMO, WELCOME !"; unsigned char panel; // Current panel unsigned int i; // General purpose register unsigned char curs; // Cursor visibility unsigned int cposx, cposy; // Cursor x-y position #define COMPLETE_EXAMPLE // comment this line to make simpler/smaller example T6963C_ctrlce = 0; // Enable T6963C T6963C_ctrlfs = 0; // Font Select 8x8 T6963C_ctrlmd = 0; // Column number select // Initialize T6963C T6963C_init(240, 128, 8); /* * Enable both graphics and text display at the same time */ T6963C_graphics(1); T6963C_text(1); panel = 0; i = 0; curs = 0; cposx = cposy = 0; /* * Text messages */ T6963C_write_text(txt, 0, 0, T6963C_ROM_MODE_XOR); T6963C_write_text(txt1, 0, 15, T6963C_ROM_MODE_XOR); /* * Cursor */ T6963C_cursor_height(8); // 8 pixel height T6963C_set_cursor(0, 0); // Move cursor to top left T6963C_cursor(0); // Cursor off /* * Draw rectangles */ T6963C_rectangle(0, 0, 239, 127, T6963C_WHITE); T6963C_rectangle(20, 20, 219, 107, T6963C_WHITE); T6963C_rectangle(40, 40, 199, 87, T6963C_WHITE); T6963C_rectangle(60, 60, 179, 67, T6963C_WHITE); /* * Draw a cross */ T6963C_line(0, 0, 239, 127, T6963C_WHITE); T6963C_line(0, 127, 239, 0, T6963C_WHITE); /* * Draw solid boxes */ T6963C_box(0, 0, 239, 8, T6963C_WHITE); T6963C_box(0, 119, 239, 127, T6963C_WHITE); #ifdef COMPLETE_EXAMPLE /* * Draw circles */ T6963C_circle(120, 64, 10, T6963C_WHITE); T6963C_circle(120, 64, 30, T6963C_WHITE); T6963C_circle(120, 64, 50, T6963C_WHITE); T6963C_circle(120, 64, 70, T6963C_WHITE); T6963C_circle(120, 64, 90, T6963C_WHITE); T6963C_circle(120, 64, 110, T6963C_WHITE); T6963C_circle(120, 64, 130, T6963C_WHITE); T6963C_sprite(76, 4, einstein, 88, 119); // Draw a sprite T6963C_setGrPanel(1); // Select other graphic panel T6963C_image(mikroE_240x128_bmp); // Draw an image #endif for(;;) { // Endless loop /* * If P1.0 is pressed, display only graphic panel */ if(!P1_0_bit) { T6963C_graphics(1); T6963C_text(0); Delay_ms(300); } #ifdef COMPLETE_EXAMPLE /* * If P1.1 is pressed, toggle the display between graphic panel 0 and graphic panel 1 */ else if(!P1_1_bit) { panel++; panel &= 1; T6963C_displayGrPanel(panel); Delay_ms(300); } #endif /* * If P1.2 is pressed, display only text panel */ else if(!P1_2_bit) { T6963C_graphics(0); T6963C_text(1); Delay_ms(300); } /* * If P1.3 is pressed, display text and graphic panels */ else if(!P1_3_bit) { T6963C_graphics(1); T6963C_text(1); Delay_ms(300); } /* * If P1.4 is pressed, change cursor */ else if(!P1_4_bit) { curs++; if(curs == 3) curs = 0; switch(curs) { case 0: // no cursor T6963C_cursor(0); break; case 1: // blinking cursor T6963C_cursor(1); T6963C_cursor_blink(1); break; case 2: // non blinking cursor T6963C_cursor(1); T6963C_cursor_blink(0); break; } Delay_ms(300); } /* * Move cursor, even if not visible */ cposx++; if(cposx == T6963C_txtCols) { cposx = 0; cposy++; if(cposy == T6963C_grHeight / T6963C_CHARACTER_HEIGHT) { cposy = 0; } } T6963C_set_cursor(cposx, cposy); Delay_ms(100); } }
HW Connection
T6963C Glcd HW connection
What do you think about this topic ? Send us feedback!