diff --git a/init.lua b/init.lua index f4ebbd2..d8aca43 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -print("Autostart in 10 seconds...") +print("Autostart in 5 seconds...") ws2812.init() -- WS2812 LEDs initialized on GPIO2 @@ -34,7 +34,7 @@ function mydofile(mod) end -tmr.alarm(1, 10000, 0, function() +tmr.alarm(1, 5000, 0, function() tmr.stop(2) if (file.open("main.lua")) then recompileAll() diff --git a/webpage.lua b/webpage.lua index aee9501..7a4c2a4 100644 --- a/webpage.lua +++ b/webpage.lua @@ -14,7 +14,7 @@ function sendWebPage(conn,answertype) if (color == nil) then color=string.char(0,0,250) end - + local hexColor = "#" .. string.format("%02x",string.byte(color,1)) .. string.format("%02x",string.byte(color,2)) .. string.format("%02x",string.byte(color,3)) local buf="HTTP/1.1 200 OK\nServer: NodeMCU\nContent-Type: text/html\n\n" if (node.heap() < 8000) then buf = buf .. "

Busy, please come later again

" @@ -28,10 +28,8 @@ function sendWebPage(conn,answertype) buf = buf .."WIFI-SSID" buf = buf .."WIFI-Password" buf = buf .."SNTP Serverntp server to sync the time" - buf = buf .."Offset to UTC timeDefine the offset to UTC time in hours. E.g +1" - buf = buf .."Red" - buf = buf .."Green" - buf = buf .."BlueAll Colors: 0 - 255" + buf = buf .."Offset to UTC timeDefine the offset to UTC time in hours. E.g +1" + buf = buf .."Color" buf = buf .."Three quaterDreiviertel Joa/nei" buf = buf .. "
" buf = buf .. "
" diff --git a/webserver.lua b/webserver.lua index fa16a30..b140455 100644 --- a/webserver.lua +++ b/webserver.lua @@ -71,8 +71,14 @@ function startWebServer() sec, _ = rtctime.get() file.open(configFile.. ".new", "w+") file.write("-- Config\n" .. "wifi.sta.config(\"" .. _POST.ssid .. "\",\"" .. _POST.password .. "\")\n" .. "sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n") - if ( (_POST.red ~= nil) and (_POST.green ~= nil) and (_POST.blue ~= nil) ) then - color=string.char(_POST.green, _POST.red, _POST.blue) + if ( _POST.fcolor ~= nil) then + -- color=string.char(_POST.green, _POST.red, _POST.blue) + print ("Got fcolor: " .. _POST.fcolor) + local hexColor=string.sub(_POST.fcolor, 4) + local red = tonumber(string.sub(hexColor, 1, 2), 16) + local green = tonumber(string.sub(hexColor, 3, 4), 16) + local blue = tonumber(string.sub(hexColor, 5, 6), 16) + color=string.char(red, green, blue) end file.write("color=string.char(" .. string.byte(color,1) .. "," .. string.byte(color, 2) .. "," .. string.byte(color, 3) .. ")\n print(\"Config from " .. sec .. "\")\n") if (_POST.threequater ~= nil) then