From f440ccf68455b9f79e2d8ae37e915deb8ab89774 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 14 Dec 2022 21:18:21 +0100 Subject: [PATCH] More cleanup before starting the webserver --- main.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index 12437a3..5b2873c 100644 --- a/main.lua +++ b/main.lua @@ -240,7 +240,11 @@ local btnCounter=0 local btntimer = tmr.create() btntimer:register(500, tmr.ALARM_AUTO, function (t) if (gpio.read(3) == 0) then - mlt:unregister() + -- stop the main loop + if (mlt ~= nil) then + mlt:unregister() + mlt = nil + end print("Button pressed " .. tostring(btnCounter)) btnCounter = btnCounter + 5 @@ -255,8 +259,9 @@ btntimer:register(500, tmr.ALARM_AUTO, function (t) file.remove("config.lc") node.restart() elseif (btnCounter == 10) then - -- start the webserver module + collectgarbage() mydofile("webserver") + -- start the webserver module end end end)