Background color can be set
This commit is contained in:
parent
353e6f0117
commit
9adf5b9ed7
@ -1,34 +1,39 @@
|
|||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
function generateLEDs(words, color)
|
function generateLEDs(words, color)
|
||||||
|
|
||||||
local white=string.char(0,0,0)
|
local space=string.char(0,0,0)
|
||||||
|
-- update the background color, if set
|
||||||
|
if (colorBg ~= nil) then
|
||||||
|
space = colorBg
|
||||||
|
end
|
||||||
|
|
||||||
local buf=color
|
local buf=color
|
||||||
-- line 1----------------------------------------------
|
-- line 1----------------------------------------------
|
||||||
if (words.itis == 1) then
|
if (words.itis == 1) then
|
||||||
buf=color:rep(2) -- ES
|
buf=color:rep(2) -- ES
|
||||||
-- K fill character
|
-- K fill character
|
||||||
buf=buf .. white:rep(1)
|
buf=buf .. space:rep(1)
|
||||||
buf=buf ..color:rep(3) -- IST
|
buf=buf ..color:rep(3) -- IST
|
||||||
-- L fill character
|
-- L fill character
|
||||||
buf=buf .. white:rep(1)
|
buf=buf .. space:rep(1)
|
||||||
else
|
else
|
||||||
buf=white:rep(7)
|
buf=space:rep(7)
|
||||||
end
|
end
|
||||||
if (words.fiveMin== 1) then
|
if (words.fiveMin== 1) then
|
||||||
buf= buf .. color:rep(4) -- FUENF
|
buf= buf .. color:rep(4) -- FUENF
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
end
|
end
|
||||||
-- line 2-- even row (so inverted) --------------------
|
-- line 2-- even row (so inverted) --------------------
|
||||||
if (words.twenty == 1) then
|
if (words.twenty == 1) then
|
||||||
buf= buf .. color:rep(7) -- ZWANZIG
|
buf= buf .. color:rep(7) -- ZWANZIG
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
end
|
end
|
||||||
if (words.tenMin == 1) then
|
if (words.tenMin == 1) then
|
||||||
buf= buf .. color:rep(4) -- ZEHN
|
buf= buf .. color:rep(4) -- ZEHN
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
end
|
end
|
||||||
-- line3----------------------------------------------
|
-- line3----------------------------------------------
|
||||||
--TODO ggf. auch ueber viertel vor abbildbar
|
--TODO ggf. auch ueber viertel vor abbildbar
|
||||||
@ -36,125 +41,125 @@ function generateLEDs(words, color)
|
|||||||
if (threequater ~= nil) then
|
if (threequater ~= nil) then
|
||||||
buf= buf .. color:rep(11) -- Dreiviertel
|
buf= buf .. color:rep(11) -- Dreiviertel
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
buf= buf .. color:rep(7) -- VIERTEL
|
buf= buf .. color:rep(7) -- VIERTEL
|
||||||
end
|
end
|
||||||
elseif (words.quater == 1) then
|
elseif (words.quater == 1) then
|
||||||
buf= buf .. white:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
buf= buf .. color:rep(7) -- VIERTEL
|
buf= buf .. color:rep(7) -- VIERTEL
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
--line 4-------- even row (so inverted) -------------
|
--line 4-------- even row (so inverted) -------------
|
||||||
if ((words.before == 1) or (words.threequater == 1 and threequater == nil)) then
|
if ((words.before == 1) or (words.threequater == 1 and threequater == nil)) then
|
||||||
buf=buf .. white:rep(2)
|
buf=buf .. space:rep(2)
|
||||||
buf= buf .. color:rep(3) -- VOR
|
buf= buf .. color:rep(3) -- VOR
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
end
|
end
|
||||||
if (words.after == 1) then
|
if (words.after == 1) then
|
||||||
buf= buf .. color:rep(4) -- NACH
|
buf= buf .. color:rep(4) -- NACH
|
||||||
buf= buf .. white:rep(2) -- TG
|
buf= buf .. space:rep(2) -- TG
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
end
|
end
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
if (words.half == 1) then
|
if (words.half == 1) then
|
||||||
buf= buf .. color:rep(4) -- HALB
|
buf= buf .. color:rep(4) -- HALB
|
||||||
buf= buf .. white:rep(1) -- X
|
buf= buf .. space:rep(1) -- X
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
end
|
end
|
||||||
if (words.twelve == 1) then
|
if (words.twelve == 1) then
|
||||||
buf= buf .. color:rep(5) -- ZWOELF
|
buf= buf .. color:rep(5) -- ZWOELF
|
||||||
buf= buf .. white:rep(1) -- P
|
buf= buf .. space:rep(1) -- P
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.seven == 1) then
|
if (words.seven == 1) then
|
||||||
buf= buf .. color:rep(6) -- SIEBEN
|
buf= buf .. color:rep(6) -- SIEBEN
|
||||||
buf= buf .. white:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
elseif (words.one == 1) then
|
elseif (words.one == 1) then
|
||||||
buf= buf .. white:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
buf= buf .. color:rep(4) -- EINS
|
buf= buf .. color:rep(4) -- EINS
|
||||||
buf= buf .. white:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
elseif (words.two == 1) then
|
elseif (words.two == 1) then
|
||||||
buf= buf .. white:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
buf= buf .. color:rep(4) -- ZWEI
|
buf= buf .. color:rep(4) -- ZWEI
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
if (words.three == 1) then
|
if (words.three == 1) then
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
buf= buf .. color:rep(4) -- DREI
|
buf= buf .. color:rep(4) -- DREI
|
||||||
buf= buf .. white:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
elseif (words.five == 1) then
|
elseif (words.five == 1) then
|
||||||
buf= buf .. white:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
buf= buf .. color:rep(4) -- FUENF
|
buf= buf .. color:rep(4) -- FUENF
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.four == 1) then
|
if (words.four == 1) then
|
||||||
buf= buf .. color:rep(4) -- VIER
|
buf= buf .. color:rep(4) -- VIER
|
||||||
buf= buf .. white:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
elseif (words.nine == 1) then
|
elseif (words.nine == 1) then
|
||||||
buf= buf .. white:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
buf= buf .. color:rep(4) -- NEUN
|
buf= buf .. color:rep(4) -- NEUN
|
||||||
buf= buf .. white:rep(3)
|
buf= buf .. space:rep(3)
|
||||||
elseif (words.eleven == 1) then
|
elseif (words.eleven == 1) then
|
||||||
buf= buf .. white:rep(8)
|
buf= buf .. space:rep(8)
|
||||||
buf= buf .. color:rep(3) -- ELEVEN
|
buf= buf .. color:rep(3) -- ELEVEN
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
if (words.eight == 1) then
|
if (words.eight == 1) then
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
buf= buf .. color:rep(4) -- ACHT
|
buf= buf .. color:rep(4) -- ACHT
|
||||||
buf= buf .. white:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
elseif (words.ten == 1) then
|
elseif (words.ten == 1) then
|
||||||
buf= buf .. white:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
buf= buf .. color:rep(4) -- ZEHN
|
buf= buf .. color:rep(4) -- ZEHN
|
||||||
buf= buf .. white:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.clock == 1) then
|
if (words.clock == 1) then
|
||||||
buf= buf .. color:rep(3) -- UHR
|
buf= buf .. color:rep(3) -- UHR
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(3)
|
buf= buf .. space:rep(3)
|
||||||
end
|
end
|
||||||
if (words.six == 1) then
|
if (words.six == 1) then
|
||||||
buf= buf .. white:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
buf= buf .. color:rep(5) -- SECHS
|
buf= buf .. color:rep(5) -- SECHS
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(8)
|
buf= buf .. space:rep(8)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (words.min1 == 1) then
|
if (words.min1 == 1) then
|
||||||
buf= buf .. color:rep(1)
|
buf= buf .. color:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
end
|
end
|
||||||
if (words.min2 == 1) then
|
if (words.min2 == 1) then
|
||||||
buf= buf .. color:rep(1)
|
buf= buf .. color:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
end
|
end
|
||||||
if (words.min3 == 1) then
|
if (words.min3 == 1) then
|
||||||
buf= buf .. color:rep(1)
|
buf= buf .. color:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
end
|
end
|
||||||
if (words.min4 == 1) then
|
if (words.min4 == 1) then
|
||||||
buf= buf .. color:rep(1)
|
buf= buf .. color:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. white:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
end
|
end
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
return buf
|
return buf
|
||||||
|
Loading…
Reference in New Issue
Block a user