This section covers GLCD devices that use the KS0108 graphics controller.
The KS0108 is an LCD is driven by on-board 5V parallel interface chipset KS0108 and KS0107. They are extremely common and well documented
The GCBASIC constants shown below control the configuration of the KS0108 controller. The only connectivity option is the 8-bit mode where 8 connections (for the data) are required between the microcontroller and the GLCD to control the data bus.
The KS0108 is a monochrome device.
To use the KS0108 driver simply include the following in your user code. This will initialise the driver.
#include <glcd.h> #DEFINE GLCD_TYPE GLCD_TYPE_KS0108 #define GLCD_RW PORTB.1 'chip specific configuration #define GLCD_RESET PORTB.5 'chip specific configuration #define GLCD_CS1 PORTB.3 'chip specific configuration #define GLCD_CS2 PORTB.4 'chip specific configuration #define GLCD_RS PORTB.0 'chip specific configuration #define GLCD_ENABLE PORTB.2 'chip specific configuration #define GLCD_DB0 PORTC.7 'chip specific configuration #define GLCD_DB1 PORTC.6 'chip specific configuration #define GLCD_DB2 PORTC.5 'chip specific configuration #define GLCD_DB3 PORTC.4 'chip specific configuration #define GLCD_DB4 PORTC.3 'chip specific configuration #define GLCD_DB5 PORTC.2 'chip specific configuration #define GLCD_DB6 PORTC.1 'chip specific configuration #define GLCD_DB7 PORTC.0 'chip specific configuration
The GCBASIC constants for the interface to the controller are shown in the table below.
Constants | Controls | Options |
---|---|---|
|
|
|
|
Specifies the output pin that is connected to Register Select on the GLCD. |
Required |
|
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) |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
Specifies the output pin that is connected to |
Required |
|
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 |
|
Not Available for this controller. |
Not applicable. |
The GCBASIC constants defined for the controller type are shown in the table below.
Constants | Controls | Default |
---|---|---|
|
The width parameter of the GLCD |
|
|
The height parameter of the GLCD |
|
|
Defining this will invert the Y Axis |
Not defined |
|
Read delay |
Default is 9 Can be set to improve overall performance. |
|
Write delay |
Default is 1 Can be set to improve performance. |
|
Clock Delay |
Default is 1 Can be set to improve performance. |
The GCBASIC constants for control display characteristics are shown in the table below.
Variables | Controls | Default |
---|---|---|
|
Width of the current GLCD font. |
Default is 6 pixels. |
|
Size of the current GLCD font. |
Default is 0. This equates to the standard GCB font set. |
|
Size of the current GLCD font. |
Default is 1. This equates to the 8 pixel high. |
The GCBASIC commands supported for this GLCD are shown in the table below.
Command | Purpose | Example |
---|---|---|
|
Clear screen of GLCD |
|
|
Print string of characters on GLCD using GCB font set |
|
|
Print character on GLCD using GCB font set |
|
|
Print characters on GLCD using GCB font set |
|
|
Draw a box on the GLCD to a specific size |
|
|
Draw a box on the GLCD to a specific size that is filled with the foreground colour. |
|
|
Draw a line on the GLCD to a specific length that is filled with the specific attribute. |
|
|
Set a pixel on the GLCD at a specific position that is set with the specific attribute. |
|
|
Set a byte value to the controller, see the datasheet for usage. |
|
|
Read a byte value from the controller, see the datasheet for usage. |
|
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 GCBASIC. 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 Do forever 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 Loop
For more help, see GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte or Pset
Supported in <GLCD.H>