Refactored swapping of line 4,5 and 6
This commit is contained in:
parent
26b16a1e3f
commit
a7f566f706
@ -38,11 +38,17 @@ end
|
||||
local data={}
|
||||
|
||||
-- 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
|
||||
if (words == nil) then
|
||||
return nil
|
||||
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
|
||||
if (words.min1 == 1) then
|
||||
@ -141,8 +147,12 @@ if (words.fiveMin== 1) then
|
||||
else
|
||||
line= line .. space:rep(5)
|
||||
end
|
||||
for i = 0,10 do
|
||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||
if (invertRows == true) then
|
||||
buf = buf .. line
|
||||
else
|
||||
for i = 0,10 do
|
||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||
end
|
||||
end
|
||||
------------------------------------------------
|
||||
if (words.half == 1) then
|
||||
@ -157,7 +167,13 @@ if (words.fiveMin== 1) then
|
||||
else
|
||||
line= line .. space:rep(6)
|
||||
end
|
||||
buf=buf .. line
|
||||
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
|
||||
end
|
||||
------------even row (so inverted) ---------------------
|
||||
if (words.seven == 1) then
|
||||
line= space:rep(5)
|
||||
@ -176,9 +192,12 @@ if (words.fiveMin== 1) then
|
||||
else
|
||||
line= space:rep(11)
|
||||
end
|
||||
|
||||
for i = 0,10 do
|
||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||
if (invertRows == true) then
|
||||
buf = buf .. line
|
||||
else
|
||||
for i = 0,10 do
|
||||
buf = buf .. line:sub((11-i)*3-2,(11-i)*3)
|
||||
end
|
||||
end
|
||||
------------------------------------------------
|
||||
if (words.three == 1) then
|
||||
|
30
main.lua
30
main.lua
@ -58,26 +58,26 @@ function displayTime()
|
||||
end
|
||||
dofile("displayword.lc")
|
||||
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))
|
||||
end
|
||||
displayword = nil
|
||||
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
|
||||
ws2812.write(ledBuf)
|
||||
else
|
||||
ws2812.write(ledBuf)
|
||||
ledBuf=nil
|
||||
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
|
||||
-- Used for debugging
|
||||
|
Loading…
Reference in New Issue
Block a user