LEDs are controlled
This commit is contained in:
parent
b252453f1e
commit
0c8ab7155f
156
main.lua
156
main.lua
@ -26,16 +26,162 @@ tmr.alarm(0, 100, 1, function()
|
||||
end)
|
||||
|
||||
function generateLEDs(words)
|
||||
buf=""
|
||||
if (words.min4 == 1) then
|
||||
buf=string.char(0,0,50):rep(110)
|
||||
|
||||
color=string.char(0,0,50)
|
||||
white=string.char(0,0,0)
|
||||
buf=color
|
||||
-- line 1----------------------------------------------
|
||||
if (words.itis == 1) then
|
||||
buf=color:rep(2) -- ES
|
||||
-- K fill character
|
||||
buf=buf .. white:rep(1)
|
||||
buf=buf ..color:rep(3) -- IST
|
||||
-- L fill character
|
||||
buf=buf .. white:rep(1)
|
||||
else
|
||||
buf=white:rep(7)
|
||||
end
|
||||
if (words.fiveMin== 1) then
|
||||
buf= buf .. color:rep(4) -- FUENF
|
||||
else
|
||||
buf=string.char(0,0,0):rep(110)
|
||||
buf= buf .. white:rep(4)
|
||||
end
|
||||
-- line 2-- even row (so inverted) --------------------
|
||||
if (words.twenty == 1) then
|
||||
buf= buf .. color:rep(7) -- ZWANZIG
|
||||
else
|
||||
buf= buf .. white:rep(7)
|
||||
end
|
||||
if (words.tenMin == 1) then
|
||||
buf= buf .. color:rep(4) -- ZEHN
|
||||
else
|
||||
buf= buf .. white:rep(4)
|
||||
end
|
||||
-- line3----------------------------------------------
|
||||
--TODO ggf. auch ueber viertel vor abbildbar
|
||||
if (words.threequater == 1) then
|
||||
buf= buf .. color:rep(11) -- Dreiviertel
|
||||
elseif (words.quater == 1) then
|
||||
buf= buf .. white:rep(4)
|
||||
buf= buf .. color:rep(7) -- VIERTEL
|
||||
else
|
||||
buf= buf .. white:rep(11)
|
||||
end
|
||||
--line 4-------- even row (so inverted) -------------
|
||||
if (words.before == 1) then
|
||||
buf=buf .. white:rep(2)
|
||||
buf= buf .. color:rep(3) -- VOR
|
||||
else
|
||||
buf= buf .. white:rep(5)
|
||||
end
|
||||
if (words.after == 1) then
|
||||
buf= buf .. color:rep(4) -- NACH
|
||||
buf= buf .. white:rep(2) -- TG
|
||||
else
|
||||
buf= buf .. white:rep(6)
|
||||
end
|
||||
------------------------------------------------
|
||||
if (words.half == 1) then
|
||||
buf= buf .. color:rep(4) -- HALB
|
||||
buf= buf .. white:rep(1) -- X
|
||||
else
|
||||
buf= buf .. white:rep(5)
|
||||
end
|
||||
if (words.twelve == 1) then
|
||||
buf= buf .. color:rep(5) -- ZWOELF
|
||||
buf= buf .. white:rep(1) -- P
|
||||
else
|
||||
buf= buf .. white:rep(6)
|
||||
end
|
||||
------------even row (so inverted) ---------------------
|
||||
if (words.seven == 1) then
|
||||
buf= buf .. color:rep(6) -- SIEBEN
|
||||
buf= buf .. white:rep(5)
|
||||
elseif (words.one == 1) then
|
||||
buf= buf .. white:rep(5)
|
||||
buf= buf .. color:rep(4) -- EINS
|
||||
buf= buf .. white:rep(2)
|
||||
elseif (words.two == 1) then
|
||||
buf= buf .. white:rep(7)
|
||||
buf= buf .. color:rep(4) -- ZWEI
|
||||
else
|
||||
buf= buf .. white:rep(11)
|
||||
end
|
||||
------------------------------------------------
|
||||
if (words.three == 1) then
|
||||
buf= buf .. white:rep(1)
|
||||
buf= buf .. color:rep(4) -- DREI
|
||||
buf= buf .. white:rep(6)
|
||||
elseif (words.five == 1) then
|
||||
buf= buf .. white:rep(7)
|
||||
buf= buf .. color:rep(4) -- FUENF
|
||||
else
|
||||
buf= buf .. white:rep(11)
|
||||
end
|
||||
------------even row (so inverted) ---------------------
|
||||
if (words.four == 1) then
|
||||
buf= buf .. color:rep(4) -- VIER
|
||||
buf= buf .. white:rep(7)
|
||||
elseif (words.nine == 1) then
|
||||
buf= buf .. white:rep(4)
|
||||
buf= buf .. color:rep(4) -- NEUN
|
||||
buf= buf .. white:rep(3)
|
||||
elseif (words.eleven == 1) then
|
||||
buf= buf .. white:rep(8)
|
||||
buf= buf .. color:rep(3) -- ELEVEN
|
||||
else
|
||||
buf= buf .. white:rep(11)
|
||||
end
|
||||
------------------------------------------------
|
||||
if (words.eight == 1) then
|
||||
buf= buf .. white:rep(1)
|
||||
buf= buf .. color:rep(4) -- ACHT
|
||||
buf= buf .. white:rep(6)
|
||||
elseif (words.ten == 1) then
|
||||
buf= buf .. white:rep(5)
|
||||
buf= buf .. color:rep(4) -- ZEHN
|
||||
buf= buf .. white:rep(2)
|
||||
else
|
||||
buf= buf .. white:rep(11)
|
||||
end
|
||||
------------even row (so inverted) ---------------------
|
||||
if (words.clock == 1) then
|
||||
buf= buf .. color:rep(3) -- UHR
|
||||
else
|
||||
buf= buf .. white:rep(3)
|
||||
end
|
||||
if (words.sechs == 1) then
|
||||
buf= buf .. white:rep(2)
|
||||
buf= buf .. color:rep(5) -- SECHS
|
||||
buf= buf .. white:rep(1)
|
||||
else
|
||||
buf= buf .. white:rep(8)
|
||||
end
|
||||
|
||||
if (words.min1 == 1) then
|
||||
buf= buf .. color:rep(1)
|
||||
else
|
||||
buf= buf .. white:rep(1)
|
||||
end
|
||||
if (words.min2 == 1) then
|
||||
buf= buf .. color:rep(1)
|
||||
else
|
||||
buf= buf .. white:rep(1)
|
||||
end
|
||||
if (words.min3 == 1) then
|
||||
buf= buf .. color:rep(1)
|
||||
else
|
||||
buf= buf .. white:rep(1)
|
||||
end
|
||||
if (words.min4 == 1) then
|
||||
buf= buf .. color:rep(1)
|
||||
else
|
||||
buf= buf .. white:rep(1)
|
||||
end
|
||||
return buf
|
||||
end
|
||||
|
||||
tmr.alarm(1, 1000, 1 ,function()
|
||||
tmr.alarm(1, 5000, 1 ,function()
|
||||
sec, usec = rtctime.get()
|
||||
time = getTime(sec, timezoneoffset)
|
||||
print("Time : " , sec)
|
||||
|
@ -1,6 +1,8 @@
|
||||
-- Revese engeeniered code of display_wc_ger.c by Vlad Tepesch
|
||||
-- See https://www.mikrocontroller.net/articles/Word_Clock_Variante_1#Download
|
||||
|
||||
-- TODO: Also add the twenty as return value!
|
||||
|
||||
-- Return the leds to use
|
||||
-- the granuality is 5 minutes
|
||||
function display_timestat(hours, minutes, longmode)
|
||||
@ -9,8 +11,9 @@ function display_timestat(hours, minutes, longmode)
|
||||
end
|
||||
|
||||
-- generate an empty return type
|
||||
local ret = { itis=0, fiveMin=0, tenMin=0, after=0, before=0, threeHour=0, quater=0, half=0, s=0,
|
||||
local ret = { itis=0, fiveMin=0, tenMin=0, after=0, before=0, threeHour=0, quater=0, threequater=0, half=0, s=0,
|
||||
one=0, two=0, three=0, four=0, five=0, six=0, seven=0, eight=0, nine=0, ten=0, eleven=0, twelve=0,
|
||||
twenty=0,
|
||||
clock=0, sr_nc=0, min1=0, min2=0, min3=0, min4=0 }
|
||||
|
||||
-- return black screen if there is no real time given
|
||||
@ -60,8 +63,7 @@ function display_timestat(hours, minutes, longmode)
|
||||
ret.half=1
|
||||
ret.after=1
|
||||
elseif (minutes==9) then
|
||||
ret.quater=1
|
||||
ret.before=1
|
||||
ret.threequater=1
|
||||
elseif (minutes==10) then
|
||||
ret.tenMin=1
|
||||
ret.before=1
|
||||
|
Loading…
Reference in New Issue
Block a user