Page 1 of 1

Float to String, not working! SOLVED!

Posted: Fri Jan 01, 2021 8:12 pm
by jgu1
Hi all!

Happy New year!

I started a project with an Ili9341 display and a BME280 sensor.
There are no decimals after the comma in the display when reading the different value out, Float and then made Float to string, when I simulate, not tested in real world. It only shows the integers.

Am I doing something wrong or is there a bug. I have a similar project in FC8 and it works, also in in simulation, ok with a LCD display.
The attached is a clip from the program, to make it easier to see what is happening. When I am finish I will share the hole project :D

Hope someone can help :roll:

Br jorgen

Re: Float to String, not working!

Posted: Sat Jan 02, 2021 1:07 am
by medelec35
Hi Jorgen,
Thank you & happy new year to you as well.
Your issue is you have used the

Code: Select all

ToString$
function which is Integer to String.
As it is typecasting to an integer, no decimal points will be expected, so it's left out.
What you need to use instead is use

Code: Select all

 FloatToString$
If you want to round the string to 2 decimal places for example , you can use

Code: Select all

HumStr = FloatToString$ (Hum, 2)

Re: Float to String, not working!

Posted: Sat Jan 02, 2021 7:26 am
by jgu1
Hi MArtin!

Of course Martin, how can I have overlooked it. Also what I have used the Float to String in previus project in FC8 :lol: Now it works as it should.

And, ok this is new to me: (Hum, 2) I always edit this When I create new String vaiable, but this is easyer. Learn some new today. ;)

Glad we have supporters like you. Many thanks for the help. :D :D

Br Jorgen.

Re: Float to String, not working! SOLVED!

Posted: Sun Jan 03, 2021 12:36 am
by medelec35
You're welcome & thank you for the update.
jgu1 wrote:
Sat Jan 02, 2021 7:26 am
ok this is new to me: (Hum, 2) I always edit this When I create new String vaiable, but this is easyer. Learn some new today.
I'm glad I have shown you something new, Shame it's not in the Wiki.
I will request it to be added.