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

How to display numerical string on lcd ?

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



Joined: 22 Dec 2013
Posts: 6

View user's profile Send private message

How to display numerical string on lcd ?
PostPosted: Wed Mar 19, 2014 3:51 am     Reply with quote

Can anyone explain how to convert the string into a numerical value for displaying in the LCD... Help me...
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Mar 19, 2014 7:09 am     Reply with quote

what makes you think strings can not be displayed as they are ??
jeremiah



Joined: 20 Jul 2010
Posts: 1328

View user's profile Send private message

PostPosted: Wed Mar 19, 2014 10:20 am     Reply with quote

yes, normally it is the other way around: convert a numeric value into a char string to print on the LCD

If that is the case, you just need to create a function that takes a single character and print's it to the LCD while making sure the cursor moves forward (if the LCD doesn't do this automatically). It would look like this:
Code:

void lcd_putc(char c){
   //do stuff here to place the character on the screen and manage the cursor
}



Then you can just:

Code:

unsigned int8 value = 23;

printf(lcd_putc,"%u",value);


Normally, a printf will send data to the UART, but when a function name is used as the first parameter, it calls that function in place of the UART one.
dan king



Joined: 22 Sep 2003
Posts: 119

View user's profile Send private message

PostPosted: Wed Mar 19, 2014 11:42 am     Reply with quote

Jeremiah,

is that typical of C or is that a CCS feature? Sorry to hi-jack the thread but it's a neat concept
jeremiah



Joined: 20 Jul 2010
Posts: 1328

View user's profile Send private message

PostPosted: Wed Mar 19, 2014 1:01 pm     Reply with quote

It's not typical C. C uses the concept of standard in, standard out, and standard error. You redirect those to get printf to go other places in normal C.

CCS doesn't use standard in/out/error (doesn't really make sense in an embedded environment), so they check your printf call at compile time to see if the first parameter is a function, and if so modify the behavior in the code.

I actually like the way CCS approaches it more, but that is just personal preference.
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