|
|
View previous topic :: View next topic |
Author |
Message |
aderogba
Joined: 03 Jun 2005 Posts: 8
|
Custom Character on LCD |
Posted: Tue Jul 05, 2005 1:23 pm |
|
|
Please I need some help with this code developed using input from this forum. I can't get any custom character to print. I'm using 18F452 with hantronix LCD.
Code: | void lcd_print_str(char* lcd_str)
{
char str[16];
int8 i;
sprintf(str,"%c",'\0');
if(strlen(lcd_str)>STRING_LENGTH)
{
strcpy(str,"str 2 long");
}
else
{
strcpy(str,lcd_str);
}
for(i=0; i<strlen(str); i++)
lcd_putc(str[i]);
}
void lcd_print_custom(char* custom)
{
int8 i;
lcd_send_byte(0,0x40); // 0 = command mode, 0x40 = write to CGRam location 0
for(i=0;i<sizeof(custom);i++) // 1 = display mode, load cursor line 1 to 8
{
delay_us(200);
lcd_send_byte(1,custom[i]);
}
lcd_send_byte(1,0x300);
}
void main()
{
BYTE lcd_custom[8] = {0x1f,0x11,0x0a,4,0x0a,0x11,0x1f,0};
char str[16];
lcd_init();
lcd_print_custom(lcd_custom, 0, 0);
while(TRUE);
} |
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jul 05, 2005 2:23 pm |
|
|
lcd_print_custom, as you have it written, expects one variable. You are sending it three.
You don't show your 'lcd_send_byte' command, but assuming it is designed to handle 'bytes', you send it a 0x300 value, which is too large for it to cope with.
Remember 'String Length' will have to be 15, if your test for the string being too long is going to work.
These are the obvious ones I can see in the bit of code posted. There are probably more.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Jul 06, 2005 10:56 am |
|
|
The initial version of the code uses lcd_send_byte(1,0). I later changed it in the process of troubleshooting. I use the code for other testing, I didn't completely strip the posted code of these extras. My major problem is with the command to pass to lcd_send_byte to print custom character |
|
|
Ttelmah Guest
|
|
Posted: Wed Jul 06, 2005 3:05 pm |
|
|
Since you don't show the lcd_send_byte function, you are not going to get many answers...
The eight custom characters appear as the characters 0x00 to 0x07, in the character set of the LCD. Assming LCD_send_byte, does not intercept the values, start by sending it a '0'.
Best Wishes |
|
|
aderogba
Joined: 03 Jun 2005 Posts: 8
|
|
Posted: Thu Jul 07, 2005 10:07 am |
|
|
Thanks for your response. The lcd_send_byte function I'm using is exactly the same one that comes from CCS in the lcd.c file. I've seen it in use by others in this forum so I think it will be sufficient for my use without any modification. |
|
|
|
|
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
|