The code is compiled
This commit is contained in:
parent
58eed3bef5
commit
6874d1545b
@ -1,8 +1,8 @@
|
|||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
function generateLEDs(words, color)
|
function generateLEDs(words, color)
|
||||||
|
|
||||||
white=string.char(0,0,0)
|
local white=string.char(0,0,0)
|
||||||
buf=color
|
local buf=color
|
||||||
-- line 1----------------------------------------------
|
-- line 1----------------------------------------------
|
||||||
if (words.itis == 1) then
|
if (words.itis == 1) then
|
||||||
buf=color:rep(2) -- ES
|
buf=color:rep(2) -- ES
|
||||||
|
63
main.lua
63
main.lua
@ -1,28 +1,52 @@
|
|||||||
-- Main Module
|
-- Main Module
|
||||||
function startSetupMode()
|
function startSetupMode()
|
||||||
tmr.stop(0)
|
tmr.stop(0)
|
||||||
dofile("webserver.lua")
|
tmr.stop(1)
|
||||||
|
-- start the webserver module
|
||||||
|
mod="webserver"
|
||||||
|
if (file.open(mod .. ".lua")) then
|
||||||
|
dofile( mod .. ".lua")
|
||||||
|
else
|
||||||
|
dofile(mod .. ".lc")
|
||||||
|
end
|
||||||
|
|
||||||
wifi.setmode(wifi.SOFTAP)
|
wifi.setmode(wifi.SOFTAP)
|
||||||
wifi.ap.config({ssid='clock',pwd='clock'})
|
cfg={}
|
||||||
print("Waiting in access point >clock< for Clients")
|
cfg.ssid="wordclock"
|
||||||
|
cfg.pwd="wordclock"
|
||||||
|
wifi.ap.config(cfg)
|
||||||
|
print("Waiting in access point >wordclock< for Clients")
|
||||||
print("Please visit 192.168.4.1")
|
print("Please visit 192.168.4.1")
|
||||||
startWebServer()
|
startWebServer()
|
||||||
end
|
end
|
||||||
|
|
||||||
wifi.setmode(wifi.STATION)
|
print("Solving dependencies")
|
||||||
if ( file.list()["config.lua"] ) then
|
dependModules = { "timecore" , "wordclock", "displayword" }
|
||||||
dofile("config.lua")
|
for _,mod in pairs(dependModules) do
|
||||||
else
|
print("Loading " .. mod)
|
||||||
startSetupMode()
|
if (file.open(mod .. ".lua")) then
|
||||||
|
dofile( mod .. ".lua")
|
||||||
|
else
|
||||||
|
dofile(mod .. ".lc")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
dofile("timecore.lua")
|
|
||||||
dofile("wordclock.lua")
|
|
||||||
dofile("displayword.lua")
|
|
||||||
|
|
||||||
ledPin=4
|
ledPin=4
|
||||||
-- 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)
|
||||||
|
|
||||||
|
function syncTimeFromInternet()
|
||||||
|
--ptbtime1.ptb.de
|
||||||
|
sntp.sync(sntpserverhostname,
|
||||||
|
function(sec,usec,server)
|
||||||
|
print('sync', sec, usec, server)
|
||||||
|
end,
|
||||||
|
function()
|
||||||
|
print('failed!')
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
connect_counter=0
|
connect_counter=0
|
||||||
-- Wait to be connect to the WiFi access point.
|
-- Wait to be connect to the WiFi access point.
|
||||||
tmr.alarm(0, 500, 1, function()
|
tmr.alarm(0, 500, 1, function()
|
||||||
@ -44,15 +68,7 @@ tmr.alarm(0, 500, 1, function()
|
|||||||
startWebServer()
|
startWebServer()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--ptbtime1.ptb.de
|
|
||||||
sntp.sync(sntpserverhostname,
|
|
||||||
function(sec,usec,server)
|
|
||||||
print('sync', sec, usec, server)
|
|
||||||
end,
|
|
||||||
function()
|
|
||||||
print('failed!')
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
-- when no wifi available, open an accesspoint and ask the user
|
-- when no wifi available, open an accesspoint and ask the user
|
||||||
if (connect_counter == 300) then -- 300 is 30 sec in 100ms cycle
|
if (connect_counter == 300) then -- 300 is 30 sec in 100ms cycle
|
||||||
@ -87,3 +103,10 @@ tmr.alarm(1, 15000, 1 ,function()
|
|||||||
collectgarbage()
|
collectgarbage()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Logic
|
||||||
|
if ( file.open("config.lua") ) then
|
||||||
|
wifi.setmode(wifi.STATION)
|
||||||
|
dofile("config.lua")
|
||||||
|
else
|
||||||
|
startSetupMode()
|
||||||
|
end
|
@ -23,7 +23,7 @@ function display_timestat(hours, minutes, longmode)
|
|||||||
|
|
||||||
-- transcode minutes
|
-- transcode minutes
|
||||||
local minutesLeds = minutes%5
|
local minutesLeds = minutes%5
|
||||||
minutes=math.floor(minutes/5)
|
local minutes=math.floor(minutes/5)
|
||||||
|
|
||||||
-- "It is" only display each half hour and each hour
|
-- "It is" only display each half hour and each hour
|
||||||
-- or if longmode is set
|
-- or if longmode is set
|
||||||
|
Loading…
Reference in New Issue
Block a user