Started with word-wise coloring
This commit is contained in:
parent
0038a7997e
commit
d851964bc9
@ -1,25 +1,45 @@
|
|||||||
-- Module filling a buffer, sent to the LEDs
|
-- Module filling a buffer, sent to the LEDs
|
||||||
|
|
||||||
function updateColor(data)
|
function updateColor(data)
|
||||||
if (data.usedCharacters <= data.charsPerMinute) then
|
-- special case, and there are exactly 4 words to display (so each word for each minute)
|
||||||
|
if (data.amountWords == 4) then
|
||||||
|
print ("Amount words are " .. tostring(data.amountWords))
|
||||||
|
if (data.words.min1 == 1 and data.drawnWords == 0) then
|
||||||
|
print "Color1"
|
||||||
|
return data.colorMin1
|
||||||
|
elseif (data.words.min2 == 1 and data.drawnWords == 1) then
|
||||||
|
print "Color2"
|
||||||
|
return data.colorMin2
|
||||||
|
elseif (data.words.min3 == 1 and data.drawnWords == 2) then
|
||||||
|
print "Color3"
|
||||||
|
return data.colorMin3
|
||||||
|
elseif (data.words.min4 == 1 and data.drawnWords == 3) then
|
||||||
|
print "Color4"
|
||||||
|
return data.colorMin4
|
||||||
|
else
|
||||||
|
print "Color default"
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
|
else -- we must do some magic calculation
|
||||||
|
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.usedCharacters <= data.charsPerMinute*2) then
|
elseif (data.drawnCharacters <= data.charsPerMinute*2) 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.usedCharacters <= 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
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
elseif (data.usedCharacters > data.charsPerMinute*3) then
|
elseif (data.drawnCharacters > data.charsPerMinute*3) then
|
||||||
if (data.words.min4 == 1) then
|
if (data.words.min4 == 1) then
|
||||||
return data.colorMin4
|
return data.colorMin4
|
||||||
else
|
else
|
||||||
@ -29,6 +49,7 @@ function updateColor(data)
|
|||||||
return data.colorFg
|
return data.colorFg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function drawLEDs(data, numberNewChars)
|
function drawLEDs(data, numberNewChars)
|
||||||
local tmpBuf=nil
|
local tmpBuf=nil
|
||||||
@ -38,9 +59,9 @@ function drawLEDs(data, numberNewChars)
|
|||||||
else
|
else
|
||||||
tmpBuf=tmpBuf .. updateColor(data)
|
tmpBuf=tmpBuf .. updateColor(data)
|
||||||
end
|
end
|
||||||
data.usedCharacters=data.usedCharacters+1
|
data.drawnCharacters=data.drawnCharacters+1
|
||||||
|
|
||||||
end
|
end
|
||||||
|
data.drawnWords=data.drawnWords+1
|
||||||
return tmpBuf
|
return tmpBuf
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,7 +76,9 @@ function generateLEDs(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4
|
|||||||
data.colorMin2=colorMin2
|
data.colorMin2=colorMin2
|
||||||
data.colorMin3=colorMin3
|
data.colorMin3=colorMin3
|
||||||
data.colorMin4=colorMin4
|
data.colorMin4=colorMin4
|
||||||
data.usedCharacters=0
|
data.drawnCharacters=0
|
||||||
|
data.drawnWords=0
|
||||||
|
data.amountWords=display_countwords_de(words)
|
||||||
local space=string.char(0,0,0)
|
local space=string.char(0,0,0)
|
||||||
-- update the background color, if set
|
-- update the background color, if set
|
||||||
if (colorBg ~= nil) then
|
if (colorBg ~= nil) then
|
||||||
@ -66,7 +89,7 @@ function generateLEDs(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4
|
|||||||
local buf=colorFg
|
local buf=colorFg
|
||||||
|
|
||||||
-- line 1----------------------------------------------
|
-- line 1----------------------------------------------
|
||||||
if (words.itis == 1) then
|
if (words.it==1 words.is == 1) then
|
||||||
buf=drawLEDs(data,2) -- ES
|
buf=drawLEDs(data,2) -- ES
|
||||||
print(tostring(buf))
|
print(tostring(buf))
|
||||||
-- K fill character
|
-- K fill character
|
||||||
|
@ -12,7 +12,7 @@ function display_timestat(hours, minutes, longmode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- generate an empty return type
|
-- generate an empty return type
|
||||||
local ret = { itis=0, fiveMin=0, tenMin=0, after=0, before=0, threeHour=0, quater=0, threequater=0, half=0, s=0,
|
local ret = { it=0, is=0, fiveMin=0, tenMin=0, after=0, before=0, threeHour=0, quater=0, threequater=0, half=0, s=0,
|
||||||
one=0, oneLong=0, two=0, three=0, four=0, five=0, six=0, seven=0, eight=0, nine=0, ten=0, eleven=0, twelve=0,
|
one=0, oneLong=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,
|
twenty=0,
|
||||||
clock=0, sr_nc=0, min1=0, min2=0, min3=0, min4=0 }
|
clock=0, sr_nc=0, min1=0, min2=0, min3=0, min4=0 }
|
||||||
@ -31,7 +31,8 @@ function display_timestat(hours, minutes, longmode)
|
|||||||
if ((longmode==1)
|
if ((longmode==1)
|
||||||
or (minutes==0)
|
or (minutes==0)
|
||||||
or (minutes==6)) then
|
or (minutes==6)) then
|
||||||
ret.itis=1
|
ret.it=1
|
||||||
|
ret.is=1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle minutes
|
-- Handle minutes
|
||||||
@ -142,8 +143,11 @@ end
|
|||||||
-- @return the amount of characters, used to describe the time or <code>0</code> on errors
|
-- @return the amount of characters, used to describe the time or <code>0</code> on errors
|
||||||
function display_countcharacters_de(words)
|
function display_countcharacters_de(words)
|
||||||
local amount=0
|
local amount=0
|
||||||
if (words.itis == 1) then
|
if (words.it == 1) then
|
||||||
amount = amount + 5
|
amount = amount + 2
|
||||||
|
end
|
||||||
|
if (words.is == 1) then
|
||||||
|
amount = amount + 3
|
||||||
end
|
end
|
||||||
if (words.fiveMin == 1) then
|
if (words.fiveMin == 1) then
|
||||||
amount = amount + 4
|
amount = amount + 4
|
||||||
|
Loading…
Reference in New Issue
Block a user