LCD float out problem

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

LCD float out problem

#1 Post by Berkl » 10 Feb 2010 11:57

Hello guys!

Problem with LCD indication:

If I need out to LCD float = 0.001 by the follow function:

void Write_LCD(unsigned char row, unsigned char col,float tmp_var)
{

char tmp_string[14];

FloatToStr(tmp_var,tmp_string);
Lcd8_Custom_Out(row,col,tmp_string);
}
then I will see on LCD: "1e-3"

But I need to see "0.001" !!
How I can do that, please?

Thank you for your answer
Have a nice day!
___________________________________________
http://www.techno-spectr.ru/en/main-en/

Yaroslavl, Russia

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: LCD float out problem

#2 Post by tihomir.losic » 10 Feb 2010 14:55

Hello,

if you are using

Code: Select all

FloatToStr(tmp_var,tmp_string);
Converts a floating point number to a string. The output string is left justified and null terminated after the last digit.
example:

Code: Select all

float ff3 = 0.000001234;
.
.
.
FloatToStr(ff3, txt);  // txt is "1.234e-6"
It's not recommended to use this function if you want the output like "0.001".
Suggestion is that you use library sprintf!
The function returns the number of characters actually written to destination string.
For more informations, look for sprintf in our help file.

If you have any additional questions, feel free to contact me.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

Re: LCD float out problem

#3 Post by Berkl » 10 Feb 2010 17:29

Thank you my friend!

I will trying

Best regards!
___________________________________________
http://www.techno-spectr.ru/en/main-en/

Yaroslavl, Russia

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”