Strange behaviour with unixtime and dummy variables

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Patou
Normal user
Posts: 106
Joined: 21 May 2018, 10:33

Strange behaviour with unixtime and dummy variables

#1 Post by Patou » 05 Sep 2021, 21:13

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 ?

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

Re: Strange behaviour with unixtime and dummy variables

#2 Post by TD-er » 05 Sep 2021, 21:25

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.

Patou
Normal user
Posts: 106
Joined: 21 May 2018, 10:33

Re: Strange behaviour with unixtime and dummy variables

#3 Post by Patou » 05 Sep 2021, 23:19

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

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

Re: Strange behaviour with unixtime and dummy variables

#4 Post by TD-er » 05 Sep 2021, 23:42

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests