2016-05-04 23:23:49 +02:00
|
|
|
dofile("wlancfg.lua")
|
2016-05-16 13:54:42 +02:00
|
|
|
dofile("timecore.lua")
|
2016-05-18 22:50:56 +02:00
|
|
|
dofile("wordclock.lua")
|
2016-06-15 21:24:40 +02:00
|
|
|
dofile("displayword.lua")
|
2016-05-16 13:54:42 +02:00
|
|
|
|
|
|
|
timezoneoffset=1
|
2016-05-04 23:23:49 +02:00
|
|
|
|
|
|
|
-- Wait to be connect to the WiFi access point.
|
|
|
|
tmr.alarm(0, 100, 1, function()
|
|
|
|
if wifi.sta.status() ~= 5 then
|
|
|
|
print("Connecting to AP...")
|
|
|
|
else
|
|
|
|
tmr.stop(0)
|
|
|
|
print('IP: ',wifi.sta.getip())
|
|
|
|
|
|
|
|
--ptbtime1.ptb.de
|
2016-05-16 13:54:42 +02:00
|
|
|
sntp.sync('ptbtime1.ptb.de',
|
2016-05-04 23:23:49 +02:00
|
|
|
function(sec,usec,server)
|
|
|
|
print('sync', sec, usec, server)
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
print('failed!')
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2016-06-07 23:30:13 +02:00
|
|
|
tmr.alarm(1, 5000, 1 ,function()
|
2016-05-04 23:23:49 +02:00
|
|
|
sec, usec = rtctime.get()
|
2016-05-16 13:54:42 +02:00
|
|
|
time = getTime(sec, timezoneoffset)
|
2016-05-04 23:23:49 +02:00
|
|
|
print("Time : " , sec)
|
2016-05-16 13:54:42 +02:00
|
|
|
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second)
|
2016-05-18 22:50:56 +02:00
|
|
|
|
|
|
|
words = display_timestat(time.hour, time.minute)
|
2016-05-22 15:31:43 +02:00
|
|
|
ledBuf = generateLEDs(words)
|
|
|
|
-- Write the buffer to the LEDs
|
|
|
|
ws2812.write(4, ledBuf)
|
2016-05-18 23:06:19 +02:00
|
|
|
|
2016-05-18 22:50:56 +02:00
|
|
|
for key,value in pairs(words) do
|
|
|
|
if (value > 0) then
|
|
|
|
print(key,value)
|
|
|
|
end
|
|
|
|
end
|
2016-05-04 23:23:49 +02:00
|
|
|
end)
|
|
|
|
|