Refactored swapping of line 4,5 and 6
This commit is contained in:
parent
26b16a1e3f
commit
a7f566f706
@ -38,11 +38,17 @@ end
|
|||||||
local data={}
|
local data={}
|
||||||
|
|
||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
local generateLEDs = function(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4)
|
local generateLEDs = function(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4, invertRows)
|
||||||
-- Set the local variables needed for the colored progress bar
|
-- Set the local variables needed for the colored progress bar
|
||||||
if (words == nil) then
|
if (words == nil) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
if (invertRows == nil) then
|
||||||
|
invertRows=false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- DEBUG code, to determine, if the color argmuments are necessary or not
|
||||||
|
print(tostring(color) .. " " .. tostring(color1))
|
||||||
|
|
||||||
local minutes=0
|
local minutes=0
|
||||||
if (words.min1 == 1) then
|
if (words.min1 == 1) then
|
||||||
@ -141,9 +147,13 @@ if (words.fiveMin== 1) then
|
|||||||
else
|
else
|
||||||
line= line .. space:rep(5)
|
line= line .. space:rep(5)
|
||||||
end
|
end
|
||||||
|
if (invertRows == true) then
|
||||||
|
buf = buf .. line
|
||||||
|
else
|
||||||
for i = 0,10 do
|
for i = 0,10 do
|
||||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
if (words.half == 1) then
|
if (words.half == 1) then
|
||||||
line= drawLEDs(data,4) -- HALB
|
line= drawLEDs(data,4) -- HALB
|
||||||
@ -157,7 +167,13 @@ if (words.fiveMin== 1) then
|
|||||||
else
|
else
|
||||||
line= line .. space:rep(6)
|
line= line .. space:rep(6)
|
||||||
end
|
end
|
||||||
|
if (invertRows == true) then
|
||||||
|
for i = 0,10 do
|
||||||
|
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||||
|
end
|
||||||
|
else
|
||||||
buf=buf .. line
|
buf=buf .. line
|
||||||
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.seven == 1) then
|
if (words.seven == 1) then
|
||||||
line= space:rep(5)
|
line= space:rep(5)
|
||||||
@ -176,10 +192,13 @@ if (words.fiveMin== 1) then
|
|||||||
else
|
else
|
||||||
line= space:rep(11)
|
line= space:rep(11)
|
||||||
end
|
end
|
||||||
|
if (invertRows == true) then
|
||||||
|
buf = buf .. line
|
||||||
|
else
|
||||||
for i = 0,10 do
|
for i = 0,10 do
|
||||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
if (words.three == 1) then
|
if (words.three == 1) then
|
||||||
line= space:rep(1)
|
line= space:rep(1)
|
||||||
|
30
main.lua
30
main.lua
@ -58,26 +58,26 @@ function displayTime()
|
|||||||
end
|
end
|
||||||
dofile("displayword.lc")
|
dofile("displayword.lc")
|
||||||
if (displayword ~= nil) then
|
if (displayword ~= nil) then
|
||||||
ledBuf = displayword.generateLEDs(words, color, color1, color2, color3, color4)
|
--if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here
|
||||||
|
local invertRows=false
|
||||||
|
if ((inv46 ~= nil) and (inv46 == "on")) then
|
||||||
|
invertRows=true
|
||||||
|
end
|
||||||
|
ledBuf = displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows)
|
||||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(displayword.data.drawnCharacters))
|
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(displayword.data.drawnCharacters))
|
||||||
end
|
end
|
||||||
displayword = nil
|
displayword = nil
|
||||||
if (ledBuf ~= nil) then
|
if (ledBuf ~= nil) then
|
||||||
--if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here
|
|
||||||
if ((inv46 ~= nil) and (inv46 == "on")) then
|
|
||||||
tempstring = ledBuf:sub(1,99) -- first 33 leds
|
|
||||||
rowend = {44,55,66}
|
|
||||||
for _, startled in ipairs(rowend) do
|
|
||||||
for i = 0,10 do
|
|
||||||
tempstring = tempstring .. ledBuf:sub((startled-i)*3-2,(startled-i)*3)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
tempstring = tempstring .. ledBuf:sub((67*3)-2,ledBuf:len())
|
|
||||||
ws2812.write(tempstring)
|
|
||||||
tempstring=nil
|
|
||||||
else
|
|
||||||
ws2812.write(ledBuf)
|
ws2812.write(ledBuf)
|
||||||
ledBuf=nil
|
else
|
||||||
|
if ((colorBg ~= nil) and (color ~= nil)) then
|
||||||
|
ws2812.write(colorBg:rep(107) .. color:rep(3))
|
||||||
|
else
|
||||||
|
local space=string.char(0,0,0)
|
||||||
|
-- set FG to fix value:
|
||||||
|
colorFg = string.char(255,0,0)
|
||||||
|
ws2812.write(space:rep(107) .. colorFg:rep(3))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Used for debugging
|
-- Used for debugging
|
||||||
|
Loading…
Reference in New Issue
Block a user