Skip to the content of the web site.

Graphic LCD Library

There are three header files in question:

    GLCD.h
    GLCD_Scroll.h
    Font_16x24_h.h
    Font_6x8_h.h

We will describe the first here. The other files (including the source files) are used by, for example, the printf command.

GLCD.h

The Graphic Liquid-Crystal Display (LCD) library contains three components:

RGB color definitions

Each colour is two bytes or 16 bits where:

  • 5 bits are for red
  • 6 bits are for green
  • 5 bits are for blue

or RRRRRGGGGGGBBBBB. The choice to add one extra bit for green is likely due to the eye being more sensitive to green in the spectrum.

Sixteen pre-defined identifiers are given color names (recall that C is case sensitive):

       Black       DarkGrey    LightGrey   White
       Blue        Navy        DarkCyan    Cyan
       DarkGreen   Green       Olive
       Maroon      Purple
       Red         Magenta
       Yellow

Lines on the screen

There are ten lines on the screen, and they are identified by

         Line0 Line1 Line2 Line3 Line4 Line5 Line6 Line7 Line8 Line9

Functions

The available functions are


void GLCD_Init           ( void );
void GLCD_WindowMax      ( void );
void GLCD_PutPixel       ( unsigned int x, unsigned int y );
void GLCD_SetTextColor   ( unsigned short color );
void GLCD_SetBackColor   ( unsigned short color );
void GLCD_Clear          ( unsigned short color );
void GLCD_DrawChar       ( unsigned int x,  unsigned int y,   unsigned int  cw, unsigned int ch, unsigned char *c );
void GLCD_DisplayChar    ( unsigned int ln, unsigned int col, unsigned char fi, unsigned char  c );
void GLCD_DisplayString  ( unsigned int ln, unsigned int col, unsigned char fi, unsigned char *s );
void GLCD_ClearLn        ( unsigned int ln, unsigned char fi );
void GLCD_Bargraph       ( unsigned int x,  unsigned int y,   unsigned int w, unsigned int h, unsigned int val );
void GLCD_Bitmap         ( unsigned int x,  unsigned int y,   unsigned int w, unsigned int h, unsigned char *bitmap );
void GLCD_ScrollVertical ( unsigned int dy );
void GLCD_WrCmd          ( unsigned char cmd );
void GLCD_WrReg          ( unsigned char reg, unsigned short val ); 

Using printf

Once you understand formatted printing, you will be interested in printing to the LCD screen. First, download the .zip file in the source directory and place these into your project directory. You will require to include three files:

  • stdio.h
  • GLCD_Scroll.h

at the top of your source file.

Note that you will working in Windows and Windows does not have case-sensitive file names. Therefore, while identifiers are case sensitive, names like GLCD_Scroll.h are not; consequently, if you are working in a Windows environment, one file may use GLCD_Scroll.h while another may use glcd_scroll.h.

#include <LPC17xx.h>
#include <stdio.h>
#include "GLCD_Scroll.h"

Now, inside your main function, you must first initialize the liquid-crystal display, and then initialize the scrolling feature.

	init_scroll(); 

Now you can use the printf function as desired.

If you do not require the scrolling feature, you need only include the library GLCD.h and the initialization command will be GLCD_Init();.

Next, learn about a real-time memory allocator where all allocations and de-allocations have a Θ(1) run time (good for Project 2), see Dynamic memory allocation.

Troubleshooting

One issue with printing to the LCD screen is that in some cases, the characters print in the reverse direction (from right to left). In this case, find the GLCD_SPI_LPC1700.c file that exists in the Blinky project (go to C:\Keil\ARM\Boards\Keil\MCB1700\Blinky).