- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have converted a float variable using ftoa and am writting to the LCD with " LCD_1_PrString(presult) "
I would like to limit the numer of places past the decimal point to two. Is ther an argument that I can add, I looked around but do not see how to do this.
Thanks,
Alan
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ftoa() has no formatting capabilities, but you may use sprintf() for this. Have a look at this thread www.cypress.com/
Parameter explanation here : publications.gbdirect.co.uk/c_book/chapter9/formatted_io.html
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ftoa() converts to an ascii string, so is the limitation in Prstring (ascii) has no modifiers?
I will look at the link you provided but am still wondering if there is any way to truncate PrString out put to LCD.
Thanks,
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may shorten the string yourself by placing an x00 at the appropiate place, but LCD_PrString() has no modifiers as the documentation of the API shows.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sprintf() has a big impact on program space, should you decide to use
it attached formatting string information.
If you use Bob's suggestion search the string for the decimal point, then
search from there to where the NULL character is. If it is > 3 counts beyond
the DP point, place a NULL in the 3'rd position as Bob suggested. If it is
<= 3 counts do nothing to the string and print. A double nested for() loop
should do the job or something equivalent.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, For this project I decided to just use unsigned int Variables so I ended up using ITOA to print to LCD
Alan