Inverted rows prepared in drawing
This commit is contained in:
parent
a4b085054e
commit
7965229dac
@ -1,6 +1,6 @@
|
|||||||
-- Module filling a buffer, sent to the LEDs
|
-- Module filling a buffer, sent to the LEDs
|
||||||
|
|
||||||
function updateColor(data)
|
function updateColor(data, inverseRow=false)
|
||||||
-- special case, and there are exactly 4 words to display (so each word for each minute)
|
-- special case, and there are exactly 4 words to display (so each word for each minute)
|
||||||
if (data.amountWords == 4) then
|
if (data.amountWords == 4) then
|
||||||
print ("Amount words are " .. tostring(data.amountWords))
|
print ("Amount words are " .. tostring(data.amountWords))
|
||||||
@ -20,14 +20,16 @@ function updateColor(data)
|
|||||||
print "Color default"
|
print "Color default"
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
else -- we must do some magic calculation
|
else -- we must do some magic calculation FIXME the magic should be improved
|
||||||
if (data.drawnCharacters <= data.charsPerMinute) then
|
if (((data.drawnCharacters <= data.charsPerMinute) and not inverseRow) or
|
||||||
|
((data.drawnCharacters > data.charsPerMinute) and inverseRow) ) then
|
||||||
if (data.words.min1 == 1 or data.words.min2 == 1 or data.words.min3 == 1 or data.words.min4 == 1) then
|
if (data.words.min1 == 1 or data.words.min2 == 1 or data.words.min3 == 1 or data.words.min4 == 1) then
|
||||||
return data.colorMin1
|
return data.colorMin1
|
||||||
else
|
else
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
elseif (data.drawnCharacters <= data.charsPerMinute*2) then
|
elseif ( ((data.drawnCharacters <= data.charsPerMinute*2) and not inverseRow) or
|
||||||
|
((data.drawnCharacters <= data.charsPerMinute*2) and inverseRow)) then
|
||||||
if (data.words.min2 == 1 or data.words.min3 == 1 or data.words.min4 == 1) then
|
if (data.words.min2 == 1 or data.words.min3 == 1 or data.words.min4 == 1) then
|
||||||
return data.colorMin2
|
return data.colorMin2
|
||||||
else
|
else
|
||||||
@ -51,13 +53,13 @@ function updateColor(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawLEDs(data, numberNewChars)
|
function drawLEDs(data, numberNewChars, inverseRow=false)
|
||||||
local tmpBuf=nil
|
local tmpBuf=nil
|
||||||
for i=1,numberNewChars do
|
for i=1,numberNewChars do
|
||||||
if (tmpBuf == nil) then
|
if (tmpBuf == nil) then
|
||||||
tmpBuf = updateColor(data)
|
tmpBuf = updateColor(data, inverseRow)
|
||||||
else
|
else
|
||||||
tmpBuf=tmpBuf .. updateColor(data)
|
tmpBuf=tmpBuf .. updateColor(data, inverseRow)
|
||||||
end
|
end
|
||||||
data.drawnCharacters=data.drawnCharacters+1
|
data.drawnCharacters=data.drawnCharacters+1
|
||||||
end
|
end
|
||||||
@ -110,12 +112,12 @@ if (words.fiveMin== 1) then
|
|||||||
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 .. drawLEDs(data,7) -- ZWANZIG
|
buf= buf .. drawLEDs(data,7,true) -- ZWANZIG
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
end
|
end
|
||||||
if (words.tenMin == 1) then
|
if (words.tenMin == 1) then
|
||||||
buf= buf .. drawLEDs(data,4) -- ZEHN
|
buf= buf .. drawLEDs(data,4,true) -- ZEHN
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
end
|
end
|
||||||
@ -131,12 +133,12 @@ if (words.fiveMin== 1) then
|
|||||||
--line 4-------- even row (so inverted) -------------
|
--line 4-------- even row (so inverted) -------------
|
||||||
if (words.before == 1) then
|
if (words.before == 1) then
|
||||||
buf=buf .. space:rep(2)
|
buf=buf .. space:rep(2)
|
||||||
buf= buf .. drawLEDs(data,3) -- VOR
|
buf= buf .. drawLEDs(data,3,true) -- VOR
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
end
|
end
|
||||||
if (words.after == 1) then
|
if (words.after == 1) then
|
||||||
buf= buf .. drawLEDs(data,4) -- NACH
|
buf= buf .. drawLEDs(data,4,true) -- NACH
|
||||||
buf= buf .. space:rep(2) -- TG
|
buf= buf .. space:rep(2) -- TG
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
@ -156,19 +158,19 @@ if (words.fiveMin== 1) then
|
|||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.seven == 1) then
|
if (words.seven == 1) then
|
||||||
buf= buf .. drawLEDs(data,6) -- SIEBEN
|
buf= buf .. drawLEDs(data,6,true) -- SIEBEN
|
||||||
buf= buf .. space:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
elseif (words.oneLong == 1) then
|
elseif (words.oneLong == 1) then
|
||||||
buf= buf .. space:rep(5)
|
buf= buf .. space:rep(5)
|
||||||
buf= buf .. drawLEDs(data,4) -- EINS
|
buf= buf .. drawLEDs(data,4,true) -- EINS
|
||||||
buf= buf .. space:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
elseif (words.one == 1) then
|
elseif (words.one == 1) then
|
||||||
buf= buf .. space:rep(6)
|
buf= buf .. space:rep(6)
|
||||||
buf= buf .. drawLEDs(data,3) -- EIN
|
buf= buf .. drawLEDs(data,3,true) -- EIN
|
||||||
buf= buf .. space:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
elseif (words.two == 1) then
|
elseif (words.two == 1) then
|
||||||
buf= buf .. space:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
buf= buf .. drawLEDs(data,4) -- ZWEI
|
buf= buf .. drawLEDs(data,4,true) -- ZWEI
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
@ -185,15 +187,15 @@ if (words.fiveMin== 1) then
|
|||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.four == 1) then
|
if (words.four == 1) then
|
||||||
buf= buf .. drawLEDs(data,4) -- VIER
|
buf= buf .. drawLEDs(data,4,true) -- VIER
|
||||||
buf= buf .. space:rep(7)
|
buf= buf .. space:rep(7)
|
||||||
elseif (words.nine == 1) then
|
elseif (words.nine == 1) then
|
||||||
buf= buf .. space:rep(4)
|
buf= buf .. space:rep(4)
|
||||||
buf= buf .. drawLEDs(data,4) -- NEUN
|
buf= buf .. drawLEDs(data,4,true) -- NEUN
|
||||||
buf= buf .. space:rep(3)
|
buf= buf .. space:rep(3)
|
||||||
elseif (words.eleven == 1) then
|
elseif (words.eleven == 1) then
|
||||||
buf= buf .. space:rep(8)
|
buf= buf .. space:rep(8)
|
||||||
buf= buf .. drawLEDs(data,3) -- ELEVEN
|
buf= buf .. drawLEDs(data,3,true) -- ELEVEN
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(11)
|
buf= buf .. space:rep(11)
|
||||||
end
|
end
|
||||||
@ -211,13 +213,13 @@ if (words.fiveMin== 1) then
|
|||||||
end
|
end
|
||||||
------------even row (so inverted) ---------------------
|
------------even row (so inverted) ---------------------
|
||||||
if (words.clock == 1) then
|
if (words.clock == 1) then
|
||||||
buf= buf .. drawLEDs(data,3) -- UHR
|
buf= buf .. drawLEDs(data,3,true) -- UHR
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(3)
|
buf= buf .. space:rep(3)
|
||||||
end
|
end
|
||||||
if (words.six == 1) then
|
if (words.six == 1) then
|
||||||
buf= buf .. space:rep(2)
|
buf= buf .. space:rep(2)
|
||||||
buf= buf .. drawLEDs(data,5) -- SECHS
|
buf= buf .. drawLEDs(data,5,true) -- SECHS
|
||||||
buf= buf .. space:rep(1)
|
buf= buf .. space:rep(1)
|
||||||
else
|
else
|
||||||
buf= buf .. space:rep(8)
|
buf= buf .. space:rep(8)
|
||||||
|
Loading…
Reference in New Issue
Block a user