Further optimisation in webserver
This commit is contained in:
parent
da139e3412
commit
a3aa7018d1
9
init.lua
9
init.lua
@ -6,7 +6,7 @@ MAXLEDS=110
|
|||||||
counter1=0
|
counter1=0
|
||||||
ws2812.write(string.char(0,0,0):rep(114))
|
ws2812.write(string.char(0,0,0):rep(114))
|
||||||
local bootledtimer = tmr.create()
|
local bootledtimer = tmr.create()
|
||||||
bootledtimer:register(5000, tmr.ALARM_AUTO, function (t)
|
bootledtimer:register(500, tmr.ALARM_AUTO, function (t)
|
||||||
counter1=counter1+1
|
counter1=counter1+1
|
||||||
spaceLeds = math.max(MAXLEDS - (counter1*2), 0)
|
spaceLeds = math.max(MAXLEDS - (counter1*2), 0)
|
||||||
ws2812.write(string.char(128,0,0):rep(counter1) .. string.char(0,0,0):rep(spaceLeds) .. string.char(0,0,64):rep(counter1))
|
ws2812.write(string.char(128,0,0):rep(counter1) .. string.char(0,0,0):rep(spaceLeds) .. string.char(0,0,64):rep(counter1))
|
||||||
@ -50,6 +50,8 @@ end
|
|||||||
initTimer = tmr.create()
|
initTimer = tmr.create()
|
||||||
initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
||||||
bootledtimer:unregister()
|
bootledtimer:unregister()
|
||||||
|
t:unregister()
|
||||||
|
collectgarbage()
|
||||||
if (
|
if (
|
||||||
(file.open("main.lua")) or
|
(file.open("main.lua")) or
|
||||||
(file.open("timecore.lua")) or
|
(file.open("timecore.lua")) or
|
||||||
@ -66,7 +68,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
|||||||
print("Rebooting ...")
|
print("Rebooting ...")
|
||||||
-- reboot repairs everything
|
-- reboot repairs everything
|
||||||
node.restart()
|
node.restart()
|
||||||
elseif (file.open("main.lc")) then
|
else
|
||||||
if ( file.open("config.lua") ) then
|
if ( file.open("config.lua") ) then
|
||||||
--- Normal operation
|
--- Normal operation
|
||||||
print("Starting main")
|
print("Starting main")
|
||||||
@ -79,9 +81,6 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
|||||||
-- Logic for inital setup
|
-- Logic for inital setup
|
||||||
startSetupMode()
|
startSetupMode()
|
||||||
end
|
end
|
||||||
else
|
|
||||||
print("No Main file found")
|
|
||||||
end
|
end
|
||||||
t:unregister()
|
|
||||||
end)
|
end)
|
||||||
initTimer:start()
|
initTimer:start()
|
||||||
|
@ -74,35 +74,16 @@ end
|
|||||||
function fillDynamicMap()
|
function fillDynamicMap()
|
||||||
replaceMap = {}
|
replaceMap = {}
|
||||||
ssid, _ = wifi.sta.getconfig()
|
ssid, _ = wifi.sta.getconfig()
|
||||||
|
if (ssid == nil) then return replaceMap end
|
||||||
if (ssid == nil) then
|
if (sntpserverhostname == nil) then sntpserverhostname="ptbtime1.ptb.de" end
|
||||||
ssid="Not set"
|
if (timezoneoffset == nil) then timezoneoffset=1 end
|
||||||
end
|
|
||||||
if (sntpserverhostname == nil) then
|
|
||||||
sntpserverhostname="ptbtime1.ptb.de"
|
|
||||||
end
|
|
||||||
if (timezoneoffset == nil) then
|
|
||||||
timezoneoffset=1
|
|
||||||
end
|
|
||||||
-- Set the default color, if nothing is set
|
-- Set the default color, if nothing is set
|
||||||
if (color == nil) then
|
if (color == nil) then color=string.char(0,0,250) end
|
||||||
color=string.char(0,0,250)
|
if (color1 == nil) then color1=color end
|
||||||
end
|
if (color2 == nil) then color2=color end
|
||||||
if (color1 == nil) then
|
if (color3 == nil) then color3=color end
|
||||||
color1=color
|
if (color4 == nil) then color4=color end
|
||||||
end
|
if (colorBg == nil) then colorBg=string.char(0,0,0) end
|
||||||
if (color2 == nil) then
|
|
||||||
color2=color
|
|
||||||
end
|
|
||||||
if (color3 == nil) then
|
|
||||||
color3=color
|
|
||||||
end
|
|
||||||
if (color4 == nil) then
|
|
||||||
color4=color
|
|
||||||
end
|
|
||||||
if (colorBg == nil) then
|
|
||||||
colorBg=string.char(0,0,0) -- black is the default background color
|
|
||||||
end
|
|
||||||
local hexColor = "#" .. string.format("%02x",string.byte(color,2)) .. string.format("%02x",string.byte(color,1)) .. string.format("%02x",string.byte(color,3))
|
local hexColor = "#" .. string.format("%02x",string.byte(color,2)) .. string.format("%02x",string.byte(color,1)) .. string.format("%02x",string.byte(color,3))
|
||||||
local hexColor1 = "#" .. string.format("%02x",string.byte(color1,2)) .. string.format("%02x",string.byte(color1,1)) .. string.format("%02x",string.byte(color1,3))
|
local hexColor1 = "#" .. string.format("%02x",string.byte(color1,2)) .. string.format("%02x",string.byte(color1,1)) .. string.format("%02x",string.byte(color1,3))
|
||||||
local hexColor2 = "#" .. string.format("%02x",string.byte(color2,2)) .. string.format("%02x",string.byte(color2,1)) .. string.format("%02x",string.byte(color2,3))
|
local hexColor2 = "#" .. string.format("%02x",string.byte(color2,2)) .. string.format("%02x",string.byte(color2,1)) .. string.format("%02x",string.byte(color2,3))
|
||||||
|
Loading…
Reference in New Issue
Block a user