View previous topic :: View next topic |
Author |
Message |
kel
Joined: 17 Oct 2005 Posts: 68 Location: Brisbane
|
pic16f84a and lcd driver modification |
Posted: Mon Jan 23, 2006 12:31 am |
|
|
Guys i'm trying to write a function that will be able to print more than one digit on the lcd screen coz the printf(LCD_PUTC," ") function does not print 0 before a digit i.e if you want lcd to print Time(01:00:45). It only prints (1:0:45) with the printf(" ") function. Here is the function but it does not work.
Code: | Code:
void print_int(int num, int len)
{
if(len>=5) lcd_writebcd(num/10000);
if(len>=4) lcd_writebcd((num/1000)%10);
if(len>=3) lcd_writebcd((num/100)%10);
if(len>=2) lcd_writebcd((num/10)%10);
if(len>=1) lcd_writebcd((num/1)%10);
}
void lcd_writebcd(char n)
{
if((n>='0') && (n<='9')) //only decimal numbers are allowed
lcd_putc(n+'0'); //print character one at a time
} |
//I CALL THE FUNCTION AS FOLLOW IN THE MAIN PROGRAM
Code: | while()
{
print_int(hour, 2); //suppose to print 2 digits i.e. xx
} |
can anyone help out here...
cheers |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 23, 2006 12:44 am |
|
|
Quote: | the printf(LCD_PUTC," ") function does not print 0 before a digit
i.e if you want lcd to print Time(01:00:45). It only prints (1:0:45)
with the printf(" ") function |
printf() can do this. Look at the CCS example file EX_RTC, which
shows exactly how to do it. That file is in this folder:
c:\Program Files\PICC\Examples
Also, please don't double-post. Please go to your other post and
delete it. http://www.ccsinfo.com/forum/viewtopic.php?t=25761
As long as no one has replied to it, you can delete it. Just click on the
little "X" in the upper right corner, which is visible when you view the post. |
|
|
kel
Joined: 17 Oct 2005 Posts: 68 Location: Brisbane
|
Appreciation To Programmer... |
Posted: Mon Jan 23, 2006 1:17 am |
|
|
Programmer, man you did not nick-name yourself programmer for nothing.
You are indeed programmer.
Thanks alot mate.I had a rough time trying to re-invent a wheeel...
cheers.
God bless |
|
|
|