Step 9: Making a custom font
Well, in the case, why not make your own? It's really simple.
Each character is made up of 5 bytes, meaning they will show up as 8 x 5 pixels on the display. This is enough room for most characters. The font is embedded on the AVR for fast access (It would take ages to send through USB), in an array named "font" located in Atmega8_LCD.h in the sources.
The easiest thing to do is overwrite the font I already have made in the font array, as then you don't have to mess with any other code. Simply remove everything inside the brackets of this array:
static const unsigned char font[] = {
//Delete everything inside here
}
Then it's just so make your own font, starting at *space* (The 33rd ASCII character)!
If you want a ASCII lookup table, to see what characters you need to make, this is a good reference. Remember that you need to add 5 bytes for every character you make, and you cannot skip any characters!
Here's a blueprint you can copy:
0b00000000, // Character *NOTHING*
0b00000000,
0b00000000,
0b00000000,
0b00000000,
If you for some reason do not wish yo use all 5 bytes, you can use the special code for "skipping":
0b10000000
This will simply not draw anything, and will not move the X location. By doing this, you can make the characters have a single pixel spacing between them no matter how big or small the character is (Instead of a lot of empty space between the characters). The only bad thing with this is that you cannot have a character that uses that last pixel. I didn't worry about that, because my font has 1 pixel spacing there, so the font looks nicer.
If it becomes a problem for your font, you can always change it to something else in the LCD_writeChar function.
Here's an example character for you, it's the capital A from my font:
static const unsigned char font[] = {
....
0b01111000, // Character A
0b00100100,
0b00100100,
0b01111000,
0b10000000, // Skip last pixel
....
}
(The rules of writing pixels to the LCD still count here, 1st bit = upper, 8th bit = lower, read right to left)
Note that 1 pixel of spacing between characters are automatically added!
Remove these ads by
Signing Up























Not Nice













Visit Our Store »
Go Pro Today »



