Character LCD Modules
Features
- Implements the industry-standard Hitachi HD44780 LCD display driver chip protocol through the GPIO pins, I2C, and SPI interfaces.
- Supports horizontal and vertical bar graphs.
General Description
The most commonly used Character LCD modules are based on the Hitachi HD44780 controller or others that are compatible with HD44580. The standard interface of the Character LCD module is parallel I/O pins, there are some devices in the markets that can convert I2C or SPI interface to the parallel ports. The Character LCD can be configured in 8-bit or 4-bit interface mode in which 8 data pins and 4 data pins are used respectively this feature allows efficient use of the digital I/O pins of the microcontroller.
Application Programming Interface (API)
Application Programming Interface (API)
Application Programming Interface (API) routines allow you to configure the component using the software. The following table lists and describes the interface to each function together with related constants provided by the "include" files. The subsequent sections cover each function in more detail.
Core Function
Functions | Description |
---|---|
ezLCD_Create() | Creates an LCD object |
ezLCD_Release() | Releases the LCD object |
ezLCD_Start() | Starts the LCD Object, enables communication interface, and turns on the LCD |
ezLCD_Connect_IO() | Connect the LCD module with standard GPIO pins |
ezLCD_Connect_I2C() | Connect the LCD module with I2C interface |
ezLCD_Connect_SPI() | Connect the LCD module with SPI interface |
ezLCD_Enable() | Turns on the display |
ezLCD_DisplayOff() | Turns off the LCD module’s display |
ezLCD_DisplayOn() | Turns on the LCD module’s display |
ezLCD_BackLightOn() | Turns on the LCD module’s backlight |
ezLCD_BackLightOff() | Turns off the LCD module’s backlight |
ezLCD_ClearDisplay() | Clears the data from the LCD module’s screen |
ezLCD_Position() | Sets the cursor¡¦s position to match the row and column supplied |
ezLCD_LoadVerticalBargraphFonts() | Loads vertical graphic bar characters into the LCD module |
ezLCD_LoadHorizontalBargraphFonts() | Loads horizontal graphic bar characters into the LCD module |
ezLCD_LoadCustomFonts() | Loads custom characters into the LCD module |
ezLCD_DrawHorizontalBG() | Draws a horizontal bar graph. Only available when a bar graph character set has been selected. |
ezLCD_DrawVerticalBG() | Draws a vertical bar graph. Only available when a bar graph character set has been selected. |
ezLCD_PutChar() | Sends a single character to the LCD module data to register at the current position. |
ezLCD_PrintString() | Prints a null-terminated string to the screen, character by character |
ezLCD_PrintInt8() | Prints a two-ASCII-character hex representation of the 8-bit value to the Character LCD module. |
ezLCD_PrintInt16() | Prints a four-ASCII-character hex representation of the 16-bit value to the Character LCD module. |
ezLCD_PrintInt32() | Prints an uint32 hexadecimal number as eight ASCII characters. |
ezLCD_PrintNumber() | Prints the decimal value of a 16-bit value as left-justified ASCII characters |
ezLCD_Print32Number() | Prints an uint32 value as a left-justified decimal value. |
ezLCD_PrintDecUint16() | Same as ezLCD_Print32Number() |
ezLCD_PrintHexUint8() | Same as ezLCD_PrintInt8() |
ezLCD_PrintHexUint16() | Same as ezLCD_PrintInt16() |
PEZOBJ_LCD ezLCD_Create(void) | |
Description: | This function creates an LCD object. |
Parameters: | None |
Return Value: | The LCD object |
void ezLCD_Release(PEZOBJ_LCD lcd) | |
Description: | This function destroys theLCD object. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_Start(PEZOBJ_LCD lcd) | |
Description: | Starts up the LCD module and loads configuration settings to the LCD. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_ConnectIO(PEZOBJ_LCD lcd, PEZOBJ_IO io) | |
Description: | This function connects the LCD object with the GPIO interface object. |
Parameters: | PEZOBJ_LCD lcd : The LCD object PEZOBJ_IO io : The GPIO port interface object |
Return Value: | None |
void ezLCD_ConnectI2C(PEZOBJ_LCD lcd, PEZOBJ_I2C i2c) | |
Description: | This function connects the LCD object with the I2C interface object. |
Parameters: | PEZOBJ_LCD lcd : The LCD object PEZOBJ_I2C i2c : The I2C interface object |
Return Value: | None |
void ezLCD8_ConnectSPI(PEZOBJ_LCD lcd, PEZOBJ_SPI spi) | |
Description: | This function connects the LCD object with the SPI interface object. |
Parameters: | PEZOBJ_LCD lcd : The LCD object PEZOBJ_SPI i2c : The SPI nterface object |
Return Value: | None |
void LCD_Enable(PEZOBJ_LCD lcd) | |
Description: | Turns on the LCD display. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_DisplayOff(PEZOBJ_LCD lcd) | |
Description: | Turns the display off, but does not reset the LCD module in any way. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_DisplayOn(PEZOBJ_LCD lcd) | |
Description: | Turns the display on, without initializing it. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_BackLightOn(PEZOBJ_LCD lcd) | |
Description: | Turns the display backlight on. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_BackLightOff(PEZOBJ_LCD lcd) | |
Description: | Turns the display backlight off. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_ClearDisplay(PEZOBJ_LCD lcd) | |
Description: | Clears the contents of the screen and resets the cursor location to be row and column zero. |
Parameters: | PEZOBJ_LCD lcd : The LCD object |
Return Value: | None |
void ezLCD_Position(PEZOBJ_LCD lcd, uint8_t row, uint8_t column) | |
Description: | Moves the cursor to the location specified by arguments row and column. |
Parameters: | PEZOBJ_LCD lcd : The LCD object uint8_t row : The row number at which to position the cursor. The minimum value is zero. uint8_t column : The column number at which to position the cursor. The minimum value is zero. |
Return Value: | None |
void ezLCD_LoadVerticalBargraphFonts(PEZOBJ_LCD lcd) | |
Description: | |
Parameters: | PEZOBJ_LCD lcd : the LCD object |
Return Value: | None |
void ezLCD_LoadHorizontalBargraphFonts(PEZOBJ_LCD lcd) | |
Description: | |
Parameters: | PEZOBJ_LCD lcd : the LCD object |
Return Value: | None |
void ezLCD_LoadCustomFonts(PEZOBJ_LCD lcd, uint8_t const customData[]) | |
Description: | Loads eight custom characters (user-defined fonts) into the LCD module to use the custom fonts during runtime. |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint8_t const customData[] : Pointer to the head of an array of bytes. The array should be 64 bytes long as 5x8 characters require 8 bytes per character. |
Return Value: | None |
void ezLCD_DrawHorizontalBG(PEZOBJ_LCD lcd, uint8_t row, uint8_t column, uint8_t maxCharacters, uint8_t value) | |
Description: | Draws a horizontal bar graph. Only available if a horizontal or vertical bar graph was loaded. |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint8_t row : The row of the first character in the bar graph uint8_t column : The column of the first character in the bar graph uint8_t maxCharacters : Number of whole characters the bar graph consumes. Represents height or width depending upon the bar graph selection. Each character is 5 pixels wide and 8 pixels high uint8_t value : Number of shaded pixels to draw. May not exceed the total pixel length (height) of the bar graph |
Return Value: | None |
void ezLCD_DrawVerticalBG(PEZOBJ_LCD lcd, uint8_t row, uint8_t column, uint8_t maxCharacters, uint8_t value) | |
Description: | Draws a vertical bar graph. Only available if a horizontal or vertical bar graph was loaded. |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint8_t row : The row of the first character in the bar graph. uint8_t column : The column of the first character in the bar graph. uint8_t maxCharacters : Number of whole characters the bar graph consumes. Represents height or width depending upon the bar graph selection. Each character is 5 pixels wide and 8 pixels high. uint8_t value : Number of shaded pixels to draw. May not exceed the total pixel length (height) of the bar graph. |
Return Value: | None |
void ezLCD_PutChar(PEZOBJ_LCD lcd, uint8_t character) | |
Description: | Writes an individual character to the screen at the current cursor location. Used to display custom characters through their named values. (EZLCD_CHAR_CUSTOM_0 through EZLCD_CHAR_CUSTOM_7). |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint8_t character : ASCII character to be displayed on the LCD module’s screen. |
Return Value: | None |
void ezLCD_PrintString(PEZOBJ_LCD lcd, char const str[]) | |
Description: | Writes a null-terminated string of characters to the screen beginning at the current cursor location. |
Parameters: | PEZOBJ_LCD lcd : the LCD object char8 const str[] : Null-terminated array of ASCII characters to be displayed on the LCD module’s screen. |
Return Value: | None |
void ezLCD_PrintInt8(PEZOBJ_LCD lcd, uint8_t value) | |
Description: | Prints a two-ASCII-character representation of the 8-bit value to the Character LCD module. |
Parameters: | PEZOBJ_LCD lcd : the LCD object. uint8_t value : The 8-bit value to be printed in hexadecimal ASCII characters. |
Return Value: | None |
void ezLCD_PrintInt16(PEZOBJ_LCD lcd, uint16_t value) | |
Description: | Prints a four-ASCII-character representation of the 16-bit value to the Character LCD module. |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint16_t value : The 16-bit value to be printed in hexadecimal ASCII characters. |
Return Value: | None |
void ezLCD_PrintInt32(PEZOBJ_LCD lcd, uint32_t value) | |
Description: | Prints an uint32 hexadecimal number as eight ASCII characters. |
Parameters: | PEZOBJ_LCD lcd : the LCD object uint32_t value : The 32-bit value to be printed in hexadecimal ASCII characters. |
Return Value: | None |
void ezLCD_PrintNumber(PEZOBJ_LCD lcd, uint16_t value) | |
Description: | Prints the decimal value of a 16-bit value as left-justified ASCII characters. |
Parameters: | PEZOBJ_LCD lcd : the LCD object. uint16_t value : The 16-bit value to be printed in ASCII characters as a decimal number. |
Return Value: | None |
void ezLCD_Print32Number(PEZOBJ_LCD lcd, uint32_t value) | |
Description: | Prints an uint32 value as a left-justified decimal value. |
Parameters: | PEZOBJ_LCD lcd : the LCD object. uint32_t value : The 32-bit value to be printed in ASCII characters as a decimal number. |
Return Value: | None |
1 | |
Description: | |
Parameters: | |
Return Value: | None |
1 | |
Description: | |
Parameters: | |
Return Value: | None |
1 | |
Description: | |
Parameters: | |
Return Value: | None |
Standard Character 2×16, 4×20 LCD Module
Standard Character LCD Module
The Hitachi 44780 compatible Character LCD modules can be interfaced in a 4-bit mode in order to reduce the pin requirements. The following table describes the LCD logical port pin to physical LCD module pin mapping.
Required Header File
#include "ezPSoC5Lib.h" #include "ezLCD.h"
Required PSoC Creator Component
Adafruit I2C/SPI Character LCD Backpack
Adafruit I2C/SPI Character LCD Backpack
Manufacturer
OVERVIEW
This is a very useful adapter to convert the parallel interface of the character LCD display module into I2C or SPI serial interfaces. This conversion reduces the number of LCDD connections to 2~3 wires. MCP23008 AND 74HC595 are two chips that convert serial inputs to parallel outputs. The MCP23008 is an 8-bit I/O expander connected to the I2C serial interface. The 74HC595 is an 8-bit shift register with a latch control to the SPI serial interface.
Technical Details:
MCP23008: 8-bit I2C I/O Expander
- 8-bit remote bidirectional I/O port
- High-speed I2C interface
- 100KHz
- 400KHz
- 1.7MHz
- Hardware slave address pins
- Three address pins [A2:A1:A0] allow up to eight devices on the same I2C bus
- Slave address range: 0x20 to 0x27
- Operating voltage:
- I2C @100KHz: 1.8V to 5.5V @ -40°C ~ +85°C
- I2C @ 400KHz: 2.7V to 5.5V @ -40°C ~ +85°C
- I2C @ 1.7MHz: 4.5V to 5.5V @ -40°C ~ +125°C
74HS595: 8-bit Shift Register with Latch Control
- 8-bit serial input, parallel output shift registers, and storage registers
- Both shift registers and storage registers have separate clocks (SHCP and STCP)
- Data is shifted on the rising-edge of the SHCP input
- Data is transferred from the shift register to the storage registers on the rising-edge of the STCP input
- Storage register with 3-state outputs
- 100MHz (typical) shift out frequency
I2C INTERFACE
By default, the adapter is configured on I2C interface mode. I2C bus uses only two bidirectional pins: Serial Data Line (SDA) and Serial Clock Line (SCL), and also supports multiple I2C devices on the same bus. Each I2C device has a unique Slave Address so that the I2C master can recognize each slave device. The adapter has 3 address pins. If you need more than one LCD display module on the same I2C bus, you need to configure each adapter in a different address by soldering separate jumpers on the [A2:A0] pins. The pin connections and I2C configurations are as follow::
- The connection between the MCP23008 and the I2C Interface:
- CLK pin to I2C: SCL pin
- DAT pin to I2C: SDA pin
- Address configuration pins: [A2:A0]
This chip uses an I2C 7-bit address with a range of 0x20-0x27. The lower-bits of this address are configured by [A2:A0] solder jumpers
- Configuration for I2C Master:
- Bit Rate: 400Kbps
- Data Bit: 8-bit
You can switch between I2C and SPI interface modes bt enabling/disabling the SPI Enable solder jumper:

- I2C Interface Mode:
To enable the I2C interface, you have to remove the solder on the SPI Enable solder jumper by using a solder sucker or solder wick. - I2C Slave Address Selection
This chip uses I2C 7-bit address with range of 0x20-0x27, configurable with solder jumpers [A2:A0]
SPI INTERFACE
Another option for communicating with the adapter is through the SPI interface. The standard SPI interface uses 3 or 4 wires. MOSI, MISO, SCLK, and SS are used in the 4-wire SPI interface, and SDA, SCLK, and SS are used in the 3-wire SPI interface. This adapter is using the 74LS595 chip to support SPI communication through the following pins: CLK, DAT, and LAT. In this mode, you have to connect 3 wires to the SPI interface: CLK (clock), DAT (data), and LAT (Latch). The pin connections and SPI configurations are as follow:
- The connection between the 74LS595 and the SPI Interface:
- CLK pin to SPI: SCLK pin
- DAT pin to SPI: MOSI pin
- LAT pin to SPI: SS pin
- Configuration for SPI Master:
- SPI Mode: CPHA=0, CPOL=0
- Data Bit: 8-bit
- Shift Direction: MSB First
- Bit Rate: 400Kbps
You can switch between I2C and SPI interface modes by enabling/disabling the SPI Enable solder jumper:

- SPI Interface Mode:
To enable SPI interface, you have to solder a blob on the SPI Enable solder jumper pins.
I2C Interface Mode: MCP23008
If you want to use the I2C interface mode, you have to disable SPI Enable solder jumper, and use the LCDMCP23008 sensor object in your PSoC 5LP project.
Required Header File
#include "LCDMCP23008.h"
Required PSoC Creator Component
I2C Master (Fixed Function or UDB)
Object Configurations
Configurations | Description | |
obj->Config.Addr | The I2C slave address. This value must be matched with the board solder jumper [A2:A0] Default: 000 |
|
obj->Config.LcdLine | The number of lines on the LCD Default: 4 |
|
obj->Config.LcdCols | The number of columns on the LCD Default: 20 |
|
obj->Config.DotSize | Configures the font size (dots) = LCD74HS595_LCD_5x8DOTS: The font size is 5x8 dots (Default) = LCD74HS595_LCD_5x10DOTS: The font size is 5x10 dots |
|
SPI Interface Mode: 74LS595
If you want to use SPI interface mode, you have to enable SPI Enable solder jumper, and use LCD74HS595 sensor object in your PSoC 5LP project.
Required Header File
#include "LCD74HS595.h"
Required PSoC Creator Component
SPI Master Bidirectional mode Marco
Object Configurations
Configurations | Description | |
obj->Config.Addr | The SPI SS (Slave Select) decoder number. This value is only used when you connect multiple SPI devices on the same bus and use SS decoder. Default: 0 |
|
obj->Config.LcdLine | The number of lines on the LCD Default: 4 |
|
obj->Config.LcdCols | The number of columns on the LCD Default: 20 |
|
obj->Config.DotSize |
Configures the font size (dots) |
|