Graphic Lcd Library

The mikroPascal PRO for PIC provides a library for operating Graphic Lcd 128x64 (with commonly used Samsung KS108/KS107 controller).

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

  Important : PIC16 family of MCUs does not support working with external resources.

Library Dependency Tree

Graphic Lcd Library Dependency Tree

External dependencies of Graphic Lcd Library

The following variables must be defined in all projects using Graphic Lcd Library: Description : Example :
var GLCD_DataPort : byte; sfr; external; Glcd Data Port. var GLCD_DataPort : byte at PORTD;
var GLCD_CS1 : sbit; sfr; external; Chip Select 1 line. var GLCD_CS1 : sbit at RB0_bit;
var GLCD_CS2 : sbit; sfr; external; Chip Select 2 line. var GLCD_CS2 : sbit at RB1_bit;
var GLCD_RS : sbit; sfr; external; Register select line. var GLCD_RS : sbit at RB2_bit;
var GLCD_RW : sbit; sfr; external; Read/Write line. var GLCD_RW : sbit at RB3_bit;
var GLCD_EN : sbit; sfr; external; Enable line. var GLCD_EN : sbit at RB4_bit;
var GLCD_RST : sbit; sfr; external; Reset line. var GLCD_RST : sbit at RB5_bit;
var GLCD_CS1_Direction : sbit; sfr; external; Direction of the Chip Select 1 pin. var GLCD_CS1_Direction : sbit at TRISB0_bit;
var GLCD_CS2_Direction : sbit; sfr; external; Direction of the Chip Select 2 pin. var GLCD_CS2_Direction : sbit at TRISB1_bit;
var GLCD_RS_Direction : sbit; sfr; external; Direction of the Register select pin. var GLCD_RS_Direction : sbit at TRISB2_bit;
var GLCD_RW_Direction : sbit; sfr; external; Direction of the Read/Write pin. var GLCD_RW_Direction : sbit at TRISB3_bit;
var GLCD_EN_Direction : sbit; sfr; external; Direction of the Enable pin. var GLCD_EN_Direction : sbit at TRISB4_bit;
var GLCD_RST_Direction : sbit; sfr; external; Direction of the Reset pin. var GLCD_RST_Direction : sbit at TRISB5_bit;

Library Routines

Basic routines:

Advanced routines:

Glcd_Init

Prototype

procedure Glcd_Init();

Returns

Nothing.

Description

Initializes the Glcd module. Each of the control lines is both port and pin configurable, while data lines must be on a single port (pins <0:7>).

Requires

Global variables :

  • GLCD_CS1 : Chip select 1 signal pin
  • GLCD_CS2 : Chip select 2 signal pin
  • GLCD_RS : Register select signal pin
  • GLCD_RW : Read/Write Signal pin
  • GLCD_EN : Enable signal pin
  • GLCD_RST : Reset signal pin
  • GLCD_DataPort : Data port

  • GLCD_CS1_Direction : Direction of the Chip select 1 pin
  • GLCD_CS2_Direction : Direction of the Chip select 2 pin
  • GLCD_RS_Direction : Direction of the Register select signal pin
  • GLCD_RW_Direction : Direction of the Read/Write signal pin
  • GLCD_EN_Direction : Direction of the Enable signal pin
  • GLCD_RST_Direction : Direction of the Reset signal pin
must be defined before using this function.

Example
// Glcd module connections
var GLCD_DataPort : byte at PORTD;

var GLCD_CS1 : sbit at RB0_bit;
    GLCD_CS2 : sbit at RB1_bit;
    GLCD_RS  : sbit at RB2_bit;
    GLCD_RW  : sbit at RB3_bit;
    GLCD_EN  : sbit at RB4_bit;
    GLCD_RST : sbit at RB5_bit;

var GLCD_CS1_Direction : sbit at TRISB0_bit;
    GLCD_CS2_Direction : sbit at TRISB1_bit;
    GLCD_RS_Direction  : sbit at TRISB2_bit;
    GLCD_RW_Direction  : sbit at TRISB3_bit;
    GLCD_EN_Direction  : sbit at TRISB4_bit;
    GLCD_RST_Direction : sbit at TRISB5_bit;
// End Glcd module connections
ANSEL = 0;
ANSELH = 0;
Glcd_Init();

Glcd_Set_Side

Prototype

procedure Glcd_Set_Side(x_pos: byte);

Returns

Nothing.

Description

Selects Glcd side. Refer to the Glcd datasheet for detailed explanation.

Parameters :

  • x_pos: position on x-axis. Valid values: 0..127

The parameter x_pos specifies the Glcd side: values from 0 to 63 specify the left side, values from 64 to 127 specify the right side.

  Note : For side, x axis and page layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example

The following two lines are equivalent, and both of them select the left side of Glcd:

Glcd_Select_Side(0);
Glcd_Select_Side(10);

Glcd_Set_X

Prototype

procedure Glcd_Set_X(x_pos: byte);

Returns

Nothing.

Description

Sets x-axis position to x_pos dots from the left border of Glcd within the selected side.

Parameters :

  • x_pos: position on x-axis. Valid values: 0..63

  Note : For side, x axis and page layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
Glcd_Set_X(25);

Glcd_Set_Page

Prototype

procedure Glcd_Set_Page(page: byte);

Returns

Nothing.

Description

Selects page of the Glcd.

Parameters :

  • page: page number. Valid values: 0..7

  Note : For side, x axis and page layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
Glcd_Set_Page(5);

Glcd_Read_Data

Prototype

function Glcd_Read_Data(): byte;

Returns

One byte from Glcd memory.

Description

Reads data from from the current location of Glcd memory and moves to the next location.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Glcd side, x-axis position and page should be set first. See functions Glcd_Set_Side, Glcd_Set_X, and Glcd_Set_Page.

Example
var data_ : byte;
...
data_ := Glcd_Read_Data();

Glcd_Write_Data

Prototype

procedure Glcd_Write_Data(ddata: byte);

Returns

Nothing.

Description

Writes one byte to the current location in Glcd memory and moves to the next location.

Parameters :

  • ddata: data to be written

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Glcd side, x-axis position and page should be set first. See functions Glcd_Set_Side, Glcd_Set_X, and Glcd_Set_Page.

Example
var ddata: byte;
...
Glcd_Write_Data(ddata);

Glcd_Set_Ext_Buffer

Prototype

procedure Glcd_Set_Ext_Buffer(getExtDataPtr : ^TGlcd_Get_Ext_Data_Ptr);

Returns

Nothing.

Description

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

Parameters :

  • TGLCD_Get_Ext_Data_Ptr - pointer to the user function.

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

Glcd module needs to be initialized. See the Glcd_Init routine.

Example
Glcd_Set_Ext_Buffer(@ReadExternalBuffer);

Glcd_Fill

Prototype

procedure Glcd_Fill(pattern: byte);

Returns

Nothing.

Description

Fills Glcd memory with the byte pattern.

Parameters :

  • pattern: byte to fill Glcd memory with

To clear the Glcd screen, use Glcd_Fill(0).

To fill the screen completely, use Glcd_Fill(0xFF).

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Clear screen
Glcd_Fill(0);

Glcd_Dot

Prototype

procedure Glcd_Dot(x_pos: byte; y_pos: byte; color: byte);

Returns

Nothing.

Description

Draws a dot on Glcd at coordinates (x_pos, y_pos).

Parameters :

  • x_pos: x position. Valid values: 0..127
  • y_pos: y position. Valid values: 0..63
  • color: color parameter. Valid values: 0..2

The parameter color determines a dot state: 0 clears dot, 1 puts a dot, and 2 inverts dot state.

  Note : For x and y axis layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Invert the dot in the upper left corner
Glcd_Dot(0, 0, 2);

Glcd_Line

Prototype

procedure Glcd_Line(x_start: integer; y_start: integer; x_end: integer; y_end: integer; color: byte);

Returns

Nothing.

Description

Draws a line on Glcd.

Parameters :

  • x_start: x coordinate of the line start. Valid values: 0..127
  • y_start: y coordinate of the line start. Valid values: 0..63
  • x_end: x coordinate of the line end. Valid values: 0..127
  • y_end: y coordinate of the line end. Valid values: 0..63
  • color: color parameter. Valid values: 0..2

The parameter color determines the line color: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a line between dots (0,0) and (20,30)
Glcd_Line(0, 0, 20, 30, 1);

Glcd_V_Line

Prototype

procedure Glcd_V_Line(y_start: byte; y_end: byte; x_pos: byte; color: byte);

Returns

Nothing.

Description

Draws a vertical line on Glcd.

Parameters :

  • y_start: y coordinate of the line start. Valid values: 0..63
  • y_end: y coordinate of the line end. Valid values: 0..63
  • x_pos: x coordinate of vertical line. Valid values: 0..127
  • color: color parameter. Valid values: 0..2

The parameter color determines the line color: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a vertical line between dots (10,5) and (10,25)
Glcd_V_Line(5, 25, 10, 1);

Glcd_H_Line

Prototype

procedure Glcd_V_Line(x_start: byte; x_end: byte; y_pos: byte; color: byte);

Returns

Nothing.

Description

Draws a horizontal line on Glcd.

Parameters :

  • x_start: x coordinate of the line start. Valid values: 0..127
  • x_end: x coordinate of the line end. Valid values: 0..127
  • y_pos: y coordinate of horizontal line. Valid values: 0..63
  • color: color parameter. Valid values: 0..2

The parameter color determines the line color: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a horizontal line between dots (10,20) and (50,20)
Glcd_H_Line(10, 50, 20, 1);

Glcd_Rectangle

Prototype

procedure Glcd_Rectangle(x_upper_left: byte; y_upper_left: byte; x_bottom_right: byte; y_bottom_right: byte; color: byte);

Returns

Nothing.

Description

Draws a rectangle on Glcd.

Parameters :

  • x_upper_left: x coordinate of the upper left rectangle corner. Valid values: 0..127
  • y_upper_left: y coordinate of the upper left rectangle corner. Valid values: 0..63
  • x_bottom_right: x coordinate of the lower right rectangle corner. Valid values: 0..127
  • y_bottom_right: y coordinate of the lower right rectangle corner. Valid values: 0..63
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the rectangle border: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a rectangle between dots (5,5) and (40,40)
Glcd_Rectangle(5, 5, 40, 40, 1);

Glcd_Rectangle_Round_Edges

Prototype

procedure Glcd_Rectangle_Round_Edges(x_upper_left: byte; y_upper_left: byte; x_bottom_right: byte; y_bottom_right: byte; radius: byte; color: byte);

Returns

Nothing.

Description

Draws a rounded edge rectangle on Glcd.

Parameters :

  • x_upper_left: x coordinate of the upper left rectangle corner. Valid values: 0..127
  • y_upper_left: y coordinate of the upper left rectangle corner. Valid values: 0..63
  • x_bottom_right: x coordinate of the lower right rectangle corner. Valid values: 0..127
  • y_bottom_right: y coordinate of the lower right rectangle corner. Valid values: 0..63
  • radius: radius of the rounded edge.
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the rectangle border: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a rounded edge rectangle between dots (5,5) and (40,40) with the edge radius of 12
Glcd_Rectangle_Round_Edges(5, 5, 40, 40, 12, 1);

Glcd_Rectangle_Round_Edges_fill

Prototype

procedure Glcd_Rectangle_Round_Edges_Fill(x_upper_left: byte; y_upper_left: byte; x_bottom_right: byte; y_bottom_right: byte; radius: byte; color: byte);

Returns

Nothing.

Description

Draws a filled rounded edge rectangle on Glcd.

Parameters :

  • x_upper_left: x coordinate of the upper left rectangle corner. Valid values: 0..127
  • y_upper_left: y coordinate of the upper left rectangle corner. Valid values: 0..63
  • x_bottom_right: x coordinate of the lower right rectangle corner. Valid values: 0..127
  • y_bottom_right: y coordinate of the lower right rectangle corner. Valid values: 0..63
  • radius: radius of the rounded edge.
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the rectangle border: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a filled rounded edge rectangle between dots (5,5) and (40,40) with the edge radius of 12
Glcd_Rectangle_Round_Edges_Fill(5, 5, 40, 40, 12, 1);

Glcd_Box

Prototype

procedure Glcd_Box(x_upper_left: byte; y_upper_left: byte; x_bottom_right: byte; y_bottom_right: byte; color: byte);

Returns

Nothing.

Description

Draws a box on Glcd.

Parameters :

  • x_upper_left: x coordinate of the upper left box corner. Valid values: 0..127
  • y_upper_left: y coordinate of the upper left box corner. Valid values: 0..63
  • x_bottom_right: x coordinate of the lower right box corner. Valid values: 0..127
  • y_bottom_right: y coordinate of the lower right box corner. Valid values: 0..63
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the box fill: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a box between dots (5,15) and (20,40)
Glcd_Box(5, 15, 20, 40, 1);

Glcd_Circle

Prototype

procedure Glcd_Circle(x_center: integer; y_center: integer; radius: integer; color: byte);

Returns

Nothing.

Description

Draws a circle on Glcd.

Parameters :

  • x_center: x coordinate of the circle center. Valid values: 0..127
  • y_center: y coordinate of the circle center. Valid values: 0..63
  • radius: radius size
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the circle line: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a circle with center in (50,50) and radius=10
Glcd_Circle(50, 50, 10, 1);

Glcd_Circle_Fill

Prototype

procedure Glcd_Circle_Fill(x_center: integer; y_center: integer; radius: integer; color: byte);

Returns

Nothing.

Description

Draws a filled circle on Glcd.

Parameters :

  • x_center: x coordinate of the circle center. Valid values: 0..127
  • y_center: y coordinate of the circle center. Valid values: 0..63
  • radius: radius size
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the circle line: 0 white, 1 black, and 2 inverts each dot.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw a filled circle with center in (50,50) and radius=10
Glcd_Circle_Fill(50, 50, 10, 1);

Glcd_Set_Font

Prototype

procedure Glcd_Set_Font(const ActiveFont: ^byte; FontWidth: byte; FontHeight: byte; FontOffs: word);

Returns

Nothing.

Description

Sets font that will be used with Glcd_Write_Char and Glcd_Write_Text routines.

Parameters :

  • activeFont: font to be set. Needs to be formatted as an array of char
  • aFontWidth: width of the font characters in dots.
  • aFontHeight: height of the font characters in dots.
  • aFontOffs: number that represents difference between the mikroPascal PRO for PIC character set and regular ASCII set (eg. if 'A' is 65 in ASCII character, and 'A' is 45 in the mikroPascal PRO for PIC character set, aFontOffs is 20). Demo fonts supplied with the library have an offset of 32, which means that they start with space.

List of supported fonts:

  • Font_Glcd_System3x5
  • Font_Glcd_System5x7
  • Font_Glcd_5x7
  • Font_Glcd_Character8x7

For the sake of the backward compatibility, these fonts are supported also:

  • System3x5 (equivalent to Font_Glcd_System3x5)
  • FontSystem5x7_v2 (equivalent to Font_Glcd_System5x7)
  • font5x7 (equivalent to Font_Glcd_5x7)
  • Character8x7 (equivalent to Font_Glcd_Character8x7)
Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Use the custom 5x7 font "myfont" which starts with space (32):
Glcd_Set_Font(@myfont, 5, 7, 32);

Glcd_Set_Font_Adv

Prototype

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

Description

Sets font that will be used with Glcd_Write_Char_Adv and Glcd_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

Glcd needs to be initialized, see Glcd_Init routine.

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

None.

Glcd_Set_Ext_Font_Adv

Prototype

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

Description

Sets font that will be used with Glcd_Write_Char_Adv and Glcd_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

Glcd needs to be initialized, see Glcd_Init routine.

Example
Glcd_Set_Ext_Font_Adv(173296, 5, 7, 32);
Notes

None.

Glcd_Write_Char

Prototype

procedure Glcd_Write_Char(chr: byte; x_pos: byte; page_num: byte; color: byte);

Returns

Nothing.

Description

Prints character on the Glcd.

Parameters :

  • chr: character to be written
  • x_pos: character starting position on x-axis. Valid values: 0..(127-FontWidth)
  • page_num: the number of the page on which character will be written. Valid values: 0..7
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the character: 0 white, 1 black, and 2 inverts each dot.

  Note : For x axis and page layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine. Use Glcd_Set_Font to specify the font for display; if no font is specified, then default Font_Glcd_System5x7 font supplied with the library will be used.

Example
// Write character 'C' on the position 10 inside the page 2:
Glcd_Write_Char('C', 10, 2, 1);

Glcd_Write_Char_Adv

Prototype

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

Returns

Nothing.

Description

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

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

glcd module needs to be initialized. See the Glcd_Init routine.

Example
Glcd_Write_Char_Adv('A',22,23);

Glcd_Write_Text

Prototype

procedure Glcd_Write_Text(var text: string; x_pos: byte; page_num: byte; color: byte);

Returns

Nothing.

Description

Prints text on Glcd.

Parameters :

  • text: text to be written
  • x_pos: text starting position on x-axis.
  • page_num: the number of the page on which text will be written. Valid values: 0..7
  • color: color parameter. Valid values: 0..2

The parameter color determines the color of the text: 0 white, 1 black, and 2 inverts each dot.

  Note : For x axis and page layout explanation see schematic at the bottom of this page.
Requires

Glcd needs to be initialized, see Glcd_Init routine. Use Glcd_Set_Font to specify the font for display; if no font is specified, then default Font_Glcd_System5x7 font supplied with the library will be used.

Example
// Write text "Hello world!" on the position 10 inside the page 2:
Glcd_Write_Text('Hello world!', 10, 2, 1);

Glcd_Write_Text_Adv

Prototype

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

Returns

Nothing.

Description

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

Parameters :

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

Glcd module needs to be initialized. See the Glcd_Init routine.

Example
Glcd_Write_Text_Adv("GLCD LIBRARY DEMO, WELCOME !", 0, 0);	

Glcd_Write_Const_Text_Adv

Prototype

procedure Glcd_Write_Const_Text_Adv(ctext : ^const far byte; x, y : word);

Returns

Nothing.

Description

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

Parameters :

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

Glcd module needs to be initialized. See the Glcd_Init routine.

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

Glcd_Image

Prototype

procedure Glcd_Image(const image: ^byte);

Returns

Nothing.

Description

Displays bitmap on Glcd.

Parameters :

  • image: image to be displayed. Bitmap array must be located in code memory.

Use the mikroPascal PRO for PIC integrated Glcd Bitmap Editor to convert image to a constant array suitable for displaying on Glcd.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
// Draw image my_image on Glcd
Glcd_Image(@my_image);

Glcd_Ext_Image

Prototype

procedure Glcd_Ext_Image(image : dword);

Description

Displays a bitmap from an external resource.

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

Nothing.

Requires

Glcd needs to be initialized, see Glcd_Init routine.

Example
Glcd_Ext_Image(153608);
Notes

Use the mikroPascal PRO for AVR integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd.

Glcd_PartialImage

Prototype

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

Returns

Nothing.

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 is located in code memory.

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

Glcd needs to be initialized, see Glcd_Init 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. 
Glcd_PartialImage(10, 12, 10, 15, 16, 32, @image);

Glcd_Ext_PartialImage

Prototype

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

Description

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

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

Glcd needs to be initialized, see Glcd_Init routine.

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

Use the mikroPascal PRO for AVR integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd.

Library Example

The following example demonstrates routines of the Glcd library: initialization, clear(pattern fill), image displaying, drawing lines, circles, boxes and rectangles, text displaying and handling.

Copy Code To ClipboardCopy Code To Clipboard
program GLCD_Test;

uses bitmap;

// Glcd module connections
var GLCD_DataPort : byte at PORTD;

var GLCD_CS1 : sbit at RB0_bit;
    GLCD_CS2 : sbit at RB1_bit;
    GLCD_RS  : sbit at RB2_bit;
    GLCD_RW  : sbit at RB3_bit;
    GLCD_EN  : sbit at RB4_bit;
    GLCD_RST : sbit at RB5_bit;

var GLCD_CS1_Direction : sbit at TRISB0_bit;
    GLCD_CS2_Direction : sbit at TRISB1_bit;
    GLCD_RS_Direction  : sbit at TRISB2_bit;
    GLCD_RW_Direction  : sbit at TRISB3_bit;
    GLCD_EN_Direction  : sbit at TRISB4_bit;
    GLCD_RST_Direction : sbit at TRISB5_bit;
// End Glcd module connections

var counter : byte;
    someText : array[18] of char;

procedure Delay2S();                                  // 2 seconds delay function
  begin
    Delay_ms(2000);
  end;

begin

  ANSEL  := 0;                                        // Configure AN pins as digital I/O
  ANSELH := 0;

  Glcd_Init();                                        // Initialize GLCD
  Glcd_Fill(0x00);                                    // Clear GLCD

  while TRUE do
    begin
      Glcd_Image(@truck_bmp);                         // Draw image
      Delay2S(); delay2S();

      Glcd_Fill(0x00);                                // Clear GLCD

      Glcd_Box(62,40,124,63,1);                       // Draw box
      Glcd_Rectangle(5,5,84,35,1);                    // Draw rectangle
      Glcd_Line(0, 0, 127, 63, 1);                    // Draw line
      Delay2S();
      counter := 5;

      while (counter <= 59) do                        // Draw horizontal and vertical lines
        begin
          Delay_ms(250);
          Glcd_V_Line(2, 54, counter, 1);
          Glcd_H_Line(2, 120, counter, 1);
          Counter := counter + 5;
        end;

      Delay2S();

      Glcd_Fill(0x00);                                   // Clear GLCD

      Glcd_Set_Font(@Font_Glcd_Character8x7, 8, 7, 32);  // Choose font "Character8x7"
      Glcd_Write_Text('mikroE', 1, 7, 2);                // Write string

      for counter := 1 to 10 do                          // Draw circles
        Glcd_Circle(63,32, 3*counter, 1);
      Delay2S();

      Glcd_Box(10,20, 70,63, 2);                         // Draw box
      Delay2S();

      Glcd_Fill(0xFF);                                   // Fill GLCD
      Glcd_Set_Font(@Font_Glcd_Character8x7, 8, 7, 32);  // Change font
      someText := '8x7 Font';
      Glcd_Write_Text(someText, 5, 0, 2);                // Write string
      delay2S();

      Glcd_Set_Font(@Font_Glcd_System3x5, 3, 5, 32);     // Change font
      someText := '3X5 CAPITALS ONLY';
      Glcd_Write_Text(someText, 60, 2, 2);               // Write string
      delay2S();

      Glcd_Set_Font(@Font_Glcd_5x7, 5, 7, 32);           // Change font
      someText := '5x7 Font';
      Glcd_Write_Text(someText, 5, 4, 2);                // Write string
      delay2S();

      Glcd_Set_Font(@Font_Glcd_System5x7, 5, 7, 32);     // Change font
      someText := '5x7 Font (v2)';
      Glcd_Write_Text(someText, 50, 6, 2);               // Write string
      delay2S();
    end;
end.

HW Connection

Glcd HW connection

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