Osama's Lab

Home‎ > ‎Projets list‎ > ‎

Arabic - English GLCD Library

This library provides some functions for interfacing graphic LCD's that uses KS0108 controller, such as "Top way displays", The following functions are available:


Function Table:

 Function
 Description
 Parameters
 glcd_on();
 Turn on GLCD
 No
 glcd_off();
Turn off GLCD 
No
 goto_col(int x);
Go to a specified column 
x: column number
0 to (GLCD width [e.g. 128]) 
 goto_row(int y);
Go to a specified row 
 y: Row number
0 to (GLCD height/8) [e.g. 8]*
 glcd_write(unsigned char b);
Writes 1 byte data at the
current location 
b: 1 – byte data to be written at the current
location 
 glcd_clrln(byte ln);
Clears a specified row 
 ln: The number of the line to be cleared  
0 to (GLCD height/8) [e.g. 8]*
 glcd_clear();
Clear  screen 
 No
 glcd_putchar(byte c,int x,int y,byte l);
Puts a character at the
current location 
 c: The character to be written
x, y: Location of the character to be written;Column, Row
l: Language         0: English
                            1: Arabic
glcd_puts(char *c,int x,int y,unsigned char l) 
Puts a string starting
from the current location 
 c: A pointer to the string
x, y: Starting location of the string
l: Language           0: English
                              1: Arabic

* 8 – bit vertical column is accessed at once.


Example:

glcd_clear();                                    //clear GLCD

glcd_puts(str,0,0,0);                      //Put an English string at column 0,row 0

glcd_puts(str2,40,3,0);                            //put another English string at column 5**,row 3

delay_ms(1000);                             //wait a second

glcd_off();                                         //Turn off display

delay_ms(1000);                             //wait a second

glcd_on();                                          //Turn on display

delay_ms(1000);                             //wait a second

glcd_clrln(0);                                   //Clear the first line

glcd_puts(ArStr,120,0,1);           //Put an Arabic string at column 15,row 6

glcd_puts(ArStr2,120,6,1);         //Put another Arabic string at column 15**,row 6

 

** To calculate x parameter for a column:

            column number X 8

 

 

How to use the library:


1. Download "ArEnGLCDLib.zip", and extract it.


2.    Copy “glcd.h” and “font.h” into your project’s directory

 

3.     Include “glcd.h”, you don’t have to include “font.h”; it will be included automatically.

 

4.     Strings to be displayed on the GLCD must be stored in a string variable e.g.

unsigned char str[] = "WELCOME";

 

5.     Specify a 8 – bit port for data transmission, set the DDR of this port to 0xFF (i.e. output), and         assign this port to the constant DATAPORT in “glcd.h” (line 8). e.g :         
                            
                                                                                                    #define DATAPORT PORTD

 

6.     Specify pins for EN, RW, RS, CS2, and CS1, set them all as outputs, and assign the selected pins      to the corresponding variables in “glcd.h” (lines 9 : 13). e.g. :      
 

     #define CS1 PORTC.4

    #define CS2 PORTC.3

    #define RS  PORTC.2

    #define RW  PORTC.1

    #define EN  PORTC.0

 

7.     Specify the number of columns and rows, by assigning values to the constants cols and rows          in “glcd.h” (lines 6, 7). e.g. :

 

    #define cols 128;

    #define rows 64;

 

8.     Enjoy using the functions shown in the table. Please don’t forget to specify the language, 0 for      English, and 1 for Arabic, as illustrated in the table.

 

Project and Simulation files:


How can I change the font ?

  1. Download arabic.zip and extract it. 
  2. Download LCD font generator.  (or from here)
  3. Open "arabic.lff" and modify each character as you like.
  4. Generate the modified array and replace the contents of the array "font" in "font.h" with the new generated array, don't change arrays name or type, leave it "flash unsigned char font" .


For any feedback, please contact me at:

                                   

                                                                        os.dexterity@ymail.com

 

Thanks,

Osama Salah Eldin                                     http://sites.google.com/site/osamaslab