As we saw on the previous page, industry-standard text LCDs include a basic set of characters. These types of LCD modules trade low cost and a simplified interface for the lack of ability to manipulate individual pixels. However, most provide the option for a software developer to create up to 4 or 8 bitmap characters.
My son began by drafting images on graph paper. In this case, the Nanox NDM082 module with Sanyo LC7985NA LCD controller allows monochrome (black and white) bitmaps up to 5x8.
We chose not to use the bottom row, so that an underline cursor can be displayed underneath the characters and so that they would be compatible with true 5x7 displays. Thus, my son worked on grids that were 5x7 (5 pixels wide by 7 pixels tall).
Next, the bitmaps are translated into binary. Each dark pixel is a 1 and each light pixel is a zero. For example, here is bitmap of a fox head as defined in flash on an Atmel AVR microcontroller when written in ImageCraft C.
__flash unsigned char LCDFoxCustomCharArray[]=
{
0b00010001,
0b00011011,
0b00011111,
0b00010101,
0b00011111,
0b00001110,
0b00000100
};
Notice the most-significant three bits are unused in each byte. So, for example, the first line could be rewritten as 0b10001. If your compiler doesn’t support binary, convert the binary values to a different number system. For example, binary 0b10001 is the same as decimal 17 or hexadecimal 0x11.
After initializing the LCD module upon power up, the custom characters must be loaded into the controller chip’s memory. This is done by setting the “screen position” to a particular non-displayed section of memory defined in the datasheet. Then, each row of the custom character is written just like you were writing characters to the screen.
After the bitmaps are loaded, you can write ASCII 0-7 characters to the displayed portion of the screen to choose which of your bitmapped custom characters (0-7) to display. For example, if you load the fox bitmap into the lowest custom character memory address, and then you write ASCII character 0 to the top-left corner of the screen, then the fox will appear there. If you then write ASCII character 0 to the bottom-right corner of the screen, the fox will appear in both places. You’ve created a character stamp, so to speak.
Here are some of my son’s custom characters and my custom characters written to the screen.
Custom LCD characters.
The screen shot above shows eight custom characters. Some LCDs permit only four custom characters.
You can modify the bitmaps anytime you’d like and the screen will instantly update. This provides the ability to change characters for different pages that your project displays. Or, it allows you to animate a bitmap.
A couple of common uses for custom characters that are repeatedly modified are:
The next time you spot a 14-pin or 16-pin connector on an alphanumeric LCD module for sale on eBay or an electronics reseller, you now know it may be using an industry-standard interface. The benefit to using a standard module is that you can reuse code and connectors throughout your projects. And, if no more of those specific parts are available, you might be able to substitute another LCD module.
But, the best part of a standard LCD interface is that you may run across bargains, like I did with the 2x8 Nanox LCDs for which the reseller didn’t have hookup specs.