Float to String, not working! SOLVED!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 615
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 509 times
Been thanked: 132 times

Float to String, not working! SOLVED!

Post 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
Attachments
BME280Ili9341No Float.fcfx
(26.03 KiB) Downloaded 199 times
Last edited by jgu1 on Sat Jan 02, 2021 7:34 am, edited 1 time in total.

medelec35
Matrix Staff
Posts: 1465
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 515 times
Been thanked: 474 times

Re: Float to String, not working!

Post 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)
Martin

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 509 times
Been thanked: 132 times

Re: Float to String, not working!

Post 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.

medelec35
Matrix Staff
Posts: 1465
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 515 times
Been thanked: 474 times

Re: Float to String, not working! SOLVED!

Post 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.
Martin

Post Reply