You are viewing an older revision! See the latest version
Text LCD Enhanced
This page describes an enhanced forked version of the basic driver code library for Text LCD panels using the 4-bit HD44780 lcd display driver.
New features¶
- Support for more LCD types
- TextLCD::LCD8x1 8x1 LCD panel
- TextLCD::LCD8x2 8x2 LCD panel
- TextLCD::LCD16x4 16x4 LCD panel
- TextLCD::LCD24x2 24x2 LCD panel
- TextLCD::LCD24x4 24x4 LCD panel (for KS0078 controller)
- TextLCD::LCD40x2 40x2 LCD panel
- Support for Cursor and/or Blinking current character
- Support for User Defined Characters to display special symbols
- Improved methods to get and set the memory address of the current character
Example Code¶
// Hello World! for the TextLCD
#include "mbed.h"
#include "TextLCD.h"
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x4); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7 ok
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x2); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 ok
int main() {
pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
for (int row=0; row<lcd.rows(); row++) {
int col=0;
pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
lcd.putc('-');
// lcd.putc('0' + row);
for (col=1; col<lcd.columns()-1; col++) {
lcd.putc('*');
}
pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
lcd.putc('+');
}
}
Examples¶
Some results are shown here:





The terminal will print the actual memory address like this:
LCD Test. Columns=20, Rows=4 MemAddr(Col=0, Row=0)=0x00 MemAddr(Col=19, Row=0)=0x13 MemAddr(Col=0, Row=1)=0x40 MemAddr(Col=19, Row=1)=0x53 MemAddr(Col=0, Row=2)=0x14 MemAddr(Col=19, Row=2)=0x27 MemAddr(Col=0, Row=3)=0x54 MemAddr(Col=19, Row=3)=0x67
References¶
- You can find the new lib here: http://mbed.org/users/wim/code/TextLCD/