Page 1 of 1

Strange behaviour with unixtime and dummy variables

Posted: 05 Sep 2021, 21:13
by Patou
Hello,
I am currently using following release : ESP_Easy_mega_20210503_normal_ESP8266_4M1M on a Wemos D1 mini
Loading unixtime in dummy devices at different times seems to give strange results !
Here is the test program :

Code: Select all

On start do
 TaskValueSet,8,1,%unixtime% // Store time
 oledframedcmd,1,"U: [M#L_Rg_T]" 
 TimerSet,1,10
endon

On Rules#Timer=1 do
 TaskValueSet,8,3,%unixtime% // Store time 10 sec after
 oledframedcmd,2,"U2: [M#Act_T]" 
 TimerSet,1,10
endon
The time is not updated or only sometimes and not with the correct value !
Storing the unixtime in a "var" works fine
How can I store a timestamp that can be kep after a reboot ?

Re: Strange behaviour with unixtime and dummy variables

Posted: 05 Sep 2021, 21:25
by TD-er
The task values are of type float, which effectively only has 22 bits for a value. The rest is for the exponent (and sign)

If you want to store a unixtime, store it in a variable.

Re: Strange behaviour with unixtime and dummy variables

Posted: 05 Sep 2021, 23:19
by Patou
OK thanks
I put in the dummy variables the unixtime - (unixtime on 2021/01/01 00:00:00)
This can be saved on a float of 22 bit correctly and I can find back the last date and time before a warm reboot starting at begin of this year.
Patou

Re: Strange behaviour with unixtime and dummy variables

Posted: 05 Sep 2021, 23:42
by TD-er
Nope.
86400 * 365 = 31.5 million, which is roughly 25 bits (10 bits = 1024, 20 bits is 1024x1024 ~ 1M)
So that will loose resolution when stored in a float.