by Andy Gock
For up to date documentation, please see the doxygen pages under the doxygen_pages
directory and within the source code.
A online version can also be seen at:
https://andygock.github.io/glcd-documentation/
However the above site may not always be up to date.
Welcome to GLCD, an open source graphic LCD library written by Andy Gock.
This library has been written cleanly, to allow easy modification for use with different microcontroller devices and controller chipsets. Logic relating to devices and controllers are palced in seperate files and specific implementations can be chosen by the use of special defined symbols.
It is suitable for monochrome (black and white) LCDs with page by page data and command write style data transfer protocol. It is not compatible with color graphic LCDs.
Works with:
The following graphic displays have been physically tested with and confirmed working:
Not all combinations of microcontroller platform and LCD controllers are supported out of the box. However you can edit the files devices/
and controllers/
and add your desired combination. More information on how to do this can be read in the doxygen documentation.
The following symbols need to be defined for the compiler:
Pick microcontroller type (pick one only):
GLCD_DEVICE_LPX111X
GLCD_DEVICE_LPX11UXX
GLCD_DEVICE_AVR8
GLCD_DEVICE_STM32F0XX
GLCD_DEVICE_STM32F4XX
GLCD_DEVICE_PIC24H
Pick LCD controller type (pick one only):
GLCD_CONTROLLER_PCD8544
GLCD_CONTROLLER_ST7565R
GLCD_CONTROLLER_NT75451
For ST7565P controllers, treat as ST7565R. For most if not all parts here, they behave the same way.
If using a parallel interface LCD (e.g NT75451 on NGX BlueBoard):
GLCD_USE_PARALLEL
When using SPI controllers:
GLCD_USE_SPI
Note the SPI symbol isn't actually checked by the source at the moment, and it is fine if it is not used. It is for forward compatibility only. One day I may decide to check for it.
For the Newhaven displays using ST7565 based controllers listed above which have been tested as working, there are certain initialisation sequences which should be followed, and this may vary from display to display. To force a certain (and tested) initialisation sequence, define one of the following:
GLCD_INIT_NHD_C12832A1Z_FSW_FBW_3V3
GLCD_INIT_NHD_C12864A1Z_FSW_FBW_HTT
GLCD_INIT_NHD_C12864WC_FSW_FBW_3V3_M
GLCD_INIT_ZOLEN_12864_FFSSWE_NAA
If you don't specify a NHD model, ST7565 controller selection will default to GLCD_INIT_NHD_C12864WC_FSW_FBW_3V3_M
sequence. This however may change in the future.
To set a reset time, used by the glcd_reset()
function, set GLCD_RESET_TIME
to desired duration in milliseconds.
When using PCD8544 controllers, define a PCD8544_CONTRAST
symbol with a 8-bit unsigned integer for the contast value. If this is not defined, a default value will be used.
Set GLCD_LCD_WIDTH
and GLCD_LCD_HEIGHT
to define custom LCD dimensions. If these are not user defined, then a default width and height is used. The default dimensions are 128x64 except for PCD8544 controllers which is 84x48.
These symbols need to be set in the configuration options of your IDE, usually in the "defined symbols" section, or they can be defined in a makefile as -D
options.
Example:
-DGLCD_DEVICE_LPC111X
Some operations such as sending a reset pulse, requires the use of a delay timer. The library will refer to a external function called delay_ms(t)
where t is the delay required in milliseconds. Please ensure you have this function elsewhere in your program.
If you are using avr-gcc with Atmel devices, you can force the library to use the built-in _delay_ms()
function by setting the compiler symbols:
GLCD_USE_AVR_DELAY
__DELAY_BACKWARD_COMPATIBLE__
F_CPU
must be set to your clock frequency for the above AVR built-in delay routine to work.
The code samples above will have the glcd library code already inside it, however I haven’t made any attempt to keep the glcd library updated in the examples so I advise that if you are using the example code, to replace the glcd directory (usually in library/glcd
or lib/glcd
) with the latest updated code.
Bitmap images can be converted into a byte array using LCD Assistant
When using this software, we need to set 8 pixels per byte with vertical byte orientation. Do not include size.