View previous topic :: View next topic |
Author |
Message |
madhunica
Joined: 22 Dec 2013 Posts: 6
|
How to display numerical string on lcd ? |
Posted: Wed Mar 19, 2014 3:51 am |
|
|
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
|
|
Posted: Wed Mar 19, 2014 7:09 am |
|
|
what makes you think strings can not be displayed as they are ?? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Wed Mar 19, 2014 10:20 am |
|
|
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
|
|
Posted: Wed Mar 19, 2014 11:42 am |
|
|
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: 1346
|
|
Posted: Wed Mar 19, 2014 1:01 pm |
|
|
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. |
|
|
|