CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Custom LCD Characters

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wmeade



Joined: 08 Sep 2003
Posts: 16

View user's profile Send private message

Custom LCD Characters
PostPosted: Fri Sep 12, 2003 8:38 am     Reply with quote

I would like to create a custom LCD character to display on my 4x20 LCD. This was rather easy in PBP, but appears to be more complicated in PICC. I searched the forum and found one message that pertained to my question but it was using functions that are not in the LCD.C, which is what I am using. Should I be using a different driver or will the LCD.C work for loading a custom character into the CG_RAM on the Display? Thanks in advance........
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 12, 2003 9:33 am     Reply with quote

Read the datasheet for the LCD controller that you are using. It is pretty simple to implement you just have to know what to do.

Here is one I wrote a while back. I think you should be able to the the 'lcd_send_byte' from LCD.C with this.

Code:

#define LCD_COMMAND             0                       
#define LCD_DISPLAY             1
#define LCD_CG_RAM              0x40

/****************************************************************************
* NAME:        Store_Custom_Char
* DESCRIPTION: Stores the custom characters in the CGRAM of the LCD Display
* PARAMETERS:  none
* GLOBALS:     none
* RETURN:      none
* ALGORITHM:   none
* NOTES:       none
*****************************************************************************/
void Store_Custom_Char(void)
{
  LCD_Write(LCD_COMMAND, LCD_CG_RAM);

  /******************************* 'É' **************************************/
  LCD_Write(LCD_DISPLAY,0x02);   /*       X  */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */ 
  LCD_Write(LCD_DISPLAY,0x10);   /*    X     */
  LCD_Write(LCD_DISPLAY,0x1E);   /*    XXXX  */
  LCD_Write(LCD_DISPLAY,0x10);   /*    X     */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /******************************* 'Ç' **************************************/
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x10);   /*    X     */
  LCD_Write(LCD_DISPLAY,0x10);   /*    X     */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x0C);   /*     XX   */

  /******************************* 'À' **************************************/
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x0A);   /*     X X  */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /******************************* 'Ô' **************************************/
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x0A);   /*     X X  */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /******************************* 'é' **************************************/
  LCD_Write(LCD_DISPLAY,0x02);   /*       X  */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x11);   /*    X   X */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x10);   /*    X     */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /*************************** Down arrow ***********************************/
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x15);   /*    X X X */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /*************************** Up arrow *************************************/
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x15);   /*    X X X */
  LCD_Write(LCD_DISPLAY,0x0E);   /*     XXX  */
  LCD_Write(LCD_DISPLAY,0x04);   /*      X   */
  LCD_Write(LCD_DISPLAY,0x00);   /*          */

  /*************************** Not Used *************************************/
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */
  LCD_Write(LCD_DISPLAY,0x1F);   /*    XXXXX */

}


Last edited by Mark on Sun May 22, 2005 8:59 pm; edited 1 time in total
wmeade



Joined: 08 Sep 2003
Posts: 16

View user's profile Send private message

PostPosted: Fri Sep 12, 2003 12:44 pm     Reply with quote

Thanks for the quick response mark. I was able to load and display my custome cursor.
Below is how I loaded it and then displayed it for anyone that may be doing the same thing using LCD.C.

// Load Custome Cursor Into LCD CG RAM

lcd_send_byte(0,0x40); // (0 = command mode) write to LCD CG Ram location 0
lcd_send_byte(1,0x08); // (1 = display mode) load cursor line 1 of 8
lcd_send_byte(1,0x0C); // (1 = display mode) load cursor line 2 of 8
lcd_send_byte(1,0x0E); // (1 = display mode) load cursor line 3 of 8
lcd_send_byte(1,0x0F); // (1 = display mode) load cursor line 4 of 8
lcd_send_byte(1,0x0E); // (1 = display mode) load cursor line 5 of 8
lcd_send_byte(1,0x0C); // (1 = display mode) load cursor line 6 of 8
lcd_send_byte(1,0x08); // (1 = display mode) load cursor line 7 of 8
lcd_send_byte(1,0x00); // (1 = display mode) load cursor line 8 of 8


// Display Custome Cursor on LCD from LCD CG RAM Location 0

lcd_send_byte(1,0); // (1 = display mode) (0 = CG RAM location)
Bryan



Joined: 23 Apr 2005
Posts: 73

View user's profile Send private message Send e-mail AIM Address

PostPosted: Fri May 20, 2005 11:11 am     Reply with quote

Where did you put this code in your main program to get it to load and display your custom cursor? I tried doing this right after lcd_init() in main but it doesn't display anything - Does this need to be inside the lcd_init() function?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri May 20, 2005 11:55 am     Reply with quote

These only store the data in the LCD. Take a look at the datasheet. You access the custom characters with a code (0-7 in this case).

Code:

  printf(lcd_putc,"This is custom char 2 \1");
  printf(lcd_putc,"This is the fourth custom char \4");


The first custom address is stored at 0 so that one is a bit tricky since \0 also signals the end of a string.
Bryan



Joined: 23 Apr 2005
Posts: 73

View user's profile Send private message Send e-mail AIM Address

PostPosted: Fri May 20, 2005 12:15 pm     Reply with quote

Thanks for the help Mark! When I tried this out, I needed to clear the display after calling the Store_Custom_Char() function before I was able to get anything to output. Do you know why this is? Also, you were right \0 doesn't work correctly so I may just store the 2 custom characters that I need for my project in positions 1 and 2 since they work fine.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri May 20, 2005 2:50 pm     Reply with quote

You can make the 0 char work but probably not in a printf().
CharlieGill



Joined: 29 Nov 2004
Posts: 15
Location: northeast georgia

View user's profile Send private message Visit poster's website

PostPosted: Sun May 22, 2005 7:16 pm     Reply with quote

If you encode your custom characters using binary constants it makes it easier to visualize what the character looks like.
0b0000100
0b0001110
0b0010101
0b0000100
0b0000100
0b0000100
0b0000000

Charlie
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun May 22, 2005 9:00 pm     Reply with quote

I added the code formating to my orginal post. I think they stand out pretty well Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group