A project may use bitmaps converted to a C header file, to be stored along with the program in the program memory, or converted to a binary file to be stored in external flash memory, or both.
Bitmaps Converted To C Header File Format
The file ‘cbitmaps.h’ is created.
Each bitmap is saved as a constant. Example:-
const rom unsigned char bitmap_1[]={ //The filename was bitmap_1.bmp
0x0,0xA,0x0,0x4,0x0 //Bitmap WidthH:WidthL:HeightH:HeightL:Flags
0x55,0x40, //Line 0
0xAA,0x80, //Line 1
0x55,0x40, //Line 2
0xAA,0x80, //Line 3
};
const rom unsigned char logo_main[]={ //The filename was logo_main.bmp
0x0,0xA,0x0,0x3,0x0 //Bitmap WidthH:WidthL:HeightH:HeightL:Flags
0xFF,0xC0, //Line 0
0x0,0x0, //Line 1
0xFF,0xC0, //Line 2
};
The ‘const rom unsigned char‘ before each file name may be changed in the Bitmap Converter application to suit your compiler.
The ‘Flags’ field is provided for future upgradeability and is not currently used.
Bitmaps Converted To Binary File Format
A C header file (bbitmaps.h) is created with the start address of each bitmap contained in the binary file (starting at address 0). Example:-
#define bitmap_1 0x0
#define logo_main 0xd
A binary (bbitmaps.bin) file is created containing the bitmap data. Example:-
Byte 0: 0x00
Byte 1: 0x0A
Byte 2: 0x00
Byte 3: 0x04
Byte 4: 0x00
Byte 5: 0x55
Byte 6: 0x40
Byte 7: 0xAA
Byte 8: 0x80
Byte 9: 0x55
Byte 10: 0x40
Byte 11: 0xAA
Byte 12: 0x80
Byte 13: 0x00
Byte 14: 0x0A
Byte 15: 0x00
Byte 16: 0x03
Byte 17: 0x00
Byte 18: 0xFF
Byte 19: 0xC0
Byte 20: 0x00
Byte 21: 0x00
Byte 22: 0xFF
Byte 23: 0xC0
Note that the .bin file extension is not a standard file extension – the file format is not readable by any standard application.
The binary file may be copied to external flash memory in your application and accessed using the C ‘bbitmaps.h’ header file. Note that you will need to provide the means of copying the binary data to your flash memory to do this, and a ‘BYTE flash_read (DWORD address)’ function to allow the driver to read the flash memory.
‘Bootloader’ memory is a particularly good choice of memory for this type of application as it is low cost, fast to read and the block erase requirements are not usually a problem when just storing bitmap data. Other non volatile memory types are of course also suitable.
Font Bitmaps
The bitmap converter will also convert special font bitmap images, to be used for ASCII text output. A font bitmap file needs to be created in the following way:-
Say you wish to create a font that will be 5 pixels wide and 7 pixels high.
Create a bitmap image 5 pixels wide by 1016 high ((character height + 1) x 127)
Then create your font as follows:-
The top 5 x 7 pixel block will be the character that represents ASCII code 0×01
Then there is an unused row pixels, which may be used to provide say a single pixel marker between each character to make it easier to navigate through the bitmap (it is ignored by the bitmap converter application).
Then the next block of 5 x 7 pixels is the character that represents ASCII code 0×02, and so on.
An example showing arrow bitmaps stored in ASCII codes 0×01 and 0×02:-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
<- ASCII character 0×01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
<- The unused row that may be used for a marker between characters |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
<- ASCII character 0×02 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
<-Carries on until character 0x7F… |
Save the file using the following naming format:-
font####07.bmp
The important fields are the ‘font’ at the beginning (non case sensitive) and the height value in characters 9 and 10. The following are examples of valid file names:-
font_05x07.bmp
Font_05x07.bmp
Font_05x07_style_1.bmp
FontTyp107_style_1.bmp
The bitmap converter application will convert this type of file into a special font bitmap. This is the same as a normal bitmap, except that the height field will contain the character height, rather than the overall bitmap height. The display bitmap function will use the character height to locate the required ASCII character within the bitmap.
Note that .bmp bitmap images are stored from the bottom row upwards. The bitmap file bottom row must be the final unused marker row (as this is the first row that will be read by the bitmap converter application and will be stored as the first row of the bitmap image).
Should you not wish to use all 127 available ASCII character locations a file of a smaller overall height may be used and the bitmap converter application will only store the characters that are available (e.g. say you only want ASCII characters from 0×30 to 0x7F).
The following sample font bitmap files are included with the driver:-
5 x 5 pixel
5 x 7 pixel
6 x 10 pixel
7 x 13 pixel
23 x 26 pixel
The sample fonts contain the following characters:-
| HEX |
Character |
|
HEX |
Character |
|
HEX |
Character |
|
|
|
0×30 |
0 |
|
0×60 |
‘ |
| 0×01 |
Left arrow |
|
0×31 |
1 |
|
0×61 |
a |
| 0×02 |
Right arrow |
|
0×32 |
2 |
|
0×62 |
b |
| 0×03 |
Up arrow |
|
0×33 |
3 |
|
0×63 |
c |
| 0×04 |
Down arrow |
|
0×34 |
4 |
|
0×64 |
d |
| 0×05 |
|
|
0×35 |
5 |
|
0×65 |
e |
| 0×06 |
|
|
0×36 |
6 |
|
0×66 |
f |
| 0×07 |
|
|
0×37 |
7 |
|
0×67 |
g |
| 0×08 |
|
|
0×38 |
8 |
|
0×68 |
h |
| 0×09 |
|
|
0×39 |
9 |
|
0×69 |
i |
| 0x0A |
|
|
0x3A |
: |
|
0x6A |
j |
| 0x0B |
|
|
0x3B |
; |
|
0x6B |
k |
| 0x0C |
|
|
0x3C |
< |
|
0x6C |
l |
| 0x0D |
|
|
0x3D |
= |
|
0x6D |
m |
| 0x0E |
|
|
0x3E |
> |
|
0x6E |
n |
| 0x0F |
|
|
0x3F |
? |
|
0x6F |
o |
| 0×10 |
|
|
0×40 |
@ |
|
0×70 |
p |
| 0×11 |
|
|
0×41 |
A |
|
0×71 |
q |
| 0×12 |
|
|
0×42 |
B |
|
0×72 |
r |
| 0×13 |
|
|
0×43 |
C |
|
0×73 |
s |
| 0×14 |
|
|
0×44 |
D |
|
0×74 |
t |
| 0×15 |
|
|
0×45 |
E |
|
0×75 |
u |
| 0×16 |
|
|
0×46 |
F |
|
0×76 |
v |
| 0×17 |
|
|
0×47 |
G |
|
0×77 |
w |
| 0×18 |
|
|
0×48 |
H |
|
0×78 |
x |
| 0×19 |
|
|
0×49 |
I |
|
0×79 |
y |
| 0x1A |
|
|
0x4A |
J |
|
0x7A |
z |
| 0x1B |
|
|
0x4B |
K |
|
0x7B |
{ |
| 0x1C |
|
|
0x4C |
L |
|
0x7C |
| |
| 0x1D |
|
|
0x4D |
M |
|
0x7D |
} |
| 0x1E |
|
|
0x4E |
N |
|
0x7E |
~ |
| 0x1F |
|
|
0x4F |
O |
|
0x7F |
Vertical bar (* required) |
| 0×20 |
|
|
0×50 |
P |
|
|
|
| 0×21 |
! |
|
0×51 |
Q |
|
|
|
| 0×22 |
“ |
|
0×52 |
R |
|
|
|
| 0×23 |
# |
|
0×53 |
S |
|
|
|
| 0×24 |
$ |
|
0×54 |
T |
|
|
|
| 0×25 |
% |
|
0×55 |
U |
|
|
|
| 0×26 |
& |
|
0×56 |
V |
|
|
|
| 0×27 |
‘ |
|
0×57 |
W |
|
|
|
| 0×28 |
( |
|
0×58 |
X |
|
|
|
| 0×29 |
) |
|
0×59 |
Y |
|
|
|
| 0x2A |
* |
|
0x5A |
Z |
|
|
|
| 0x2B |
+ |
|
0x5B |
[ |
|
|
|
| 0x2C |
, |
|
0x5C |
\ |
|
|
|
| 0x2D |
- |
|
0x5D |
] |
|
|
|
| 0x2E |
. |
|
0x5E |
ˆ |
|
|
|
| 0x2F |
/ |
|
0x5F |
_ |
|
|
|
Unused characters can be used to add your own special characters if required.
(* required) The character at location 0x7F must be a single vertical bar. This special character is used for the space between each character and the width of the bar determines the number of blank pixels to be placed between each character.