From e4b22a9921cd82869dc51bff6fd7f2a7d34e3c16 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 10 Feb 2021 19:55:07 +0100 Subject: [PATCH] Removed debug code in main; shrinked struct name in displayword --- displayword.lua | 24 +++++++++++++++--------- main.lua | 23 ++++++----------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/displayword.lua b/displayword.lua index ffdeece..56cbbaf 100644 --- a/displayword.lua +++ b/displayword.lua @@ -1,9 +1,15 @@ -- Module filling a buffer, sent to the LEDs local M 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) - if (data.amountOfChars > 0) then - local div = tonumber(data.drawnCharacters/data.amountOfChars) + if (data.aoC > 0) then + local div = tonumber(data.dC/data.aoC) if (div < 1) then return data.colorFg elseif (div < 2) then @@ -33,7 +39,7 @@ local drawLEDs = function(data, numberNewChars) else tmpBuf=tmpBuf .. updateColor(data) end - data.drawnCharacters=data.drawnCharacters+1 + data.dC=data.dC+1 end return tmpBuf end @@ -63,8 +69,8 @@ local data={} -- @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 invertRows wheather line 4,5 and 6 shall be inverted or not --- @param amountOfChars Amount of characters to be displayed -local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3, colorM4, invertRows, amountOfChars) +-- @param aoC Amount of characters to be displayed +local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3, colorM4, invertRows, aoC) -- Set the local variables needed for the colored progress bar if (words == nil) then return nil @@ -88,10 +94,10 @@ local generateLEDs = function(words, colorBg, colorFg, colorM1, colorM2, colorM3 colorFg = string.char(255,255,255) end - if (amountOfChars ~= nil) then - data.amountOfChars = amountOfChars/minutes + if (aoC ~= nil) then + data.aoC = aoC/minutes else - data.amountOfChars = 0 + data.aoC = 0 end 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.colorM4=colorM4 end - data.drawnCharacters=0 + data.dC=0 local charsPerLine=11 -- Space / background has no color by default diff --git a/main.lua b/main.lua index 7bb98a4..6267604 100644 --- a/main.lua +++ b/main.lua @@ -51,24 +51,13 @@ function displayTime() displayword = nil if (ledBuf ~= nil) then ws2812.write(ledBuf) - else - if ((colorBg ~= nil) and (color ~= nil)) then - ws2812.write(colorBg:rep(107) .. color:rep(3)) - else - local space=string.char(0,0,0) - -- set FG to fix value: - colorFg = string.char(255,0,0) - 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 + else + -- set FG to fix value: RED + local space=string.char(0,0,0) + local color = string.char(255,0,0) + ws2812.write(space:rep(107) .. color:rep(3)) -- UHR end + -- cleanup briPercent=words.briPercent words=nil