Handle 4 words differently

This commit is contained in:
C3MA 2018-05-02 21:03:43 +02:00
parent c9924f4a22
commit 3f8abd30bf
2 changed files with 36 additions and 5 deletions

View File

@ -171,14 +171,45 @@ if (words.fiveMin== 1) then
local bufColored = string.char() local bufColored = string.char()
--function to set some color to the LEDs --function to set some color to the LEDs
local word=0
local firstCharAfterSpace=true
for x=0,9 do for x=0,9 do
for y=0, (charsPerLine-1) do for y=0, (charsPerLine-1) do
local start = ((x * charsPerLine) + y)*3 + 1 local start = ((x * charsPerLine) + y)*3 + 1
item=string.byte(buf, start) item=string.byte(buf, start)
-- Color -- Color the visible words
if (item > 0) then if (item > 0) then
bufColored = bufColored .. colorForground if (firstCharAfterSpace == true) then
word = word + 1
end
firstCharAfterSpace=false
if (characters == 4) then -- we have a word for each minute to color differently
if (words.min4 == 1 and word == 4) then
bufColored = bufColored .. colorMin4
elseif (words.min3 == 1 and word == 3) then
bufColored = bufColored .. colorMin3
elseif (words.min2 == 1 and word == 2) then
bufColored = bufColored .. colorMin2
elseif (words.min1 == 1 and word == 1) then
bufColored = bufColored .. colorMin1
else
bufColored = bufColored .. colorForground
end
else -- FIXME some more magic should be added here
if (words.min4 == 1) then
bufColored = bufColored .. colorMin4
elseif (words.min3 == 1) then
bufColored = bufColored .. colorMin3
elseif (words.min2 == 1) then
bufColored = bufColored .. colorMin2
elseif (words.min1 == 1) then
bufColored = bufColored .. colorMin1
else
bufColored = bufColored .. colorForground
end
end
else else
firstCharAfterSpace=true
-- update the background color, if set -- update the background color, if set
if (colorBg ~= nil) then if (colorBg ~= nil) then
bufColored = bufColored .. colorBg bufColored = bufColored .. colorBg

View File

@ -4,9 +4,9 @@ red=128
blue=0 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.2), red, blue)
color2=string.char(tonumber(green2*0.8), red, blue) color2=string.char(tonumber(green2*0.4), red, blue)
color3=string.char(tonumber(green2*0.8), red, blue) color3=string.char(tonumber(green2*0.6), red, blue)
color4=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 colorBg=string.char(0,0,0) -- black is the default background color