Reworked require with dofile
This commit is contained in:
parent
97de5dbb78
commit
c3e48fb17a
@ -1,16 +1,12 @@
|
|||||||
-- Module filling a buffer, sent to the LEDs
|
-- Module filling a buffer, sent to the LEDs
|
||||||
|
local M
|
||||||
local moduleName = ...
|
do
|
||||||
local M = {} -- public interface
|
local updateColor = function (data, inverseRow)
|
||||||
_G[moduleName] = M
|
|
||||||
|
|
||||||
|
|
||||||
function M.updateColor(data, inverseRow)
|
|
||||||
--FIXME magic missing to start on the left side
|
--FIXME magic missing to start on the left side
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.drawLEDs(data, numberNewChars, inverseRow)
|
local drawLEDs = function(data, numberNewChars, inverseRow)
|
||||||
if (inverseRow == nil) then
|
if (inverseRow == nil) then
|
||||||
inverseRow=false
|
inverseRow=false
|
||||||
end
|
end
|
||||||
@ -30,7 +26,7 @@ function M.drawLEDs(data, numberNewChars, inverseRow)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Utility function for round
|
-- Utility function for round
|
||||||
function M.round(num)
|
local round = function(num)
|
||||||
under = math.floor(num)
|
under = math.floor(num)
|
||||||
upper = math.floor(num) + 1
|
upper = math.floor(num) + 1
|
||||||
underV = -(under - num)
|
underV = -(under - num)
|
||||||
@ -47,7 +43,7 @@ local briPercent=50
|
|||||||
local data={}
|
local data={}
|
||||||
|
|
||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
function M.generateLEDs(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4)
|
local generateLEDs = function(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4)
|
||||||
-- Set the local variables needed for the colored progress bar
|
-- Set the local variables needed for the colored progress bar
|
||||||
data={}
|
data={}
|
||||||
|
|
||||||
@ -248,3 +244,11 @@ if (words.fiveMin== 1) then
|
|||||||
collectgarbage()
|
collectgarbage()
|
||||||
return buf
|
return buf
|
||||||
end
|
end
|
||||||
|
M = {
|
||||||
|
generateLEDs = generateLEDs,
|
||||||
|
round = round,
|
||||||
|
drawLEDs = drawLEDs,
|
||||||
|
updateColor = updateColor,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return M
|
11
main.lua
11
main.lua
@ -50,12 +50,13 @@ function displayTime()
|
|||||||
local time = getTime(sec, timezoneoffset)
|
local time = getTime(sec, timezoneoffset)
|
||||||
local words = display_timestat(time.hour, time.minute)
|
local words = display_timestat(time.hour, time.minute)
|
||||||
print(package.path)
|
print(package.path)
|
||||||
dp = require("displayword")
|
dp = dofile("displayword.lc")
|
||||||
|
if (dp ~= nil) then
|
||||||
ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4)
|
ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4)
|
||||||
|
|
||||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(dp.data.drawnCharacters))
|
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(dp.data.drawnCharacters))
|
||||||
|
end
|
||||||
dp = nil
|
dp = nil
|
||||||
|
if (ledBuf ~= 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
|
||||||
if ((inv46 ~= nil) and (inv46 == "on")) then
|
if ((inv46 ~= nil) and (inv46 == "on")) then
|
||||||
tempstring = ledBuf:sub(1,99) -- first 33 leds
|
tempstring = ledBuf:sub(1,99) -- first 33 leds
|
||||||
@ -72,9 +73,7 @@ function displayTime()
|
|||||||
ws2812.write(ledBuf)
|
ws2812.write(ledBuf)
|
||||||
ledBuf=nil
|
ledBuf=nil
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Used for debugging
|
-- Used for debugging
|
||||||
if (clockdebug ~= nil) then
|
if (clockdebug ~= nil) then
|
||||||
for key,value in pairs(words) do
|
for key,value in pairs(words) do
|
||||||
|
Loading…
Reference in New Issue
Block a user