KS0108 Controllers

See below for an example of using the KS0108 GLCD. This section contains the relevant information for this type of device.

The Great Cow BASIC constants for control of the connectivity are shown in the table below. The only connectivity option the 8-bit mode where 8 pins are connected between the microcontroller and the GLCD to control the data bus.

To use the KS0108 drivers simply include the following:

    #include <glcd.h>
    #DEFINE GLCD_TYPE GLCD_TYPE_KS0108

The Great Cow BASIC constants for control display characteristics are shown in the table below.

Constants Controls Options

GLCD_TYPE

GLCD_TYPE_KS0108

Required

GLCD_DATA_PORT

Not Available for this controller.

Not applicable.

GLCD_RS

Specifies the output pin that is connected to Register Select on the GLCD.

Required

GLCD_RW

Specifies the output pin that is connected to Read/Write on the GLCD. The R/W pin can be disabled.

Must be defined (unless R/W is disabled)
see
GLCD_NO_RW

GLCD_CS1

Specifies the output pin that is connected to CS1 on the GLCD.

Required

GLCD_CS2

Specifies the output pin that is connected to CS2 on the GLCD.

Required

GLCD_ENABLE

Specifies the output pin that is connected to Enable on the GLCD.

Required

GLCD_DB0

Specifies the output pin that is connected to DB0 on the GLCD.

Required

GLCD_DB1

Specifies the output pin that is connected to DB1 on the GLCD.

Required

GLCD_DB2

Specifies the output pin that is connected to DB2 on the GLCD.

Required

GLCD_DB3

Specifies the output pin that is connected to DB3 on the GLCD.

Required

GLCD_DB4

Specifies the output pin that is connected to DB4 on the GLCD.

Required

GLCD_DB5

Specifies the output pin that is connected to DB5 on the GLCD.

Required

GLCD_DB6

Specifies the output pin that is connected to DB6 on the GLCD.

Required

GLCD_DB7

Specifies the output pin that is connected to DB7 on the GLCD.

Required

GLCD_NO_RW

Disables read/write inspection of the device during read/write operations

Optional, but recommend NOT to set. The R/W pin can be disabled by setting the GLCD_NO_RW constant. If this is done, there is no need for the R/W to be connected to the chip, and no need for the LCD_RW constant to be set. Ensure that the R/W line on the LCD is connected to ground if not used.

The Great Cow BASIC constants for display characteristics are shown in the table below.

Constants Controls Default

GLCD_WIDTH

The width parameter of the GLCD

128

GLCD_HEIGHT

The height parameter of the GLCD

64

GLCDDirection

Defining this will invert the Y Axis

Not defined

KS0108ReadDelay

Read delay

Default is 9

Can be set to improve performance.

KS0108WriteDelay

Write delay

Default is 1

Can be set to improve performance.

KS0108ClockDelay

Clock Delay

Default is 1

Can be set to improve performance.

The Great Cow BASIC variables to control display characteristics are shown in the table below.

Variables Controls Default

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.

The Great Cow BASIC commands supported for this GLCD are shown in the table below.

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)

GLCDWriteByte

Set a byte value to the controller, see the datasheet for usage.

GLCDWriteByte ( LCDByte)

GLCDReadByte

Read a byte value from the controller, see the datasheet for usage.

bytevariable = GLCDReadByte

For a KS0108 datasheet, please refer here.

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.

    ;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 reversed on some devices
    #define GLCD_CS2 PORTB.4 'D11 to actually since CS1, CS2 can be reversed on some devices
    #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

Supported in <GLCD.H>