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
|
-- 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,48 +24,52 @@ 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
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
|
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
|
||||||
|
if (data.words.min3 == 1 or data.words.min4 == 1) then
|
||||||
|
return data.colorMin3
|
||||||
|
else
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
|
elseif (data.drawnCharacters > data.charsPerMinute*3) then
|
||||||
|
if (data.words.min4 == 1) then
|
||||||
|
return data.colorMin4
|
||||||
|
else
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
elseif ( ((data.drawnCharacters <= data.charsPerMinute*2) and not inverseRow) or
|
else -- inverse row
|
||||||
((data.drawnCharacters <= data.charsPerMinute*2) and inverseRow)) then
|
--FIXME magic missing
|
||||||
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
|
|
||||||
if (data.words.min3 == 1 or data.words.min4 == 1) then
|
|
||||||
return data.colorMin3
|
|
||||||
else
|
|
||||||
return data.colorFg
|
|
||||||
end
|
|
||||||
elseif (data.drawnCharacters > data.charsPerMinute*3) then
|
|
||||||
if (data.words.min4 == 1) then
|
|
||||||
return data.colorMin4
|
|
||||||
else
|
|
||||||
return data.colorFg
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawLEDs(data, numberNewChars, inverseRow)
|
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
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user