Here’s a method I’ve developed for generating an ASCII character set using a combination of an Excel spreadsheet and a perl script.
The spreadsheet is used to visually edit the character set, the perl script converts the data in the spreadsheet into a set of C source files which can be compiled into your Arduino code.
The code can be downloaded from here :
characterSetGenerator.zip
Instructions
To use this package to generate a character set you need the following:
- Excel for Windows or Mac
- perl
If you are using a Mac, you need to have Spreadsheet::ParseExcel perlpackage installed, or if you are using Windows, you need to have use Win32::OLE perl package installed. These packages are used to read the Excel spreadsheet from perl and can be installed from the CPAN perl package sources available on the internet.
Once you have the appropriate perl package installed begin by opening charset.xls. You’ll see something like this:
- Column A contains the decimal value of the character as per the ASCII table.
- Column B contains the nominal character.
- Column C contains the character array offsets of the bytes for each character.
- Column D lists the row number for each pixel in the character.
- Columns E to L contain the graphical representation of each character.
- Columns N to U contain the binary representation of the character data.
- Columns W to AD are the hexadecimal conversion of each byte of character data.
You can edit the character data by entering a “1” or a “0” in each square in the graphical character area. If you enter a “1” the square turns red, otherwise it stays white. The binary representation and associated hex value also change as the squares are edited allowing you to check things as you go.
The graphical area contains a 5×7 pixel sub-region which is the nominal character size. A character can be larger than this region, it is just a guide to help editing characters.
However as it stands the perl script only uses the first 5 columns of character data to create the character set source files because I wanted a set of 5×7 pixel characters.
Once you have finished with Excel save the file and open a terminal, go the directory which contains all the files and enter the following:
peewee~: tom$ perl genChar-unix.pl charset.xls font
Windows users should use genChar-win.pl.
This will create two files “font.h” and “font.c”.
“font.h” contains the declaration of the character set array as an array in program memory and a couple of relevant #defines.
“font.c” contains the actual array containing the font data. Each character starts at a 5-byte offset in the array.
These two files can now be added to your Arduino sketch and compiled into your code!
Thanks for providing this code. I appreciate it.
Hi sir,
this blog is very help full to me but ,i need bit maps for 16 rows and 10 columns ….please give me solution or give me source code plz
The source code is all there to download from this page.
It has been a long time since I last looked at the code. You need MS Excel (or something compatible) and perl.
You use Excel to draw the character bitmaps and the perl script to generate C code with the bitmap information from the spreadsheet.
You should be able to modify the spreadsheet and perl script to generate code for 16×10 characters.
I love it. Thank You!!!