1. Introduction
In the previous tutorial, we saw how to print English font on OLED display. In this tutorial, we will see how to print Indian languages. It was easy to print English characters as there is no composite word made from two half letters. But in Devnagari it is not the case. We will see what are the challenges to print Devanagari on OLED
In Indian languages, we are going to print Devanagari script. And in Devanagari script, we are going to use Shivaji02 font. You can use any other font also.
Please watch the following video before reading Further
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
3) Following window will open. I am selecting
Font -> Shivaji2 ,
Font style -> Regular
Size -> 22
4) We want to input the ASCII code of start and last character. input 32 to 137 as shown in the following image
5) The 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 { }.
7) paste the copied array in data[][] array declared in Arduino code.
3. Problems
3.1 separate characters
in the previous tutorial no. 3 we printed an English font. In English there are no composite words made from two half letters. But in Devanagari maximum words are made from two half characters. like as shown below
See in the image below, if we print Devanagari script using the same method which was used to print English then each character will be seen separately which is not expected. we are shifting cursor by the same amount before printing a new character.
@yaa
= @
+y
+ a+ a
See in the image below, if we print Devanagari script using the same method which was used to print English then each character will be seen separately which is not expected. we are shifting cursor by the same amount before printing a new character.
3.2 Solution-1
In the above image, we saw that there is a large gap between two characters when we print the Devanagari script. one solution for this is decreasing the spacing between two characters as shown in the image below:
But one problem in the above method is overlapping of two characters. Rightmost pixels of '@ ' are masked by leftmost pixels of 'y '. So need some improvement in this solution.
3.3 Solution-2
In solution-1 there is a problem at the overlapping region of two characters. The solution to this problem is OR operation in the overlapping region. OR operation means a pixel in the overlapping region will be ON if it is ON for one of the two characters. The image below shows the effect of OR operation in the overlapping region. The dotted red line represents the overlapped region.
We can see in the above image, OR operation in the overlapping region solved our problem. so we will implement solution-2
4. Implementation of the Solution
In the above section we saw, solution-2 solved our problem in the overlapping region. In this section, we will see how to implement solution-2.In 0.96 inch OLED I had, we can write data at any column and page, but we can't read it back. For OR operation, we need to do OR operation of Rightmost overlapping pixels of character which is printed on-screen with leftmost pixels of the character which is to be printed.
We can see in the above image, we need to OR operation of the region inside two dotted rectangles. But the problem is we can't access data in OLED.
The solution to this is, storing the copy of the data which we are sending to the OLED. This copy is a 2D array and it is called screen buffer.
Following image shows the screen buffer:
After OR operation and sending data to OLED, screen and screen buffer will show composite characters as we were expecting. You can see it in the following image
5. To print String:
In the previous tutorial code, we built one function called
print_string();
we need to pass a string that is to be printed. Now we will see want kind of string is to pass to this function to print Devanagari Font.
Following image shows the English keyboard to Shivaji Font conversion
1) Open Microsoft word (or any editor in which we can select a font)
2) Select Shivaji02 font
3) write a Devanagari string that you want to display in using the above image
4) Copy that Devnagari String and paste it in arduino code in
print_string("String",0,0);
2) Select Shivaji02 font
3) write a Devanagari string that you want to display in using the above image
4) Copy that Devnagari String and paste it in arduino code in
print_string("String",0,0);
No comments:
Post a Comment