Nouveau set_time, qui sauvegarde toutes les minutes l'heure dans la FLASH
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
zf200814.1936
|
||||
zf200815.1404
|
||||
|
||||
print(ztime())
|
||||
print("rtctime: "..rtctime.get())
|
||||
|
||||
dsleep_on()
|
||||
|
||||
f = "0_wifi_scan.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
function boot()
|
||||
print("\n boot.lua zf200722.1944 \n")
|
||||
print("\n boot.lua zf200815.1358 \n")
|
||||
print("On lance le boot...")
|
||||
collectgarbage() print(node.heap())
|
||||
local f
|
||||
@@ -13,7 +13,7 @@ function boot()
|
||||
-- zarg_boot=zarg_boot.."energy,value=boot_reason_"..yellow_id.." val="..boot_reason
|
||||
-- http_post(influxdb_url,zarg_boot)
|
||||
|
||||
f = "set_time.lua" if file.exists(f) then dofile(f) end
|
||||
f = "set_time2.lua" if file.exists(f) then dofile(f) end
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
|
||||
f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
-- Scripts pour régler l'horloge quand on est connecté en WIFI
|
||||
-- et la sauve dans un fichier pour si jamais on n'a pas d'Internet
|
||||
-- au power boot
|
||||
-- https://www.unixtimestamp.com/index.php
|
||||
|
||||
print("\n set_time2.lua zf200815.1255 \n")
|
||||
print("\n set_time2.lua zf200815.1426 \n")
|
||||
|
||||
function set_time()
|
||||
sntp.sync(nil, nil, nil, 1)
|
||||
end
|
||||
|
||||
function ztime()
|
||||
tm = rtctime.epoch2cal(rtctime.get()+2*3600)
|
||||
print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
|
||||
-- function ztime()
|
||||
-- tm = rtctime.epoch2cal(rtctime.get()+2*3600)
|
||||
-- print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
|
||||
-- end
|
||||
|
||||
function zget_time()
|
||||
zrtc_time = rtctime.get()
|
||||
if zrtc_time > 0 then
|
||||
ztmr_set_time:alarm(60*1000, tmr.ALARM_SINGLE , zget_time)
|
||||
print("j'ai trouvé l'heure: "..zrtc_time)
|
||||
file.putcontents("_ztime_", zrtc_time)
|
||||
-- print(file.getcontents("_ztime_"))
|
||||
else
|
||||
ztmr_set_time:alarm(1*1000, tmr.ALARM_SINGLE , zget_time)
|
||||
print("je cherche l'heure: "..zrtc_time)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ztmr_set_time = tmr.create()
|
||||
ztmr_set_time:alarm(1*1000, tmr.ALARM_SINGLE , zget_time)
|
||||
|
||||
set_time()
|
||||
|
||||
--[[
|
||||
print(ztime())
|
||||
]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user