Merge branch 'nodemcu-firmware-2.2.1' of https://github.com/C3MA/Wordclock into nodemcu-firmware-2.2.1
This commit is contained in:
commit
27d8f68e84
@ -45,8 +45,8 @@ Please note that all settings are mandatory<br /><br />
|
|||||||
<table id="table-6">
|
<table id="table-6">
|
||||||
<tr><th><b>WIFI-SSID</b></th><td><input id="ssid" name="ssid" value="$SSID"></td><td>SSID of the wireless network</td></tr>
|
<tr><th><b>WIFI-SSID</b></th><td><input id="ssid" name="ssid" value="$SSID"></td><td>SSID of the wireless network</td></tr>
|
||||||
<tr><th>WIFI-Password</th><td><input id="password" name="password"></td><td>Password of the wireless network</td></tr>
|
<tr><th>WIFI-Password</th><td><input id="password" name="password"></td><td>Password of the wireless network</td></tr>
|
||||||
<tr><th>SNTP Server</th><td><input id="sntpserver" name="sntpserver" value="$SNTPSERVER"></td><td>Server to sync the time with. Only one ntp server is allowed.</tr>
|
<tr><th>SNTP Server</th><td><input id="sntpserver" name="sntpserver" value="$SNTPSERVER"></td><td>Server to sync the time with. Only one ntp server is allowed.</td></tr>
|
||||||
<tr><th>Offset to UTC time</th><td><input id="timezoneoffset" name="timezoneoffset" value="$TIMEOFFSET"></td><td>Define the offset to UTC time in hours. For example +1 hour for Germany</tr>
|
<tr><th>Offset to UTC time</th><td><input id="timezoneoffset" name="timezoneoffset" value="$TIMEOFFSET"></td><td>Define the offset to UTC time in hours. For example +1 hour for Germany</td></tr>
|
||||||
<tr><th>Foreground Color</th><td><input type="color" name="fcolor" value="$HEXCOLORFG"></td><td>LED Color for all minutes, divisible by five</td></tr>
|
<tr><th>Foreground Color</th><td><input type="color" name="fcolor" value="$HEXCOLORFG"></td><td>LED Color for all minutes, divisible by five</td></tr>
|
||||||
<tr><th>Background Color</th><td><input type="color" name="bcolor" value="$HEXCOLORBG"></td><td>Background LED Color</td></tr>
|
<tr><th>Background Color</th><td><input type="color" name="bcolor" value="$HEXCOLORBG"></td><td>Background LED Color</td></tr>
|
||||||
<tr><th>1. Minute Color</th><td><input type="color" name="colorMin1" value="$HEXCOLOR1"></td><td>First minute after</td></tr>
|
<tr><th>1. Minute Color</th><td><input type="color" name="colorMin1" value="$HEXCOLOR1"></td><td>First minute after</td></tr>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
--TODO:
|
--TODO:
|
||||||
|
|
||||||
configFile="config.lua"
|
configFile="config.lua"
|
||||||
|
|
||||||
|
httpSending=false
|
||||||
sentBytes=0
|
sentBytes=0
|
||||||
function sendPage(conn, nameOfFile, replaceMap)
|
function sendPage(conn, nameOfFile, replaceMap)
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
@ -11,8 +11,9 @@ function sendPage(conn, nameOfFile, replaceMap)
|
|||||||
conn:close()
|
conn:close()
|
||||||
print("Page sent")
|
print("Page sent")
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
|
httpSending=false
|
||||||
else
|
else
|
||||||
print("Next")
|
collectgarbage()
|
||||||
sendPage(conn, nameOfFile, replaceMap)
|
sendPage(conn, nameOfFile, replaceMap)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -32,9 +33,6 @@ function sendPage(conn, nameOfFile, replaceMap)
|
|||||||
local line = file.readline()
|
local line = file.readline()
|
||||||
|
|
||||||
while (line ~= nil) do
|
while (line ~= nil) do
|
||||||
-- increase the amount of sent bytes
|
|
||||||
sentBytes=sentBytes+string.len(line)
|
|
||||||
|
|
||||||
-- all placeholder begin with a $, so search for it in the current line
|
-- all placeholder begin with a $, so search for it in the current line
|
||||||
if (line:find("$") ~= nil) then
|
if (line:find("$") ~= nil) then
|
||||||
-- Replace the placeholder with the dynamic content
|
-- Replace the placeholder with the dynamic content
|
||||||
@ -45,10 +43,15 @@ function sendPage(conn, nameOfFile, replaceMap)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- increase the amount of sent bytes
|
||||||
|
sentBytes=sentBytes+string.len(line)
|
||||||
|
|
||||||
buf = buf .. line
|
buf = buf .. line
|
||||||
|
|
||||||
-- Sent after 1k data
|
-- Sent after 500 bytes data
|
||||||
if (string.len(buf) >= 700) then
|
if ( (string.len(buf) >= 500) or (node.heap() < 2000) ) then
|
||||||
line=nil
|
line=nil
|
||||||
conn:send(buf)
|
conn:send(buf)
|
||||||
print("Sent part of " .. sentBytes .. "B")
|
print("Sent part of " .. sentBytes .. "B")
|
||||||
@ -125,17 +128,55 @@ function startWebServer()
|
|||||||
srv=net.createServer(net.TCP)
|
srv=net.createServer(net.TCP)
|
||||||
srv:listen(80,function(conn)
|
srv:listen(80,function(conn)
|
||||||
conn:on("receive", function(conn,payload)
|
conn:on("receive", function(conn,payload)
|
||||||
|
if (httpSending) then
|
||||||
|
print("HTTP sending... be patient!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if (payload:find("GET /") ~= nil) then
|
if (payload:find("GET /") ~= nil) then
|
||||||
|
httpSending=true
|
||||||
--here is code for handling http request from a web-browser
|
--here is code for handling http request from a web-browser
|
||||||
|
collectgarbage()
|
||||||
|
-- Stop all
|
||||||
|
for i=0,5 do tmr.stop(i) end
|
||||||
|
-- unload all other functions
|
||||||
|
-- grep function *.lua | grep -v webserver | grep -v init.lua | grep -v main.lua | cut -f 2 -d ':' | grep "^function" | sed "s/function //g" | grep -o "^[a-zA-Z0-9\_]*"
|
||||||
|
updateColor = nil
|
||||||
|
drawLEDs = nil
|
||||||
|
round = nil
|
||||||
|
generateLEDs = nil
|
||||||
|
isSummerTime = nil
|
||||||
|
getUTCtime = nil
|
||||||
|
getTime = nil
|
||||||
|
display_timestat = nil
|
||||||
|
display_countcharacters_de = nil
|
||||||
|
display_countwords_de = nil
|
||||||
|
collectgarbage()
|
||||||
|
ws2812.write(string.char(0,0,0):rep(56) .. color:rep(2) .. string.char(0,0,0):rep(4) .. color:rep(2) .. string.char(0,0,0):rep(48))
|
||||||
|
-- Start Time after 1 minute
|
||||||
|
tmr.alarm(5, 60000, 0 ,function()
|
||||||
|
dependModules = { "timecore" , "wordclock", "displayword" }
|
||||||
|
for _,mod in pairs(dependModules) do
|
||||||
|
print("Loading " .. mod)
|
||||||
|
mydofile(mod)
|
||||||
|
end
|
||||||
|
-- Start the time Thread
|
||||||
|
displayTime()
|
||||||
|
-- Start the time Thread
|
||||||
|
tmr.alarm(1, 20000, 1 ,function()
|
||||||
|
displayTime()
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
-- send response after 100ms
|
||||||
|
tmr.alarm(4, 100, 0 ,function()
|
||||||
if (sendPage ~= nil) then
|
if (sendPage ~= nil) then
|
||||||
print("Sending webpage.html ...")
|
print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...")
|
||||||
-- Load the sendPagewebcontent
|
-- Load the sendPagewebcontent
|
||||||
replaceMap=fillDynamicMap()
|
replaceMap=fillDynamicMap()
|
||||||
sendPage(conn, "webpage.html", replaceMap)
|
sendPage(conn, "webpage.html", replaceMap)
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
else if (payload:find("POST /") ~=nil) then
|
else if (payload:find("POST /") ~=nil) then
|
||||||
--code for handling the POST-request (updating settings)
|
--code for handling the POST-request (updating settings)
|
||||||
_, postdatastart = payload:find("\r\n\r\n")
|
_, postdatastart = payload:find("\r\n\r\n")
|
||||||
@ -288,10 +329,11 @@ function startWebServer()
|
|||||||
conn:on("disconnection", function(c)
|
conn:on("disconnection", function(c)
|
||||||
print("Goodbye")
|
print("Goodbye")
|
||||||
node.output(nil) -- un-register the redirect output function, output goes to serial
|
node.output(nil) -- un-register the redirect output function, output goes to serial
|
||||||
|
collectgarbage()
|
||||||
--reset amount of sent bytes, as we reached the end
|
--reset amount of sent bytes, as we reached the end
|
||||||
sentBytes=0
|
sentBytes=0
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
--FileView done.
|
||||||
|
@ -105,7 +105,7 @@ function display_timestat(hours, minutes, longmode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (hours == 1) then
|
if (hours == 1) then
|
||||||
if (ret.it == 1) then
|
if ((ret.it == 1) and (ret.half == 0) ) then
|
||||||
ret.one=1
|
ret.one=1
|
||||||
else
|
else
|
||||||
ret.oneLong=1
|
ret.oneLong=1
|
||||||
|
Loading…
Reference in New Issue
Block a user