Directly show the time after finding the WiFi

This commit is contained in:
ollo 2016-06-19 18:14:28 +02:00
parent b1f702df75
commit 8321e5f112

View File

@ -41,6 +41,31 @@ function syncTimeFromInternet()
) )
end end
function displayTime()
sec, usec = rtctime.get()
time = getTime(sec, timezoneoffset)
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second)
words = display_timestat(time.hour, time.minute)
ledBuf = generateLEDs(words, color)
-- Write the buffer to the LEDs
ws2812.write(ledPin, ledBuf)
-- Used for debugging
if (clockdebug ~= nil) then
for key,value in pairs(words) do
if (value > 0) then
print(key,value)
end
end
end
-- cleanup
ledBuf=nil
words=nil
time=nil
collectgarbage()
end
function normalOperation() function normalOperation()
-- Color is defined as GREEN, RED, BLUE -- Color is defined as GREEN, RED, BLUE
color=string.char(0,0,250) color=string.char(0,0,250)
@ -76,30 +101,10 @@ function normalOperation()
startWebServer() startWebServer()
end) end)
displayTime()
-- Start the time Thread -- Start the time Thread
tmr.alarm(1, 20000, 1 ,function() tmr.alarm(1, 20000, 1 ,function()
sec, usec = rtctime.get() displayTime()
time = getTime(sec, timezoneoffset)
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second)
words = display_timestat(time.hour, time.minute)
ledBuf = generateLEDs(words, color)
-- Write the buffer to the LEDs
ws2812.write(ledPin, ledBuf)
-- Used for debugging
if (clockdebug ~= nil) then
for key,value in pairs(words) do
if (value > 0) then
print(key,value)
end
end
end
-- cleanup
ledBuf=nil
words=nil
time=nil
collectgarbage()
end) end)
end end