1

I have 132x65 dot matrix LCD. I am using STM32f303 controller in my application. I got success in displaying the normal 5x7 fonts on LCD. Now I what I want to do is to display 13x16 custom sized fonts on the LCD. I generated the appropriate hex code for all 95 characters for the 13x16 size. In 5x7 i was able to send all the bytes using following routine.

void Display(uint8_t Display_Row, uint8_t Display_Column, unsigned char) 
{
  uint16_t String_Pointer_Offset;

  String_Pointer_Offset = 0;

  while( '\0' != *(String_Pointer + String_Pointer_Offset) )
  {
#if (defined(DISPLAY_WRAP_TEXT_STRINGS) && (DISPLAY_WRAP_TEXT_STRINGS == YEP ))
    if(Display_Column > SHADOW_LAST_COLUMN) /* Check if it's the appropriate to wrap the row printing the exceeding character on the next line. */
    {
      Display_Column = 0;
      Display_Row ++;
    };
    if (Display_Row > SHADOW_LAST_LINE)
    {
      return; /* Ran out of space :( */
    };
#else /* if (not defined(DISPLAY_WRAP_TEXT_STRINGS) || (DISPLAY_WRAP_TEXT_STRINGS == NOPE )) */
    if( (Display_Column > SHADOW_LAST_COLUMN)
     || (Display_Row    > SHADOW_LAST_LINE  ) )
    {
      return; /* Ran out of space :( */
    };
#endif
    Display.Row[Display_Row].Column [Display_Column] = *(String_Pointer + String_Pointer_Offset);
    Display.Row[Display_Row].Touched[Display_Column] = TRUE;

    Display_Column ++;
    String_Pointer_Offset++;
  };

  return;
}

And using Display_Print(1,1,"ABC \0"); function in the main file i was able to display the string on my LCD.

But here number of bytes 26 instead of 8 so which can not be sent simultaneously on parallely interfaced LCD. Can anyone help me how to achieve this big 13x16 pixel font display task?

spp
  • 151
  • 2
  • 13
  • Hi, you seem to have edited out a lot of the text in the question; I think it makes the question (and my answer to it :D ) more unclear now. But up to you. In any case great that your code is working now. – PkP Nov 03 '14 at 09:43
  • I am sorry for that..but i am a bit stuck in some another issue, I am working on that...seems it's over (hope fully i would be able to do it by my self) I will edit the question once again for the better understanding. – spp Nov 03 '14 at 10:27

2 Answers2

3

I just simulated the character you added to your question, and it looks OK to me. For reference, I wrote this code:

    unsigned char cha[] = {0x00, 0x0C, 0x00, 0x03, 0xC0, 0x01, 0x30, 0x01, 0x0C, 0x01, 0x30, 0x01, 0xC0, 0x01, 0x00, 0x03, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void main(void) {
    int i;
    int j;
    for (i=0; i<sizeof(cha); i++) {
        for (j=0; j<8; j++) {
            printf("%c",(cha[i]&(1<<j)) ? '#' : '.');
        }
        i++;
        for (j=0; j<8; j++) {
            printf("%c",(cha[i]&(1<<j)) ? '#' : '.');
        }
        printf("\n");
    }
}

and it prints out:

..........##....
........##......
......###.......
....##..#.......
..##....#.......
....##..#.......
......###.......
........##......
..........##....
................
................
................
................

So it seems that your font data for the character "A" seems ok and to write this to the LCD's row 0, you'd write bytes 0,2,4,6,8,... (0x00, 0x00, 0xc0, 0x30...) to row 0 and bytes 1,3,5,7,9... (0x0C, 0x03, 0x01, 0x01,...) to row 1.

I have only worked with LCDs on a direct hardware level. In case it's useful to you or someone else familiar with this platform, I can explain how to write byte B to row R, column C using the LCD display you seem to be using (NT75451):

First give the command SET PAGE (R), which in c language is (0xB0 | R). Then SET HIGH COLUMN ADDRESS, command (0x10 | (C >> 4)) and SET LOW COLUMN ADDRESS (0x00 | (C & 0xf)). Finally send the data byte (B).

Commands are sent with the LCD display's pin A0 pulled low and data is sent with A0 pulled high, but I suspect you already know this.

Hope this is helpful to you or someone else.


[EDIT]: Based on the draw function added to the question, you might try something like this to draw the big character:

void LCD_Draw_Char(uint8_t Line, uint8_t Column, unsigned char Char) // Bypass shadow display characters matrix to directly draw one character.
{
  Task_S_T Task;
  uint8_t Index;

  LCD_Write_Command_SetPage(Line);          // Set the virtual line index.
  LCD_Write_Command_SetColumn(Column);      // Set the column index.
  Task.Command = TASK_WRITING;
  Task.Iter    = 0;
  for( Index = 0; Index < 13; Index++ )
  {
    if( (Column + Index > DISPLAY_LAST_COLUMN)
     || (Line           > DISPLAY_LAST_LINE  ) )
    {
      return; /* Ran out of space :( */
    };
    Task.Data = Combination_Of(ACTION_WRITE_DATA_TO_RAM, Font_13x16[Char - BIG_FONT_FIRST_CHAR_CODE][Index*2]);
    LCD_FIFO_Push(Task);
  };
  Task.Data = Combination_Of(ACTION_WRITE_DATA_TO_RAM, 0x00); /* The separator column of each char is set here to prevent dirty pixels being left unerased. */
  LCD_FIFO_Push(Task);                                        /* The separator column of each char is set here to prevent dirty pixels being left unerased. */


  LCD_Write_Command_SetPage(Line+1);          // Set the virtual line index.
  LCD_Write_Command_SetColumn(Column);      // Set the column index.
  Task.Command = TASK_WRITING;
  Task.Iter    = 0;
  for( Index = 0; Index < 13; Index++ )
  {
    if( (Column + Index > DISPLAY_LAST_COLUMN)
     || (Line           > DISPLAY_LAST_LINE  ) )
    {
      return; /* Ran out of space :( */
    };
    Task.Data = Combination_Of(ACTION_WRITE_DATA_TO_RAM, Font_13x16[Char - BIG_FONT_FIRST_CHAR_CODE][Index*2+1]);
    LCD_FIFO_Push(Task);
  };
  Task.Data = Combination_Of(ACTION_WRITE_DATA_TO_RAM, 0x00); /* The separator column of each char is set here to prevent dirty pixels being left unerased. */
  LCD_FIFO_Push(Task);                                        /* The separator column of each char is set here to prevent dirty pixels being left unerased. */


  return;
}
PkP
  • 7,567
  • 2
  • 23
  • 42
  • Is it some how possible to directly pick the character from the predefined character array? just like i did in the draw function. And you are spot on about the LCD model. – spp Nov 01 '14 at 07:18
  • This worked ....but the only problem I am getting is that when i type a string the 2nd character is being printed on the 2nd row... – spp Nov 03 '14 at 06:00
  • Do you still have some Display.Row[Display_Row++] code left in the caller? The ++ would switch to the next row. – PkP Nov 03 '14 at 06:03
  • No i havent used that portion in my code... – spp Nov 03 '14 at 06:17
  • sorry..i made some edits in the main called which was causing the problem which is now resolved..thanks a lot – spp Nov 03 '14 at 06:23
2

You don't say which display you are working with and you don't show any font data in your question, so I can't say for sure, but usually these types of LCD's, if they are black-and-white, are written to one byte at the time. The byte will set the values of one vertical column of 1x8 pixels. For a 13 wide, 16 pixels high font, you'd need to first write the top slice of 13x8 pixels (13 bytes of pixel data), then switch to the second row and write the bottom slice of 13x8 pixels (another 13 bytes of pixel data).

If the LCD display is TFT, e.g. a "full color" display, then you will first need to establish a 13x16 sized rectangle to write and then fill it with pixels.

PkP
  • 7,567
  • 2
  • 23
  • 42
  • Thanks a lot...I am sorry that i forgot to mention about the display. Well you are right that it's a black and white type and it is indeed writing 1*8 pixel blocks. Thats where I am stuck like am not getting how to proceed. – spp Nov 01 '14 at 06:01
  • Also find the edited question. I have included hex code for "A" – spp Nov 01 '14 at 06:03
  • Ok, I've done something similar and usually it's easiest to do each vertical column of 1x16 bits with something like this: Display.Row[Display_Row++].Column [Display_Column] = top_8_bits; Display.Row[Display_Row--].Column [Display_Column] = bottom_8_bits; (note that I've worked with the LCD bus directly without any graphics libraries, this code is something like what I suspect you might be able to write in your case) – PkP Nov 01 '14 at 06:13
  • Why to ++ for the 1st time? I am confused – spp Nov 01 '14 at 06:21
  • The ++ and -- are to switch the row, first from top to bottom then from bottom to top. – PkP Nov 01 '14 at 06:29
  • Oops! I thought that the Display.Row[y].Column[x]=b would show the 8 pixels from byte b on a one 1x8 pixels vertical stripe. But looking at the code, it looks like it it's doing something more complex like draw the entire character. It's to that draw function where you need to make your edits. Sorry that I couldn't help you. – PkP Nov 01 '14 at 06:39
  • Please see the code for draw function which is being used at the start of the main loop. – spp Nov 01 '14 at 07:09