GLCD Overview

The GLCD commands are used to control a Graphical Liquid Crystal Display (GLCD) based on the a number of GLCD chipsets. These are often 128x64 pixel displays. They can draw graphical elements by enabling or disabling pixels.

The GLCD with back-lit pixels. These GLCD are a graphical upgrade to the popular 16x2 LCDs (see Liquid Crystal Display Overview ) but the GLCD allows full graphical control of the display. Typical displays are

  • 128 x 64 'monochrome' pixels
  • Low power white LED back-light
  • Driven by on-board 5V parallel interface chipsets or SPI interface controllers
  • The GLCDs are very common and well documente
  • Typically with viewing area is 71mmx39mm (2.8" x 1.5")
  • Typically requires a 36-pin 0.1" header and 10K contrast pot

Great Cow BASIC makes this type of device easier to control with the commands for the GLCD.

Setup:

You must include the glcd.h file at the top of your program. The file needs to be in brackets as shown below.

    #include <GLCD.h>

Defines:

There are several connections that must be defined to use the GLCD commands with a GLCD display. The I/O pin is the pin on the Microchip PIC or the Atmel AVR microcontroller that is connected to that specific pin on the graphical LCD.

Example: KS0108 connectivity

    #define GLCD_RW 	_I/O pin_	‘Read/Write pin connection
    #define GLCD_RESET 	_I/O pin_	‘Reset pin connection
    #define GLCD_CS1 	_I/O pin_	‘CS1 pin connection
    #define GLCD_CS2 	_I/O pin_	‘CS2 pin connection
    #define GLCD_RS 	_I/O pin_	‘RS pin connection
    #define GLCD_ENABLE	_I/O pin_	‘Enable pin Connection
    #define GLCD_DB0 	_I/O pin_	‘Data pin 0 Connection
    #define GLCD_DB1 	_I/O pin_	‘Data pin 1 Connection
    #define GLCD_DB2 	_I/O pin_	‘Data pin 2 Connection
    #define GLCD_DB3 	_I/O pin_	‘Data pin 3 Connection
    #define GLCD_DB4 	_I/O pin_	‘Data pin 4 Connection
    #define GLCD_DB5 	_I/O pin_	‘Data pin 5 Connection
    #define GLCD_DB6 	_I/O pin_	‘Data pin 6 Connection
    #define GLCD_DB7 	_I/O pin_	‘Data pin 7 Connection

Common commands supported across the range of supported GLCDs are:

Command Purpose Example

GLCDCLS

Clear screen of GLCD

GLCDCLS

GLCDPrint

Print string of characters on GLCD using GCB font set

GLCDPrint( Xposition, Yposition, Stringvariable )

GLCDDrawChar

Print character on GLCD using GCB font set

GLCDDrawChar( Xposition, Yposition, CharCode )

GLCDDrawString

Print characters on GLCD using GCB font set

GLCDDrawString( Xposition, Yposition, Stringvariable )

Box

Draw a box on the GLCD to a specific size

Box ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour as 0 or 1] )

FilledBox

Draw a box on the GLCD to a specific size that is filled with the foreground colour.

FilledBox (Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )

Line

Draw a line on the GLCD to a specific length that is filled with the specific attribute.

Line ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )

PSet

Set a pixel on the GLCD at a specific position that is set with the specific attribute.

PSet(Xposition, Yposition, Pixel Colour 0 or 1)



Public variable supported across the range of supported GLCDs are shown in the table below. These variables control the user definable parameters of a specific GLCD.

Variable Purpose Type

GLCDBackground

Color of GLCD background.

Can be monochrome or color.
For mono GLCDs the default is White or 0x0001. For color GLCDs the default is White or 0xFFFF.

GLCDForeground

Color of GLCD foreground.

Can be monochrome or color.
For mono GLCDs the default is non-white or 0x0000. For color GLCDs the default is Black or 0x0000.

GLCDFontWidth

Width of the current GLCD font.

Default is 6 pixels.

GLCDfntDefault

Size of the current GLCD font.

Default is 0.+ This equates to the standard GCB font set.

GLCDfntDefaultsize

Size of the current GLCD font.

Default is 1.+ This equates to the 8 pixel high.

For more help, see KS 0108 controllers, ST7735 Controllers and ST7920 Controllers

This example shows how to drive a KS0108 based Graphic LCD module with the built in commands of Great Cow BASIC. See Graphic LCD for details, this is an external web site.

Example:

    ;Chip Settings
    #chip 16F886,16
    '#config MCLRE = on 'enable reset switch on CHIPINO
    #include <GLCD.h>

    ;Defines (Constants)
    #define GLCD_RW PORTB.1  'D9 to pin 5 of LCD
    #define GLCD_RESET PORTB.5 'D13 to pin 17 of LCD
    #define GLCD_CS1 PORTB.3 'D12 to actually since CS1, CS2 can be inverted
    #define GLCD_CS2 PORTB.4 'D11 to actually since CS1, CS2 can be inverted
    #define GLCD_RS PORTB.0  'D8 to pin 4 D/I pin on LCD
    #define GLCD_ENABLE PORTB.2 'D10 to Pin 6 on LCD
    #define GLCD_DB0 PORTC.7 'D0 to pin 7 on LCD
    #define GLCD_DB1 PORTC.6 'D1 to pin 8 on LCD
    #define GLCD_DB2 PORTC.5 'D2 to pin 9 on LCD
    #define GLCD_DB3 PORTC.4 'D3 to pin 10 on LCD
    #define GLCD_DB4 PORTC.3 'D4 to pin 11 on LCD
    #define GLCD_DB5 PORTC.2 'D5 to pin 12 on LCD
    #define GLCD_DB6 PORTC.1 'D6 to pin 13 on LCD
    #define GLCD_DB7 PORTC.0 'D7 to pin 14 on LCD

    Start:
    GLCDCLS
    GLCDPrint 0,10,"Hello"        'Print Hello
    wait 5 s
    GLCDPrint 0,10, "ASCII #:"    'Print ASCII #:
    Box 18,30,28,40               'Draw Box Around ASCII Character
    for char = 15 to 129          'Print 0 through 9
      GLCDPrint 17, 20 , Str(char)+"  "
      GLCDdrawCHAR 20,30, char
      wait 125 ms
    next
    line 0,50,127,50               'Draw Line using line command
    for xvar = 0 to 80             'Draw line using Pset command
        pset xvar,63,on                    '
    next                                        '
    Wait 1 s
    GLCDPrint 0,10,"End  "          'Print Hello
    wait 1 s
    Goto Start

For more help, see Graphical LCD Demonstration, GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte, Pset