User manual
5) CUSTOM CHARACTERS
The LCD controller is great for ready-made alphanumeric characters: send the code for a
character in ROM, and it is displayed on the LCD. But there is also a very small amount of
RAM reserved for custom characters. The controller can hold up to 8 characters of your
own design. To create and display these characters, use the following procedure:
- Design your 5x8 character
- Code it into 8 bytes, one byte for each row
- Save the data in the controller’s ‘character generator RAM’
- Repeat above steps for up to 8 characters
- Display the character by sending the corresponding code (0x00 through 0x07)
Let’s try a useful example: a battery status indicator. We will create seven symbols, going
from no-charge to full-charge. Fill in the outline of the no-charge symbol, assigning a ‘1’ to
a filled square and ‘0’ to a clear square.
Here is the battery symbol on a 5x8 grid. There
are 8 rows, and each row has 5 columns. The
green box shows how we convert the binary
ones and zeros of each row to their
hexadecimal equivalent. Our 8-byte
representation for the symbol, from top to
bottom, is the list [0x1E, 0x1B, …, 0x1F]
To create a full-charge battery, just fill in the middle rows. As you fill each middle row, its
value will change from 0x11 to 0x1F. A list of all of these battery symbols looks like this:
battery = [
[ 0x0E, 0x1B, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F ], #0% (no charge)
[ 0x0E, 0x1B, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F ], #17%
[ 0x0E, 0x1B, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x1F ], #34%
[ 0x0E, 0x1B, 0x11, 0x11, 0x1F, 0x1F, 0x1F, 0x1F ], #50% (half-full)
[ 0x0E, 0x1B, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F ], #67%
[ 0x0E, 0x1B, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F ], #84%
[ 0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F ], #100% (full charge)
]
Each row of this list corresponds to a battery symbol, from the no-charge symbol on top, to
the full-charge symbol on the bottom.
0
1
1
1
0
1
1
0
1
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
1
1
1
1
0b01110 = 0x1E
0b11011 = 0x1B
0b10001 = 0x11
0b10001 = 0x11
0b10001 = 0x11
0b10001 = 0x11
0b10001 = 0x11
0b11111 = 0x1F