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 support@ccsinfo.com

pic16f84a and lcd driver modification

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



Joined: 17 Oct 2005
Posts: 68
Location: Brisbane

View user's profile Send private message

pic16f84a and lcd driver modification
PostPosted: Mon Jan 23, 2006 12:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 23, 2006 12:44 am     Reply with quote

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

View user's profile Send private message

Appreciation To Programmer...
PostPosted: Mon Jan 23, 2006 1:17 am     Reply with quote

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
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