Wordclock/displayword.lua

161 lines
4.0 KiB
Lua
Raw Normal View History

2016-06-15 21:24:40 +02:00
-- Module displaying of the words
2016-06-18 17:07:49 +02:00
function generateLEDs(words, color)
2016-06-15 21:24:40 +02:00
2017-01-03 14:46:09 +01:00
local space=string.char(0,0,0)
-- update the background color, if set
if (colorBg ~= nil) then
space = colorBg
end
2016-06-19 00:08:21 +02:00
local buf=color
2016-06-15 21:24:40 +02:00
-- line 1----------------------------------------------
if (words.itis == 1) then
buf=color:rep(2) -- ES
-- K fill character
2017-01-03 14:46:09 +01:00
buf=buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
buf=buf ..color:rep(3) -- IST
-- L fill character
2017-01-03 14:46:09 +01:00
buf=buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf=space:rep(7)
2016-06-15 21:24:40 +02:00
end
if (words.fiveMin== 1) then
buf= buf .. color:rep(4) -- FUENF
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(4)
2016-06-15 21:24:40 +02:00
end
-- line 2-- even row (so inverted) --------------------
if (words.twenty == 1) then
buf= buf .. color:rep(7) -- ZWANZIG
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(7)
2016-06-15 21:24:40 +02:00
end
if (words.tenMin == 1) then
buf= buf .. color:rep(4) -- ZEHN
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(4)
2016-06-15 21:24:40 +02:00
end
-- line3----------------------------------------------
if (words.threequater == 1) then
buf= buf .. color:rep(11) -- Dreiviertel
2016-06-15 21:24:40 +02:00
elseif (words.quater == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(4)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(7) -- VIERTEL
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(11)
2016-06-15 21:24:40 +02:00
end
--line 4-------- even row (so inverted) -------------
if ((words.before == 1) or (words.threequater == 1)) then
2017-01-03 14:46:09 +01:00
buf=buf .. space:rep(2)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(3) -- VOR
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(5)
2016-06-15 21:24:40 +02:00
end
if (words.after == 1) then
buf= buf .. color:rep(4) -- NACH
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(2) -- TG
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(6)
2016-06-15 21:24:40 +02:00
end
------------------------------------------------
if (words.half == 1) then
buf= buf .. color:rep(4) -- HALB
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1) -- X
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(5)
2016-06-15 21:24:40 +02:00
end
if (words.twelve == 1) then
buf= buf .. color:rep(5) -- ZWOELF
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1) -- P
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(6)
2016-06-15 21:24:40 +02:00
end
------------even row (so inverted) ---------------------
if (words.seven == 1) then
buf= buf .. color:rep(6) -- SIEBEN
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(5)
2016-06-15 21:24:40 +02:00
elseif (words.one == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(5)
2016-12-12 20:25:55 +01:00
buf= buf .. color:rep(4) -- EINS
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(2)
2016-06-15 21:24:40 +02:00
elseif (words.two == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(7)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- ZWEI
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(11)
2016-06-15 21:24:40 +02:00
end
------------------------------------------------
if (words.three == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- DREI
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(6)
2016-06-15 21:24:40 +02:00
elseif (words.five == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(7)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- FUENF
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(11)
2016-06-15 21:24:40 +02:00
end
------------even row (so inverted) ---------------------
if (words.four == 1) then
buf= buf .. color:rep(4) -- VIER
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(7)
2016-06-15 21:24:40 +02:00
elseif (words.nine == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(4)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- NEUN
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(3)
2016-06-15 21:24:40 +02:00
elseif (words.eleven == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(8)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(3) -- ELEVEN
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(11)
2016-06-15 21:24:40 +02:00
end
------------------------------------------------
if (words.eight == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- ACHT
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(6)
2016-06-15 21:24:40 +02:00
elseif (words.ten == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(5)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(4) -- ZEHN
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(2)
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(11)
2016-06-15 21:24:40 +02:00
end
------------even row (so inverted) ---------------------
if (words.clock == 1) then
buf= buf .. color:rep(3) -- UHR
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(3)
2016-06-15 21:24:40 +02:00
end
2016-06-18 19:12:31 +02:00
if (words.six == 1) then
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(2)
2016-06-15 21:24:40 +02:00
buf= buf .. color:rep(5) -- SECHS
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(8)
2016-06-15 21:24:40 +02:00
end
if (words.min1 == 1) then
buf= buf .. color:rep(1)
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
end
if (words.min2 == 1) then
buf= buf .. color:rep(1)
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
end
if (words.min3 == 1) then
buf= buf .. color:rep(1)
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
end
if (words.min4 == 1) then
buf= buf .. color:rep(1)
else
2017-01-03 14:46:09 +01:00
buf= buf .. space:rep(1)
2016-06-15 21:24:40 +02:00
end
collectgarbage()
2016-06-15 21:24:40 +02:00
return buf
2016-06-18 17:07:49 +02:00
end