From 017aef74f656dc418d8d99353977de2d11b69d76 Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 9 Dec 2022 23:22:27 +0100 Subject: [PATCH] Handle checkboxes on webserver --- main.lua | 13 ++++++++++--- webpage.html | 3 ++- webserver.lua | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main.lua b/main.lua index 852184e..37c3082 100644 --- a/main.lua +++ b/main.lua @@ -126,8 +126,7 @@ function normalOperation() mydofile("telnet") end else - -- start the webserver module - mydofile("webserver") + print("webserver prepared") end setupCounter=setupCounter-1 elseif (setupCounter > 2) then @@ -235,12 +234,20 @@ btntimer:register(500, tmr.ALARM_AUTO, function (t) mlt:unregister() print("Button pressed " .. tostring(btnCounter)) btnCounter = btnCounter + 5 - for i=1,btnCounter do rgbBuffer:set(i, 0, 128, 0) end + + if ((web ~= nil) and (btnCounter < 50)) then + for i=1,btnCounter do rgbBuffer:set(i, 128, 0, 0) end + else + for i=1,btnCounter do rgbBuffer:set(i, 0, 128, 0) end + end ws2812.write(rgbBuffer) if (btnCounter >= 110) then file.remove("config.lua") file.remove("config.lc") node.restart() + elseif (btnCounter == 10) then + -- start the webserver module + mydofile("webserver") end end end) diff --git a/webpage.html b/webpage.html index af7dd57..2993518 100644 --- a/webpage.html +++ b/webpage.html @@ -52,7 +52,8 @@ Please note that all settings are mandatory

Foreground Color Minute2LED Color for first single minute Foreground Color Minute3LED Color for first single minute Foreground Color Minute4LED Color for first single minute -Threequarter3/4 instead of 1/4 before +Threequarter3/4 instead of 1/4 before +Adjust brightnessDim brightness automatically WebserverActivate Webserver
diff --git a/webserver.lua b/webserver.lua index 8f0295b..006cd6c 100644 --- a/webserver.lua +++ b/webserver.lua @@ -165,7 +165,7 @@ function startWebServer() sec, _ = rtctime.get() 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("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=\"" .. tostring(_POST.inv46) .. "\"\n" .. "dim=\"" .. tostring(_POST.dim) .. "\"\n") + file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=" .. tostring(_POST.inv46) .. "\n" .. "dim=" .. tostring(_POST.dim) .. "\n") if ( _POST.fcolor ~= nil) then -- color=string.char(_POST.green, _POST.red, _POST.blue)