1. Introduction
In the previous tutorial, we displayed a 12x24 matrix on OLED display. In this tutorial, we will display English font on OLED. We will create Hex code for English font in GLCD Font Creator.
Please Video of this on Youtube:
2. Creating Hex code For Font
Steps to create a custom font for OLED are as follows:
1) Open GLCD Font creator
2) Goto File->New Font-> Import An Existing System Font
Font -> @DFGothic-EB font ,
Font style -> Regular
Size -> 18
4) We want to input the ASCII code of start and last character:
5) Following window will open. Now click on 'Export for GLCD'
6) In following windows 1)select mikroC 2) then copy full array in between two curly braces { }.
Storing Array in Flash memory:
In the following image, we calculated the number of bytes required for storing a single character Hex code
37bytes are require for storing single character's Hex code
No. of characters we want to display = 127-31= 96
No. of bytes required for 96 characters = 96 x 37 = 3552 byte
But SRAM of Microcontroller ( Arduino in this case) is 2 kb i.e 2048 bytes
So we will store our Hex code array in Flash memory which is 32kb in Arduino. It is done using PROGMEM as follows:
const PROGMEM dataType variableName[] = {};
Also, you need to know the first character is represented by first 37 items in an array and their index are from 0 to 36 in which the first number does not represent any pixel. Next character is represented by items with index 37-73 as shown in following image.
The following function
1) takes input as a character, x and y position
2) finds line no. in array ( as shown in above image)
3) Finds the index of item from which hex code of character to be displayed is started and add 1 because first Hex no. does not represent any pixel
1) takes input as a character, x and y position
2) finds line no. in array ( as shown in above image)
3) Finds the index of item from which hex code of character to be displayed is started and add 1 because first Hex no. does not represent any pixel
To Print string we need to call above function in a loop and also each time we need to shift cursor by character width to print next character in at next location on the screen. Following code implement the same
_______
_______
No comments:
Post a Comment