diff --git a/displayword.lua b/displayword.lua index 27e3561..8186bab 100644 --- a/displayword.lua +++ b/displayword.lua @@ -369,4 +369,4 @@ M = { countChars = countChars } end -dw = M +return M diff --git a/main.lua b/main.lua index 4fd5e04..62d984f 100644 --- a/main.lua +++ b/main.lua @@ -28,14 +28,17 @@ function displayTime() if (timezoneoffset == nil) then timezoneoffset=0 end - mydofile("timecore") + local tc = require("timecore_diet") if (tc == nil) then return end local time = tc.getTime(sec, timezoneoffset) tc = nil + timecore_diet=nil + package.loaded["timecore_diet"]=nil + collectgarbage() - mydofile("wordclock") + local wc = require("wordclock_diet") if (wc ~= nil) then words = wc.timestat(time.hour, time.minute) if ((dim ~= nil) and (dim == "on")) then @@ -48,9 +51,12 @@ function displayTime() end end wc = nil + wordclock_diet=nil + package.loaded["wordclock_diet"]=nil + collectgarbage() print("wc: " .. tostring(node.heap())) - mydofile("displayword") + local dw = require("displayword_diet") if (dw ~= nil) then --if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here local invertRows=false @@ -66,6 +72,9 @@ function displayTime() print("Show number") end dw = nil + displayword_diet=nil + package.loaded["displayword_diet"]=nil + collectgarbage() -- cleanup diff --git a/mqtt.lua b/mqtt.lua index 3b3a73c..3e46e20 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -137,14 +137,20 @@ function registerMqtt() -- generate the temperatur to display, once as it will not change local dispTemp = tonumber(data) collectgarbage() - mydofile("wordclock") + if (dispTemp > 0) then + local wc = require("wordclock_diet") if (wc ~= nil) then tw = wc.showText(dw, rgbBuffer, invertRows, dispTemp) - wc = nil print("MQTT | generated words for: " .. tostring(dispTemp)) else print("MQTT | wordclock failed") end + wc = nil + wordclock_diet=nil + package.loaded["wordclock_diet"]=nil + else + tw=nil + end end elseif (topic == (mqttPrefix .. "/cmd/num/col")) then -- Set number of the color to display diff --git a/timecore.lua b/timecore.lua index e7bb36c..25d32d5 100755 --- a/timecore.lua +++ b/timecore.lua @@ -146,4 +146,4 @@ M = { getTime = getTime } end -tc = M +return M diff --git a/wordclock.lua b/wordclock.lua index fb60c71..ba6df61 100755 --- a/wordclock.lua +++ b/wordclock.lua @@ -192,4 +192,4 @@ M = { showText = showText } end -wc = M +return M