problems with display 16x2

GLCD Font Creator software is the ultimate solution to create personalized fonts, symbols and icons for Graphic LCDs. It generates code compatible with All mikroElektronika compilers
Post Reply
Author
Message
Feo
Posts: 20
Joined: 29 Jan 2012 17:58
Location: Russian Federation

problems with display 16x2

#1 Post by Feo » 01 Jan 2013 10:41

Hi,
I'm using an EasyPic7, a pic 16f876 with a 4Mhz crystal and the lcd display is a WINSTAR model WH1602B-TMI-ET#(from EasyPic7).
I need pictograms to be showen on display , like in pic.№1 of the attachment.
I'm trying to make code work with one symbol - symbol №0 in pic №1.

Code: Select all

const unsigned short Untitled5x8[] = {
        0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char num #0
               };
void InitHD44780CustomChars()
{
  char i;
  LCD_Cmd(64);
  for (i = 0; i <= 7 ; i++)
    LCD_Chr_Cp(Untitled5x8[i]);
  LCD_Cmd(_LCD_RETURN_HOME);
}
...............................
void main(){
while (1){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
delay_ms(500);
InitHD44780CustomChars();
delay_ms(500);
}

}
This variant shows nothing on display.
But, when changing code (adding {} to circle for):

Code: Select all

void InitHD44780CustomChars()
{
  char i;
  LCD_Cmd(64);
  for (i = 0; i <= 7 ; i++)                {
    LCD_Chr_Cp(Untitled5x8[i]);
  LCD_Cmd(_LCD_RETURN_HOME);   }
}
The first place has line at top on display, as is needed.
For getting the second line we change the code:

Code: Select all

const unsigned short Untitled5x8[] = {
        0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char num #0
               };
after programming the controller indication is not changed. When the board is switched off and then switched on again the monitor shows random elements in the first place.
Delete {} from circle FOR, program - nothing on the monitor. When programming with {} - two lines are shown.

What do you think the matter is?.
Don't know as well what the command LCD_Cmd(64) is for.
Attachments
1.jpg
1.jpg (67.98 KiB) Viewed 7674 times

Seniorlemuren
Posts: 125
Joined: 25 Sep 2012 23:51
Location: Sweden

Re: problems with display 16x2

#2 Post by Seniorlemuren » 01 Jan 2013 20:06

You could do it like this:

Code: Select all

const char character_zero[] = {0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};    //char  -

void CustomChar0(char pos_row, char pos_char) {
  char i;
    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_zero[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);
}
...............................
void main(){
              // All stuff you do here depending on uC comes first

    .
    .
     Lcd_Init();
     Lcd_Cmd(_LCD_CLEAR);               // Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
     Lcd_Out(1,1,"My char zero") ;
     CustomChar0(2,1);                 //Lcd  row #2, pos #1
}
Or if you have several custom char, you could do it like this:

Code: Select all

const char character_zero[] = {4,0,14,1,15,17,15,0};    //char å
const char character_one[] = {10,0,14,1,15,17,15,0};    //char ä
const char character_two[] = {10,0,14,17,17,17,14,0};   //char ö
const char character_three[] = {4,14,17,17,31,17,17,0}; //char Å
const char character_four[] = {10,14,17,17,31,17,17,0}; //char Ä
const char character_five[] = {10,14,17,17,17,17,14,0}; //char Ö

void load_char() {
  char i;
    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_zero[i]);
    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_one[i]);
    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_two[i]);
    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_three[i]);
    Lcd_Cmd(96);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_four[i]);
    Lcd_Cmd(104);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character_five[i]);
}


void main() { 
              // All stuff you do here depending on uC comes first

    .
    .
     Lcd_Init();
     load_char();
     Lcd_Cmd(_LCD_CLEAR);               // Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
     Lcd_Out(1,1,"All my char") ;
     Lcd_Chr(2,1,0);
     Lcd_Chr_CP(1);
     Lcd_Chr_CP(2);
     Lcd_Chr_CP(3);
     Lcd_Chr_CP(4);
     Lcd_Chr_CP(5);

}
Regards

Plain common sense is not very common.

Feo
Posts: 20
Joined: 29 Jan 2012 17:58
Location: Russian Federation

Re: problems with display 16x2

#3 Post by Feo » 01 Jan 2013 20:31

thanks a lot!Your code is correct, but I can't get why it works.
"Lcd_Chr(pos_row, pos_char, 0);" why we need to add this function. If i get right, it just indicates the symbol's place.
Why we put zero into this place?

Seniorlemuren
Posts: 125
Joined: 25 Sep 2012 23:51
Location: Sweden

Re: problems with display 16x2

#4 Post by Seniorlemuren » 01 Jan 2013 20:56

:) If you look at the LIbrary for LCD you can se the prototype for Lcd_Chr

Code: Select all

void Lcd_Chr(char row, char column, char out_char);
You give the row and column for the char 0. char 0 is your custom char. If you look at the next example with more than one char you maybe understand how it works.

You ask earlier why this "Lcd_Cmd(64);" is for. That is the RAM address for the custom char. Next custom char it to be in RAM address 72 and so on.
Regards

Plain common sense is not very common.

Post Reply

Return to “GLCD Font Creator Software”