LCD custom character tool problem--help me pls

General discussion on mikroElektronika development boards.
Post Reply
Author
Message
tranlong1612
Posts: 30
Joined: 10 Apr 2011 07:00
Location: Viet Nam

LCD custom character tool problem--help me pls

#1 Post by tranlong1612 » 22 Jun 2011 09:56

Hi,
I created my own character by LCD custom character tool that is intergrated with MikroC PRO.
The code generated look like this:

Code: Select all

const char character[] = {7,3,21,24,24,21,3,7}; //Custom character here

void CustomChar(char pos_row, char pos_char) {
  char i;
    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);
}
When I tried to creat more than 1 custom character and display all of them on the LCD, it can only displayed 1 only. Can anyone tell me why please?
And...what is the meaning of "Lcd_Cmd(64)"? and the "LCD RETURN HOME", what is the address of "home"? I have been searching the Help section and didnt find anything like that. :(
Thanks in advance.

octal
Posts: 534
Joined: 09 Feb 2005 14:15
Location: France
Contact:

Re: LCD custom character tool problem--help me pls

#2 Post by octal » 22 Jun 2011 13:33

Hello,
use this code:

Code: Select all


//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
//MikroeElektronika 2011 
//http://www.mikroe.com 

//HD44780 Alpha Numeric Character Set - FontName : MyChars5x8
//HD44780 Alpha Numeric Character Set - FontSize : 5 x 8

const unsigned short MyChars5x8[] = {
        0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00,  // Code for char num #0
        0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F,  // Code for char num #1
        0x0E, 0x11, 0x1B, 0x11, 0x15, 0x11, 0x11, 0x0E,  // Code for char num #2
        0x00, 0x11, 0x1F, 0x11, 0x1B, 0x0E, 0x04, 0x00,  // Code for char num #3
        0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x04, 0x04, 0x04,  // Code for char num #4
        0x04, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x0E, 0x04,  // Code for char num #5
        0x1F, 0x00, 0x04, 0x04, 0x0E, 0x00, 0x00, 0x1F,  // Code for char num #6
        0x1F, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x1F   // Code for char num #7
        };


void InitHD44780CustomChars()
{
  char i;
  LCD_Cmd(64);
  for (i = 0; i <= 63 ; i++)
    LCD_Chr_Cp(MyChars5x8[i]);
  LCD_Cmd(_LCD_RETURN_HOME);
}
You need to send all chars to the disp to redefine them.
To make the chars, you can also use MikroElektronika GLCD Font Creator
http://www.mikroe.com/eng/products/view ... t-creator/

- Choose [File]->[New Font]->[New HD44780 LCD Custom Characters Set]
- Draw your chars
- Click on [Export Button] (button with MikroE logo on toolbar).
On the export window, choose your language (Basic/Pascal/C) and check the checkbox [Add HD44780 CGRAM custom chars routines]
Generated code will have the init routine and all the chars array!

Image
Image

Try Search feature of the forum... this topic has been discussed a lot:
http://www.mikroe.com/forum/viewtopic.p ... er#p137776
http://www.mikroe.com/forum/viewtopic.p ... 29#p114750
http://www.mikroe.com/forum/viewtopic.p ... nt+Creator
http://www.mikroe.com/forum/viewtopic.p ... er#p134172
http://www.mikroe.com/forum/viewtopic.p ... er#p132170

Regards
http://www.pocketmt.com

tranlong1612
Posts: 30
Joined: 10 Apr 2011 07:00
Location: Viet Nam

Re: LCD custom character tool problem--help me pls

#3 Post by tranlong1612 » 23 Jun 2011 03:42

Thank you so much. It worked^^

tranlong1612
Posts: 30
Joined: 10 Apr 2011 07:00
Location: Viet Nam

Re: LCD custom character tool problem--help me pls

#4 Post by tranlong1612 » 23 Jun 2011 06:09

New problem arised: when I created more than 8 custom characters then the LCD displayed something weird :( .
I followed the link u gave: for the 1st character I used Lcd_Cmd(64) and Lcd_Chr(row,chr,0) and for the n character: Lcd_Cmd(64+8*n) and Lcd_Chr(row,chr,n). But the LCD just display the first 8 correctly.
Can u help me one more time pls?

octal
Posts: 534
Joined: 09 Feb 2005 14:15
Location: France
Contact:

Re: LCD custom character tool problem--help me pls

#5 Post by octal » 07 Jul 2011 09:40

hi tranlong1612
check the datasheet of the HD44780 controller. You can define ONLY 8 characters at any time.
On Mikroelektronika GLCD Font Creator, you can ask to create more than 8 chars for two reasons:
1- This let you group your characters and special symbols all in the SAME project, and at export time, you can specify to export FROM char TO char, you can ask for chars in any interval (of 8 chars) to be exported.
2- SOME NEW chinese (I personally got one made in Japan) HD4470 "compatible" controllers, you have more CGRAM and you can redefine up to 256 (some users reported up to 368 chars on some specific controllers). This is not the case of most HD44780 controllers. So MikroElektronika GLCD Font Creator let you accomodate those specific controllers if needed. But check your controller, almost all HD44780 (chinese made) controllers are limited to 8 chars. writing beyond the 8 chars CGRAM addresses can generate anything and can even make your display controller to hang.
http://www.pocketmt.com

JennyJones
Posts: 1
Joined: 22 Nov 2011 11:38

Re: LCD custom character tool problem--help me pls

#6 Post by JennyJones » 22 Nov 2011 12:00

I have used these codes but my issue intact no change i really can't understand whats the problem is now i am thinking to through it out


Post Reply

Return to “Development Boards”