Prepared Minutes in different colors

This commit is contained in:
C3MA 2016-12-14 19:12:14 +01:00
parent 67c506571f
commit 093ab81c34
2 changed files with 52 additions and 2 deletions

View File

@ -14,7 +14,23 @@ function sendWebPage(conn,answertype)
if (color == nil) then if (color == nil) then
color=string.char(0,0,250) color=string.char(0,0,250)
end 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 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" local buf="HTTP/1.1 200 OK\nServer: NodeMCU\nContent-Type: text/html\n\n"
if (node.heap() < 8000) then if (node.heap() < 8000) then
buf = buf .. "<h1>Busy, please come later again</h1>" buf = buf .. "<h1>Busy, please come later again</h1>"
@ -30,6 +46,10 @@ function sendWebPage(conn,answertype)
buf = buf .."<tr><th>SNTP Server</th><td><input name=\"sntpserver\" value=\"" .. sntpserverhostname .. "\"></td><td>ntp server to sync the time</tr>" buf = buf .."<tr><th>SNTP Server</th><td><input name=\"sntpserver\" value=\"" .. sntpserverhostname .. "\"></td><td>ntp server to sync the time</tr>"
buf = buf .."<tr><th>Offset to UTC time</th><td><input type=\"number\" name=\"timezoneoffset\" value=\"" .. timezoneoffset .. "\"></td><td>Define the offset to UTC time in hours. E.g +1</tr>" buf = buf .."<tr><th>Offset to UTC time</th><td><input type=\"number\" name=\"timezoneoffset\" value=\"" .. timezoneoffset .. "\"></td><td>Define the offset to UTC time in hours. E.g +1</tr>"
buf = buf .."<tr><th>Color</th><td><input type=\"color\" name=\"fcolor\" value=\"" .. hexColor .. "\"></td><td /></tr>" buf = buf .."<tr><th>Color</th><td><input type=\"color\" name=\"fcolor\" value=\"" .. hexColor .. "\"></td><td /></tr>"
--buf = buf .."<tr><th>Color 1. Min</th><td><input type=\"color\" name=\"colM1\" value=\"" .. hexColor1 .. "\"></td><td /></tr>"
--buf = buf .."<tr><th>Color 2. Min</th><td><input type=\"color\" name=\"colM2\" value=\"" .. hexColor2 .. "\"></td><td /></tr>"
--buf = buf .."<tr><th>Color 3. Min</th><td><input type=\"color\" name=\"colM3\" value=\"" .. hexColor3 .. "\"></td><td /></tr>"
--buf = buf .."<tr><th>Color 4. Min</th><td><input type=\"color\" name=\"colM4\" value=\"" .. hexColor4 .. "\"></td><td /></tr>"
buf = buf .."<tr><th>Three quater</th><td><input type=\"checkbox\" name=\"threequater\" ".. (threequater and "checked" or "") .. "></td><td>Dreiviertel Joa/nei</td></tr>" buf = buf .."<tr><th>Three quater</th><td><input type=\"checkbox\" name=\"threequater\" ".. (threequater and "checked" or "") .. "></td><td>Dreiviertel Joa/nei</td></tr>"
buf = buf .. "<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" value=\"Save Configuration\" onclick=\"this.value='Submitting ..';this.disabled='disabled'; this.form.submit();\"></div></td></tr>" buf = buf .. "<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" value=\"Save Configuration\" onclick=\"this.value='Submitting ..';this.disabled='disabled'; this.form.submit();\"></div></td></tr>"
buf = buf .. "<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" name=\"action\" value=\"Reboot\"></div></td></tr>" buf = buf .. "<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" name=\"action\" value=\"Reboot\"></div></td></tr>"

View File

@ -78,9 +78,39 @@ function startWebServer()
local red = tonumber(string.sub(hexColor, 1, 2), 16) local red = tonumber(string.sub(hexColor, 1, 2), 16)
local green = tonumber(string.sub(hexColor, 3, 4), 16) local green = tonumber(string.sub(hexColor, 3, 4), 16)
local blue = tonumber(string.sub(hexColor, 5, 6), 16) local blue = tonumber(string.sub(hexColor, 5, 6), 16)
color=string.char(red, green, blue) color=string.char(green, red, blue)
end 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 if (_POST.threequater ~= nil) then
file.write("threequater=true\n") file.write("threequater=true\n")
else else