diff --git a/init.lua b/init.lua
index 64fe3bb..ea1bd71 100644
--- a/init.lua
+++ b/init.lua
@@ -17,6 +17,7 @@ end)
bootledtimer:start()
function mydofile(mod)
+ print("load:" .. mod)
if (file.open(mod .. ".lua")) then
dofile( mod .. ".lua")
elseif (file.open(mod .. "_diet.lua")) then
@@ -36,7 +37,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
initTimer:unregister()
initTimer=nil
bootledtimer=nil
- local modlist = { "timecore" , "displayword", "ds18b20", "mqtt", "main" }
+ local modlist = { "timecore" , "displayword", "ds18b20", "mqtt", "main", "webserver" }
for i,mod in pairs(modlist) do
if (file.open(mod .. "_diet.lua")) then
file.remove(mod .. "_diet.lc")
diff --git a/webpage.html b/webpage.html
index 7266fa7..af7dd57 100644
--- a/webpage.html
+++ b/webpage.html
@@ -47,7 +47,13 @@ Please note that all settings are mandatory
WIFI-Password
Password of the wireless network
SNTP Server
Server to sync the time with. Only one ntp server is allowed.
Offset to UTC time
Define the offset to UTC time in hours. For example +1 hour for Germany
-
Foreground Color
LED Color for all minutes, divisible by five
+
General Foreground Color
LED Color for all minutes, divisible by five
+
Foreground Color Minute1
LED Color for first single minute
+
Foreground Color Minute2
LED Color for first single minute
+
Foreground Color Minute3
LED Color for first single minute
+
Foreground Color Minute4
LED Color for first single minute
+
Threequarter
3/4 instead of 1/4 before
+
Webserver
Activate Webserver
diff --git a/webserver.lua b/webserver.lua
index 77b87fd..a6d0dfc 100644
--- a/webserver.lua
+++ b/webserver.lua
@@ -107,6 +107,14 @@ function fillDynamicMap()
return replaceMap
end
+function readHex(source, variable)
+ local hexColor=string.sub(source, 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(variable.."=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n")
+end
+
function startWebServer()
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
@@ -162,63 +170,37 @@ function startWebServer()
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)
- file.write("color=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n")
- -- fill the current values
- color=string.char(green, red, blue)
+ readHex(_POST.fcolor, "color")
end
- 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")
- -- fill the current values
- color1=string.char(green, red, blue)
+ if ( _POST.mcolor1 ~= nil) then
+ readHex(_POST.mcolor1, "color1")
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")
- -- fill the current values
- color2=string.char(green, red, blue)
+ if ( _POST.mcolor2 ~= nil) then
+ readHex(_POST.mcolor2, "color2")
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")
- -- fill the current values
- color3=string.char(green, red, blue)
+ if ( _POST.mcolor3 ~= nil) then
+ readHex(_POST.mcolor3, "color3")
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")
- -- fill the current values
- color4=string.char(green, red, blue)
+ if ( _POST.mcolor4 ~= nil) then
+ readHex(_POST.mcolor4, "color4")
end
if ( _POST.bcolor ~= nil) then
local hexColor=string.sub(_POST.bcolor, 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("colorBg=string.char(" .. green .. "," .. red .. "," .. blue .. ")\n")
- -- fill the current values
- colorBg=string.char(green, red, blue)
+ readHex(_POST.bcolor, "colorBg")
end
if (getTime ~= nil) then
time = getTime(sec, timezoneoffset)
file.write("print(\"Config from " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. "\")\n")
end
+ if (_POST.web ~= nil) then
+ file.write("web=true\n")
+ -- fill the current values
+ web=true
+ else
+ file.write("web=nil\n") -- use webserver instead of mqtt or telnet
+ -- fill the current values
+ web=nil
+ end
if (_POST.threequater ~= nil) then
file.write("threequater=true\n")
-- fill the current values
@@ -312,4 +294,4 @@ ledBuf=nil
print("Waiting in access point >wordclock< for Clients")
print("Please visit 192.168.4.1")
startWebServer()
-collectgarbage()
\ No newline at end of file
+collectgarbage()