diff --git a/webpage.lua b/webpage.lua index 7a4c2a4..ebe7ddb 100644 --- a/webpage.lua +++ b/webpage.lua @@ -14,7 +14,23 @@ function sendWebPage(conn,answertype) if (color == nil) then color=string.char(0,0,250) end + if (color1 == nil) then + color1=color + end + if (color2 == nil) then + color2=color + end + if (color3 == nil) then + color3=color + end + if (color4 == nil) then + color4=color + 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 hexColor1 = "#" .. string.format("%02x",string.byte(color1,1)) .. string.format("%02x",string.byte(color1,2)) .. string.format("%02x",string.byte(color1,3)) + local hexColor2 = "#" .. string.format("%02x",string.byte(color2,1)) .. string.format("%02x",string.byte(color2,2)) .. string.format("%02x",string.byte(color2,3)) + local hexColor3 = "#" .. string.format("%02x",string.byte(color3,1)) .. string.format("%02x",string.byte(color3,2)) .. string.format("%02x",string.byte(color3,3)) + local hexColor4 = "#" .. string.format("%02x",string.byte(color4,1)) .. string.format("%02x",string.byte(color4,2)) .. string.format("%02x",string.byte(color4,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

" @@ -30,6 +46,10 @@ function sendWebPage(conn,answertype) 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 .."Color" + --buf = buf .."Color 1. Min" + --buf = buf .."Color 2. Min" + --buf = buf .."Color 3. Min" + --buf = buf .."Color 4. Min" buf = buf .."Three quaterDreiviertel Joa/nei" buf = buf .. "
" buf = buf .. "
" diff --git a/webserver.lua b/webserver.lua index b140455..56dd40a 100644 --- a/webserver.lua +++ b/webserver.lua @@ -78,9 +78,39 @@ function startWebServer() 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) + color=string.char(green, red, 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.colorMin1 ~= nil) then + local hexColor=string.sub(_POST.colorMin1, 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) + file.write("color1=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n") + end + if ( _POST.colorMin2 ~= nil) then + local hexColor=string.sub(_POST.colorMin2, 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) + file.write("color2=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n") + end + if ( _POST.colorMin3 ~= nil) then + local hexColor=string.sub(_POST.colorMin3, 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) + file.write("color3=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n") + end + if ( _POST.colorMin4 ~= nil) then + local hexColor=string.sub(_POST.colorMin4, 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) + file.write("color4=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n") + end + time = getTime(sec, timezoneoffset) + file.write("color=string.char(" .. string.byte(color,1) .. "," .. string.byte(color, 2) .. "," .. string.byte(color, 3) .. ")\n") + file.write("print(\"Config from " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. "\")\n") if (_POST.threequater ~= nil) then file.write("threequater=true\n") else