3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Connecting Nokia 3310 LCD to USB using AVR

Step 9Making a custom font

Making a custom font
You don't like my 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!
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
7
Followers
1
Author:wkter