-->
Page 1 of 3

Lua and floating points

PostPosted: Mon Dec 08, 2014 1:58 pm
by JohnPap70
Hi all!

I was trying to make some sensor drivers in Lua in order to connect them with the ESP8266. It seems that the floating point values are not supported by the Lua running on the ESP. Is this correct?

Are we going to have this feature soon or it is totally unsupported by the hardware?

Re: Lua and floating points

PostPosted: Mon Dec 08, 2014 11:47 pm
by zeroday
float is not supported in chip esp8266.
firmware can support float, but costs ram.

Re: Lua and floating points

PostPosted: Sun Dec 14, 2014 6:43 am
by JohnPap70
Thank you for your answer! I am new to Lua and I was trying to write a few sensor drivers.

How I will define that a variable of mine is a float in the Lua running on the ESP chip?

Re: Lua and floating points

PostPosted: Tue Dec 16, 2014 8:24 am
by sancho
JohnPap70 wrote:Thank you for your answer! I am new to Lua and I was trying to write a few sensor drivers.

How I will define that a variable of mine is a float in the Lua running on the ESP chip?

I would suggest to take a look into the example for DS1820 - you can see the temperature calculation, which should be done by multiplication of resulting integer by 0.0625 to get degrees Celsius.
However, instead of this, the number is multiplied by 625, resulting in 4 decimal places.
Than, you can display the number as
Code: Select allprint(resultValue/10000 .. "." .. string.format("%04d", resultValue%10000))

Does it help?