>info page
>release schedule
  first steps
  compiler settings
  linker settings
  assembler settings
  programmer settings
    first steps
    direct memory debugger
    PC only debugger
    in circuit debugger
    seven segments wizards
    dot matrix library wizard
    dot matrix character wizard
    font wizard
  font wizard tutorial
hosted by Logo
>New site up and running
>New project launched:
>propose new project
>legal disclaimer
>Not logged in.

Dot matrix character wizard

The dot matrix character wizard helps You with painting characters for text based displays, which have a character generator RAM. You may paint characters of the size 5x8 and 5x10 using this wizard. Figure 1 shows the wizard window.

Figure 1: The wizard window

The variable name determines the name of the variable which is used to store the information for the user defined characters. The type of that variable is determined by the Type field. A good choice is static prog_char. This type makes the avr-gcc store the information in the flash eeprom, where usually the program is stored. This helps You save RAM space in Your microcontroller. It is necessary to have the pgmspace.h header file included using the #include <avr/pgmspace.h> statement. Otherwise, the data type prog_char is not defined. If You insert the variable in a function, make sure to define the variable static. If it is defined outside of a function, the static keyword may be omitted.
The size of the characters, as used by Your display, can be defined by the radio buttons "5x8" and "5x10". Only the currently selected character will be changed. To add a character, press the "Add" button, to remove the currently selected character, press the "Remove" button. The order of the characters in the array may be changed by the "Up" and "Down" buttons.


To paint the currently selected character, use the green area in the left of the window. By clicking on it using the left mouse button draws a dark dot. Clicking on the right button clears the dot. You can also hold one of these buttons to draw continuously. You will see a small preview of all characters left of the numbers of the characters in the characters list view, as You can see in figure 2.
Another possibility is to draw the characters in an external program, using a 5x8 or 5x10 canvas respectively, and save the file to disk. Then use the konqueror, browse to the file You saved, drag the image, and drop it onto the green area. The KontrollerLab will accept that drop and paint a character according to that image (the image will be converted to greyscale and every pixel darker than 128 will be drawn as dark dot.)

A little example

Here is a little example to make it easier. The following code sets all 8 user-defined characters of a HD44780 based display using the library of Peter Fleury. This library can be added automatically in the KontrollerLab. How to do this is described in the dot matrix library wizard section. But, of course, You can also use another library for interfacing the display. This one is selected because it comes with the KontrollerLab and is very flexible and easy to use.

#include "dm_lcd.h"
#include <avr/pgmspace.h>

int main()
    // WIZARD CODE Do not edit the lines below.
    // Otherwise the wizard may be unable to reread the settings.
    static prog_char newChar[] = { 0x3, 0x5, 0x9, 0x11, 0x9, 0x5, 0x3,
                                   0x0, 0xe, 0xe, 0xe, 0xe, 0xe, 0x1f,
                                   0xe, 0x4, 0x4, 0xe, 0x1f, 0xe, 0xe,
                                   0xe, 0xe, 0xe, 0x0, 0x4, 0x1e, 0x1f,
                                   0x1e, 0x4, 0x0, 0x0, 0x0, 0x4, 0xf,
                                   0x1f, 0xf, 0x4, 0x0, 0x0, 0x1, 0xe,
                                   0xe, 0x5, 0x4, 0x4, 0xa, 0x11, 0x1,
                                   0x2, 0x2, 0x4, 0x14, 0x8, 0x8, 0x0,
                                   0x7, 0x8, 0x1e, 0x8, 0x1e, 0x8, 0x7,
                                   0x0 };

    uint8_t addressCounter=0;

    lcd_puts("CG-RAM  ");
    lcd_puts("\x1\x2\x3\x4\x5\x6\x7\nHello world!\0");

    for (addressCounter=0;addressCounter<64;addressCounter++)
        lcd_data( pgm_read_byte(&newChar[ addressCounter ]) );

    while (1)
Listing 1: The example code

The code is organized as follows: First, the user defined characters are defined. Then, the display is initialized and cleared, using the lcd_clrscr(); command. After that, the cursor is set to the first position, and then we write "CG-RAM " to the display. Now, we send a 0 (the binary number, not ASCII "0"!) to the display. This signalizes the display to show the first user-defined character here, which has the index 0. This cannot be done by the lcd_puts command, because lcd_puts expects a null-terminated string, and would misinterpret the 0. Afterwards, we write all user-defined characters to the line, one after the other. Then, we write a "Hello World!" to the second line.
Now we have to tell the display, how the user-defined characters should look like. This is done by the for loop. It sets the CG RAM address, using the lcd_command statement, and then writes one byte of the user-defined character array to the display.

When You open the wizard while the cursor is in one of the lines between // WIZARD CODE Do not edit the lines below. and // END OF WIZARD CODE, then the wizard window will come up as shown in figure 2. It automatically reads in the data from the file. If You change the characters, and click "OK", these lines will get changed accordingly.

Figure 2: The wizard window when started while the cursor is on the line where newChar[] is defined.

The result of the little example is shown in figure 3.

Figure 3: The result of the example

This site was created using free software only:
The GIMP, Quanta, KPovModeler and Povray.