dim value is set, webserver access is shown via the characters: W E B
This commit is contained in:
parent
bf61184217
commit
8001a8e1d4
@ -5,6 +5,15 @@ local sentBytes=0
|
|||||||
function sendPage(conn, nameOfFile, replaceMap)
|
function sendPage(conn, nameOfFile, replaceMap)
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Sending " .. nameOfFile .. " " .. sentBytes .. "B already; " .. node.heap() .. "B in heap")
|
print("Sending " .. nameOfFile .. " " .. sentBytes .. "B already; " .. node.heap() .. "B in heap")
|
||||||
|
if (sentBytes == 0) then
|
||||||
|
-- print status status
|
||||||
|
local statusColor=string.char(0,128,0)
|
||||||
|
if ((inv46 ~= nil) and (inv46 == "on")) then
|
||||||
|
ws2812.write(string.char(0,0,0):rep(55) .. statusColor:rep(2) .. string.char(0,0,0):rep(5) .. statusColor .. string.char(0,0,0):rep(49))
|
||||||
|
else
|
||||||
|
ws2812.write(string.char(0,0,0):rep(57) .. statusColor .. string.char(0,0,0):rep(5) .. statusColor:rep(2) .. string.char(0,0,0):rep(49))
|
||||||
|
end
|
||||||
|
end
|
||||||
conn:on("sent", function(conn)
|
conn:on("sent", function(conn)
|
||||||
if (sentBytes == 0) then
|
if (sentBytes == 0) then
|
||||||
conn:close()
|
conn:close()
|
||||||
@ -66,6 +75,13 @@ function sendPage(conn, nameOfFile, replaceMap)
|
|||||||
if (string.len(buf) > 0) then
|
if (string.len(buf) > 0) then
|
||||||
conn:send(buf)
|
conn:send(buf)
|
||||||
print("Sent rest")
|
print("Sent rest")
|
||||||
|
-- print status status
|
||||||
|
local statusColor=string.char(128,0,0)
|
||||||
|
if ((inv46 ~= nil) and (inv46 == "on")) then
|
||||||
|
ws2812.write(string.char(0,0,0):rep(55) .. statusColor:rep(2) .. string.char(0,0,0):rep(5) .. statusColor .. string.char(0,0,0):rep(49))
|
||||||
|
else
|
||||||
|
ws2812.write(string.char(0,0,0):rep(57) .. statusColor .. string.char(0,0,0):rep(5) .. statusColor:rep(2) .. string.char(0,0,0):rep(49))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -127,7 +143,6 @@ function startWebServer()
|
|||||||
if (color == nil) then
|
if (color == nil) then
|
||||||
color=string.char(0,128,0)
|
color=string.char(0,128,0)
|
||||||
end
|
end
|
||||||
ws2812.write(string.char(0,0,0):rep(56) .. color:rep(2) .. string.char(0,0,0):rep(4) .. color:rep(2) .. string.char(0,0,0):rep(48))
|
|
||||||
if (sendPage ~= nil) then
|
if (sendPage ~= nil) then
|
||||||
print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...")
|
print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...")
|
||||||
mydofile("config")
|
mydofile("config")
|
||||||
@ -165,7 +180,7 @@ function startWebServer()
|
|||||||
sec, _ = rtctime.get()
|
sec, _ = rtctime.get()
|
||||||
file.open(configFile.. ".new", "w+")
|
file.open(configFile.. ".new", "w+")
|
||||||
file.write("-- Config\n" .. "station_cfg={}\nstation_cfg.ssid=\"" .. _POST.ssid .. "\"\nstation_cfg.pwd=\"" .. _POST.password .. "\"\nstation_cfg.save=false\nwifi.sta.config(station_cfg)\n")
|
file.write("-- Config\n" .. "station_cfg={}\nstation_cfg.ssid=\"" .. _POST.ssid .. "\"\nstation_cfg.pwd=\"" .. _POST.password .. "\"\nstation_cfg.save=false\nwifi.sta.config(station_cfg)\n")
|
||||||
file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=on\n" .. "dim=" .. tostring(_POST.dim) .. "\n")
|
file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=nil\n")
|
||||||
|
|
||||||
if ( _POST.fcolor ~= nil) then
|
if ( _POST.fcolor ~= nil) then
|
||||||
-- color=string.char(_POST.green, _POST.red, _POST.blue)
|
-- color=string.char(_POST.green, _POST.red, _POST.blue)
|
||||||
@ -201,6 +216,11 @@ function startWebServer()
|
|||||||
-- fill the current values
|
-- fill the current values
|
||||||
web=nil
|
web=nil
|
||||||
end
|
end
|
||||||
|
if (_POST.dim ~= nil) then
|
||||||
|
file.write("dim=\"" .. tostring(_POST.dim) .. "\"\n")
|
||||||
|
else
|
||||||
|
file.write("dim=nil\n") -- unset dimming functionality
|
||||||
|
end
|
||||||
if (_POST.threequater ~= nil) then
|
if (_POST.threequater ~= nil) then
|
||||||
file.write("threequater=true\n")
|
file.write("threequater=true\n")
|
||||||
-- fill the current values
|
-- fill the current values
|
||||||
|
Loading…
Reference in New Issue
Block a user