Two questions concerning display variables on LCD

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Two questions concerning display variables on LCD

#1 Post by mackowiakp » 26 Sep 2020, 13:42

First. Lets assume that value of variable no.1 is equal 1234.56. If I use such command to display it on 4x20 LCD:

Code: Select all

LCD,1,1,[INT#1]
does value variable no.1 will be display as "rounded to the nearest" (in this case display as 1235) or simply decimals positions will be cut?

Second. Each variable has two decimal position. Is there any possibility to display on 4x20 LCD variable with only one decimal position? Its because the amount of places on LCD display is limited.

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Two questions concerning display variables on LCD

#2 Post by TD-er » 26 Sep 2020, 14:07

I would expect it will be rounded down, since it is a float casted to an int.
I doubt there is a 0.5 added to it before casting.

If you need formatting, please look at the documentation: https://espeasy.readthedocs.io/en/lates ... red-values
And you can also refer to the float value, via "var" instead of "int"

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Two questions concerning display variables on LCD

#3 Post by mackowiakp » 26 Sep 2020, 14:30

In the meantime, I ran several tests by manually inserting values into the variable. It seems that when changing from VAR to INT, rounding is used.
For example, now the value of the variable (specifically pressure) is 1001.78. This is the value of the variable read from the ESP menu (Tools-> System variables).
And the LCD displays 1002.

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Two questions concerning display variables on LCD

#4 Post by TD-er » 26 Sep 2020, 18:48

OK, so I did add a round function there... Good to know :)
That's something I would easily forget to do, so I was doubting if it was using a round function when you asked...

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Two questions concerning display variables on LCD

#5 Post by mackowiakp » 26 Sep 2020, 19:00

Well. The man forgives and forgets. The woman will forgive. But forget - never forget. :lol:

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Two questions concerning display variables on LCD

#6 Post by mackowiakp » 27 Sep 2020, 06:14

OK. Formatting number on LCD works as docu stands. Good work, unknown form me until now...

Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests