Removed debug code in main; shrinked struct name in displayword
This commit is contained in:
parent
40447dd521
commit
e4b22a9921
@ -1,9 +1,15 @@
|
|||||||
-- Module filling a buffer, sent to the LEDs
|
-- Module filling a buffer, sent to the LEDs
|
||||||
local M
|
local M
|
||||||
do
|
do
|
||||||
|
|
||||||
|
-- @fn generateLEDs
|
||||||
|
-- Module displaying of the words
|
||||||
|
-- @param data struct with the following paramter:
|
||||||
|
-- aoC amount of characters to be used
|
||||||
|
-- dC drawn characters
|
||||||
local updateColor = function (data)
|
local updateColor = function (data)
|
||||||
if (data.amountOfChars > 0) then
|
if (data.aoC > 0) then
|
||||||
local div = tonumber(data.drawnCharacters/data.amountOfChars)
|
local div = tonumber(data.dC/data.aoC)
|
||||||
if (div < 1) then
|
if (div < 1) then
|
||||||
return data.colorFg
|
return data.colorFg
|
||||||
elseif (div < 2) then
|
elseif (div < 2) then
|
||||||
@ -33,7 +39,7 @@ local drawLEDs = function(data, numberNewChars)
|
|||||||
else
|
else
|
||||||
tmpBuf=tmpBuf .. updateColor(data)
|
tmpBuf=tmpBuf .. updateColor(data)
|
||||||
end
|
end
|
||||||
data.drawnCharacters=data.drawnCharacters+1
|
data.dC=data.dC+1
|
||||||
end
|
end
|
||||||
return tmpBuf
|
return tmpBuf
|
||||||
end
|
end
|
||||||
@ -63,8 +69,8 @@ local data={}
|
|||||||
-- @param colorM3 foreground color if three minutes after a displayable time is present
|
-- @param colorM3 foreground color if three minutes after a displayable time is present
|
||||||
-- @param colorM4 foreground color if four minutes after a displayable time is present
|
-- @param colorM4 foreground color if four minutes after a displayable time is present
|
||||||
-- @param invertRows wheather line 4,5 and 6 shall be inverted or not
|
-- @param invertRows wheather line 4,5 and 6 shall be inverted or not
|
||||||
-- @param amountOfChars Amount of characters to be displayed
|
-- @param aoC Amount of characters to be displayed
|
||||||
local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3, colorM4, invertRows, amountOfChars)
|
local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3, colorM4, invertRows, aoC)
|
||||||
-- Set the local variables needed for the colored progress bar
|
-- Set the local variables needed for the colored progress bar
|
||||||
if (words == nil) then
|
if (words == nil) then
|
||||||
return nil
|
return nil
|
||||||
@ -88,10 +94,10 @@ local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3
|
|||||||
colorFg = string.char(255,255,255)
|
colorFg = string.char(255,255,255)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (amountOfChars ~= nil) then
|
if (aoC ~= nil) then
|
||||||
data.amountOfChars = amountOfChars/minutes
|
data.aoC = aoC/minutes
|
||||||
else
|
else
|
||||||
data.amountOfChars = 0
|
data.aoC = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if ( (adc ~= nil) and (words.briPercent ~= nil) ) then
|
if ( (adc ~= nil) and (words.briPercent ~= nil) ) then
|
||||||
@ -111,7 +117,7 @@ local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3
|
|||||||
data.colorM3=colorM3
|
data.colorM3=colorM3
|
||||||
data.colorM4=colorM4
|
data.colorM4=colorM4
|
||||||
end
|
end
|
||||||
data.drawnCharacters=0
|
data.dC=0
|
||||||
local charsPerLine=11
|
local charsPerLine=11
|
||||||
|
|
||||||
-- Space / background has no color by default
|
-- Space / background has no color by default
|
||||||
|
19
main.lua
19
main.lua
@ -52,23 +52,12 @@ function displayTime()
|
|||||||
if (ledBuf ~= nil) then
|
if (ledBuf ~= nil) then
|
||||||
ws2812.write(ledBuf)
|
ws2812.write(ledBuf)
|
||||||
else
|
else
|
||||||
if ((colorBg ~= nil) and (color ~= nil)) then
|
-- set FG to fix value: RED
|
||||||
ws2812.write(colorBg:rep(107) .. color:rep(3))
|
|
||||||
else
|
|
||||||
local space=string.char(0,0,0)
|
local space=string.char(0,0,0)
|
||||||
-- set FG to fix value:
|
local color = string.char(255,0,0)
|
||||||
colorFg = string.char(255,0,0)
|
ws2812.write(space:rep(107) .. color:rep(3)) -- UHR
|
||||||
ws2812.write(space:rep(107) .. colorFg:rep(3))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- Used for debugging
|
|
||||||
if (clockdebug ~= nil) then
|
|
||||||
for key,value in pairs(words) do
|
|
||||||
if (value > 0) then
|
|
||||||
print(key,value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- cleanup
|
-- cleanup
|
||||||
briPercent=words.briPercent
|
briPercent=words.briPercent
|
||||||
words=nil
|
words=nil
|
||||||
|
Loading…
Reference in New Issue
Block a user