Refactored files to modules

This commit is contained in:
Ollo 2022-01-23 18:30:46 +01:00
parent e676f6f8cf
commit 7e7736e12f
5 changed files with 23 additions and 8 deletions

View File

@ -369,4 +369,4 @@ M = {
countChars = countChars countChars = countChars
} }
end end
dw = M return M

View File

@ -28,14 +28,17 @@ function displayTime()
if (timezoneoffset == nil) then if (timezoneoffset == nil) then
timezoneoffset=0 timezoneoffset=0
end end
mydofile("timecore") local tc = require("timecore_diet")
if (tc == nil) then if (tc == nil) then
return return
end end
local time = tc.getTime(sec, timezoneoffset) local time = tc.getTime(sec, timezoneoffset)
tc = nil tc = nil
timecore_diet=nil
package.loaded["timecore_diet"]=nil
collectgarbage() collectgarbage()
mydofile("wordclock") local wc = require("wordclock_diet")
if (wc ~= nil) then if (wc ~= nil) then
words = wc.timestat(time.hour, time.minute) words = wc.timestat(time.hour, time.minute)
if ((dim ~= nil) and (dim == "on")) then if ((dim ~= nil) and (dim == "on")) then
@ -48,9 +51,12 @@ function displayTime()
end end
end end
wc = nil wc = nil
wordclock_diet=nil
package.loaded["wordclock_diet"]=nil
collectgarbage() collectgarbage()
print("wc: " .. tostring(node.heap())) print("wc: " .. tostring(node.heap()))
mydofile("displayword") local dw = require("displayword_diet")
if (dw ~= nil) then if (dw ~= nil) then
--if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here --if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here
local invertRows=false local invertRows=false
@ -66,6 +72,9 @@ function displayTime()
print("Show number") print("Show number")
end end
dw = nil dw = nil
displayword_diet=nil
package.loaded["displayword_diet"]=nil
collectgarbage() collectgarbage()
-- cleanup -- cleanup

View File

@ -137,14 +137,20 @@ function registerMqtt()
-- generate the temperatur to display, once as it will not change -- generate the temperatur to display, once as it will not change
local dispTemp = tonumber(data) local dispTemp = tonumber(data)
collectgarbage() collectgarbage()
mydofile("wordclock") if (dispTemp > 0) then
local wc = require("wordclock_diet")
if (wc ~= nil) then if (wc ~= nil) then
tw = wc.showText(dw, rgbBuffer, invertRows, dispTemp) tw = wc.showText(dw, rgbBuffer, invertRows, dispTemp)
wc = nil
print("MQTT | generated words for: " .. tostring(dispTemp)) print("MQTT | generated words for: " .. tostring(dispTemp))
else else
print("MQTT | wordclock failed") print("MQTT | wordclock failed")
end end
wc = nil
wordclock_diet=nil
package.loaded["wordclock_diet"]=nil
else
tw=nil
end
end end
elseif (topic == (mqttPrefix .. "/cmd/num/col")) then elseif (topic == (mqttPrefix .. "/cmd/num/col")) then
-- Set number of the color to display -- Set number of the color to display

View File

@ -146,4 +146,4 @@ M = {
getTime = getTime getTime = getTime
} }
end end
tc = M return M

View File

@ -192,4 +192,4 @@ M = {
showText = showText showText = showText
} }
end end
wc = M return M