From 3f8abd30bfe21acb279cc6375b219c25bd50ecd1 Mon Sep 17 00:00:00 2001 From: C3MA Date: Wed, 2 May 2018 21:03:43 +0200 Subject: [PATCH] Handle 4 words differently --- displayword.lua | 35 +++++++++++++++++++++++++++++++++-- simulation/config.lua | 6 +++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/displayword.lua b/displayword.lua index 2c1fa5c..d69babb 100644 --- a/displayword.lua +++ b/displayword.lua @@ -171,14 +171,45 @@ if (words.fiveMin== 1) then local bufColored = string.char() --function to set some color to the LEDs + local word=0 + local firstCharAfterSpace=true for x=0,9 do for y=0, (charsPerLine-1) do local start = ((x * charsPerLine) + y)*3 + 1 item=string.byte(buf, start) - -- Color + -- Color the visible words 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 + firstCharAfterSpace=true -- update the background color, if set if (colorBg ~= nil) then bufColored = bufColored .. colorBg diff --git a/simulation/config.lua b/simulation/config.lua index ed91742..ece2ce3 100644 --- a/simulation/config.lua +++ b/simulation/config.lua @@ -4,9 +4,9 @@ red=128 blue=0 color=string.char(green, red, blue) -color1=string.char(tonumber(green2*0.8), red, blue) -color2=string.char(tonumber(green2*0.8), red, blue) -color3=string.char(tonumber(green2*0.8), red, blue) +color1=string.char(tonumber(green2*0.2), red, blue) +color2=string.char(tonumber(green2*0.4), red, blue) +color3=string.char(tonumber(green2*0.6), red, blue) color4=string.char(tonumber(green2*0.8), red, blue) colorBg=string.char(0,0,0) -- black is the default background color