Filling words in odd rows still open

This commit is contained in:
ollo 2018-02-18 15:40:54 +01:00
parent 674835ae73
commit e01d699e8a
2 changed files with 36 additions and 32 deletions

View File

@ -1,6 +1,6 @@
-- Module filling a buffer, sent to the LEDs -- Module filling a buffer, sent to the LEDs
function updateColor(data, inverseRow) function updateColor(data, inverseRow, characters2draw)
if (inverseRow == nil) then if (inverseRow == nil) then
inverseRow=false inverseRow=false
end end
@ -24,21 +24,20 @@ function updateColor(data, inverseRow)
return data.colorFg return data.colorFg
end end
else -- we must do some magic calculation FIXME the magic should be improved else -- we must do some magic calculation FIXME the magic should be improved
if (((data.drawnCharacters <= data.charsPerMinute) and not inverseRow) or if (not inverseRow) then -- nomral row
((data.drawnCharacters > data.charsPerMinute) and inverseRow) ) then if (data.drawnCharacters < data.charsPerMinute) 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) and not inverseRow) or elseif (data.drawnCharacters < data.charsPerMinute*2) then
((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
return data.colorFg return data.colorFg
end end
elseif (data.drawnCharacters <= data.charsPerMinute*3) then elseif (data.drawnCharacters < data.charsPerMinute*3) then
if (data.words.min3 == 1 or data.words.min4 == 1) then if (data.words.min3 == 1 or data.words.min4 == 1) then
return data.colorMin3 return data.colorMin3
else else
@ -53,6 +52,10 @@ function updateColor(data, inverseRow)
else else
return data.colorFg return data.colorFg
end end
else -- inverse row
--FIXME magic missing
return data.colorFg
end
end end
end end
@ -60,12 +63,13 @@ function drawLEDs(data, numberNewChars, inverseRow)
if (inverseRow == nil) then if (inverseRow == nil) then
inverseRow=false inverseRow=false
end end
print("charactes " .. tostring(data.charsPerMinute) .. " per minute; " .. tonumber(data.drawnCharacters) .. " used characters")
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, inverseRow) tmpBuf = updateColor(data, inverseRow, numberNewChars)
else else
tmpBuf=tmpBuf .. updateColor(data, inverseRow) tmpBuf=tmpBuf .. updateColor(data, inverseRow, numberNewChars)
end end
data.drawnCharacters=data.drawnCharacters+1 data.drawnCharacters=data.drawnCharacters+1
end end
@ -77,7 +81,7 @@ end
function generateLEDs(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, characters) function generateLEDs(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, characters)
-- Set the local variables needed for the colored progress bar -- Set the local variables needed for the colored progress bar
data={} data={}
data.charsPerMinute=math.floor(characters/3) -- devide by three (Minute 1 to Minute 3, Minute 4 takes the last chars) data.charsPerMinute=math.floor(characters/4) -- devide by three (Minute 1 to Minute 3, Minute 4 takes the last chars)
data.words=words data.words=words
data.colorFg=colorFg data.colorFg=colorFg
data.colorMin1=colorMin1 data.colorMin1=colorMin1

View File

@ -5,9 +5,9 @@ blue=0
color=string.char(green, red, blue) color=string.char(green, red, blue)
color1=string.char(tonumber(green2*0.8), red, blue) color1=string.char(tonumber(green2*0.8), red, blue)
color2=string.char(tonumber(green2*0.6), red, blue) color2=string.char(tonumber(green2*0.8), red, blue)
color3=string.char(tonumber(green2*0.4), red, blue) color3=string.char(tonumber(green2*0.8), red, blue)
color4=string.char(tonumber(green2*0.2), red, blue) color4=string.char(tonumber(green2*0.8), red, blue)
colorBg=string.char(0,0,0) -- black is the default background color colorBg=string.char(0,0,0) -- black is the default background color
sntpserverhostname="ptbtime1.ptb.de" sntpserverhostname="ptbtime1.ptb.de"