Simple font data for LED matrix displays

By | November 6, 2011

My next mouse will have to have one of those small LED matrix displays. Not only is it actually useful to have a way of getting some feedback from the mouse, but these days, you feel a bit left out without one. There are numerous examples of 5×5 matrix font data available but when you need to design special characters it can get a bit tedious. Not being able to find anything suitable to help me, that would also run on a mac, I turned to Excel for help…

A spreadsheet may not be your first choice but actually, it is quite handy. The display itself needs to be fed patterns of bits where a 1 causes an LED to light and a 0 leaves it dark. There are 5 columns of 7 LEDs and so five bytes of data are needed for each character definition. The device I am using is the HCMS-3905 – a green, 3.3V four digit display. On this device, the top-most LED in each column corresponds to the least significant bit in the data.

HCMS-3905 four character,5x7 LED matrix display

The font data is stored in the program source code as an array something like this:

static const char Font5x7[] = {
	0x80, 0x80, 0x80, 0x80, 0x80,
	0x40, 0x40, 0x40, 0x40, 0x40,
	0x20, 0x20, 0x20, 0x20, 0x20,
	0x10, 0x10, 0x10, 0x10, 0x10,
	0x08, 0x08, 0x08, 0x08, 0x08,
	0x04, 0x04, 0x04, 0x04, 0x04,
	0x02, 0x02, 0x02, 0x02, 0x02,
	0x01, 0x01, 0x01, 0x01, 0x01
}

You may choose to have whatever characters you like so for the full, standard 7-bit ASCII set, you would need up to 128 rows of 5 bytes rather than the 8 examples rows above.

The tedious part is either keeping in your head what binary numbers make what shape or, colouring in squares on graph paper.

The spreadsheet software, Excel, allows you to calculate the values automatically, format them up into a suitable string to copy and paste into your code. It can even be persuaded to show a coloured in version while you work. In use, it looks like this:

Just enter a 1 where the LED is to be lit and a zero where it is not. Auto formatting takes care of the colouring for you. Copy and paste the line in bold straight into your code. the spreadhsheet itself is a record and visual reminder of the font details.

It would not take much imagination to modify this for 8×8 or any other size font.

You can download the spreadsheet here: 5×7-font designer spreadsheet.

 

5 thoughts on “Simple font data for LED matrix displays

  1. Peter Harrison Post author

    I have one of those – the smaller one. They are excellent in many ways but a bit large for permanent mounting.

    Is there no micromouse in Spain at all?

  2. Peter Harrison Post author

    These are readily available but not, by any means, inexpensive.
    In the UK, they can be had from Farnell or RS for about £28 + VAT
    Look for similar items for different colours and numbers of rows/characters.

  3. dragonet80

    Hi Peter,

    Yes, we do not have micromouse competitions in Spain (I would love to have one). Some schools/universitys have had some kind of maze competitions, but very diferents in size and rules from official micromouse.

    Respect to display, yes, it is very expensive, 40€ in Farnell Spain. Recently I found this web, far more cheaper, from avnet:
    http://avnetexpress.avnet.com/store/em/EMController/LED-Displays/Avago-Technologies/HCMS-3906/_/R-728585/A-728585/An-0?action=part&catalogId=500201&langId=-1&storeId=500201&listIndex=-1

    I never bought from them before, so I do not know if they are trust nor how much is shipping cost.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.