From 0e49a6842b219e7df7710369c81da23c2d9c5e68 Mon Sep 17 00:00:00 2001 From: ollo Date: Thu, 18 Apr 2019 16:45:50 +0200 Subject: [PATCH] extracted stopping function --- webserver.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/webserver.lua b/webserver.lua index 5d2478e..6c7b953 100644 --- a/webserver.lua +++ b/webserver.lua @@ -124,20 +124,7 @@ function fillDynamicMap() return replaceMap 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() +function stopWordclock() -- Stop all for i=0,5 do tmr.stop(i) end -- unload all other functions @@ -153,6 +140,24 @@ function startWebServer() display_countcharacters_de = nil display_countwords_de = nil 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)) -- Start Time after 1 minute tmr.alarm(5, 60000, 0 ,function()