extracted stopping function

This commit is contained in:
ollo 2019-04-18 16:45:50 +02:00
parent 27d8f68e84
commit 0e49a6842b

View File

@ -124,20 +124,7 @@ function fillDynamicMap()
return replaceMap return replaceMap
end end
function startWebServer() function stopWordclock()
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(conn,payload)
if (httpSending) then
print("HTTP sending... be patient!")
return
end
if (payload:find("GET /") ~= nil) then
httpSending=true
--here is code for handling http request from a web-browser
collectgarbage()
-- Stop all -- Stop all
for i=0,5 do tmr.stop(i) end for i=0,5 do tmr.stop(i) end
-- unload all other functions -- unload all other functions
@ -153,6 +140,24 @@ function startWebServer()
display_countcharacters_de = nil display_countcharacters_de = nil
display_countwords_de = nil display_countwords_de = nil
collectgarbage() collectgarbage()
end
function startWebServer()
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(conn,payload)
if (httpSending) then
print("HTTP sending... be patient!")
return
end
if (payload:find("GET /") ~= nil) then
httpSending=true
--here is code for handling http request from a web-browser
collectgarbage()
stopWordclock()
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)) 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 -- Start Time after 1 minute
tmr.alarm(5, 60000, 0 ,function() tmr.alarm(5, 60000, 0 ,function()