Filling words in odd rows still open
This commit is contained in:
parent
674835ae73
commit
e01d699e8a
@ -1,6 +1,6 @@
|
||||
-- Module filling a buffer, sent to the LEDs
|
||||
|
||||
function updateColor(data, inverseRow)
|
||||
function updateColor(data, inverseRow, characters2draw)
|
||||
if (inverseRow == nil) then
|
||||
inverseRow=false
|
||||
end
|
||||
@ -24,21 +24,20 @@ function updateColor(data, inverseRow)
|
||||
return data.colorFg
|
||||
end
|
||||
else -- we must do some magic calculation FIXME the magic should be improved
|
||||
if (((data.drawnCharacters <= data.charsPerMinute) and not inverseRow) or
|
||||
((data.drawnCharacters > data.charsPerMinute) and inverseRow) ) then
|
||||
if (not inverseRow) then -- nomral row
|
||||
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
|
||||
return data.colorMin1
|
||||
else
|
||||
return data.colorFg
|
||||
end
|
||||
elseif ( ((data.drawnCharacters <= data.charsPerMinute*2) and not inverseRow) or
|
||||
((data.drawnCharacters <= data.charsPerMinute*2) and inverseRow)) then
|
||||
elseif (data.drawnCharacters < data.charsPerMinute*2) then
|
||||
if (data.words.min2 == 1 or data.words.min3 == 1 or data.words.min4 == 1) then
|
||||
return data.colorMin2
|
||||
else
|
||||
return data.colorFg
|
||||
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
|
||||
return data.colorMin3
|
||||
else
|
||||
@ -53,6 +52,10 @@ function updateColor(data, inverseRow)
|
||||
else
|
||||
return data.colorFg
|
||||
end
|
||||
else -- inverse row
|
||||
--FIXME magic missing
|
||||
return data.colorFg
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -60,12 +63,13 @@ function drawLEDs(data, numberNewChars, inverseRow)
|
||||
if (inverseRow == nil) then
|
||||
inverseRow=false
|
||||
end
|
||||
print("charactes " .. tostring(data.charsPerMinute) .. " per minute; " .. tonumber(data.drawnCharacters) .. " used characters")
|
||||
local tmpBuf=nil
|
||||
for i=1,numberNewChars do
|
||||
if (tmpBuf == nil) then
|
||||
tmpBuf = updateColor(data, inverseRow)
|
||||
tmpBuf = updateColor(data, inverseRow, numberNewChars)
|
||||
else
|
||||
tmpBuf=tmpBuf .. updateColor(data, inverseRow)
|
||||
tmpBuf=tmpBuf .. updateColor(data, inverseRow, numberNewChars)
|
||||
end
|
||||
data.drawnCharacters=data.drawnCharacters+1
|
||||
end
|
||||
@ -77,7 +81,7 @@ end
|
||||
function generateLEDs(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, characters)
|
||||
-- Set the local variables needed for the colored progress bar
|
||||
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.colorFg=colorFg
|
||||
data.colorMin1=colorMin1
|
||||
|
@ -5,9 +5,9 @@ blue=0
|
||||
|
||||
color=string.char(green, red, blue)
|
||||
color1=string.char(tonumber(green2*0.8), red, blue)
|
||||
color2=string.char(tonumber(green2*0.6), red, blue)
|
||||
color3=string.char(tonumber(green2*0.4), red, blue)
|
||||
color4=string.char(tonumber(green2*0.2), red, blue)
|
||||
color2=string.char(tonumber(green2*0.8), red, blue)
|
||||
color3=string.char(tonumber(green2*0.8), red, blue)
|
||||
color4=string.char(tonumber(green2*0.8), red, blue)
|
||||
|
||||
colorBg=string.char(0,0,0) -- black is the default background color
|
||||
sntpserverhostname="ptbtime1.ptb.de"
|
||||
|
Loading…
Reference in New Issue
Block a user