From aeae13642f63da6321f92d88968c8331c00cb691 Mon Sep 17 00:00:00 2001 From: ollo Date: Sat, 27 Apr 2019 00:22:29 +0200 Subject: [PATCH] More math --- displayword.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/displayword.lua b/displayword.lua index 3142b2c..057aba7 100644 --- a/displayword.lua +++ b/displayword.lua @@ -43,7 +43,7 @@ briPercent=50 -- Module displaying of the words function generateLEDs(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4) -- Set the local variables needed for the colored progress bar - data={} + local data={} local minutes=1 if (words.min1 == 1) then @@ -56,7 +56,7 @@ function generateLEDs(words, colorForground, colorMin1, colorMin2, colorMin3, co minutes = minutes + 4 end if (adc ~= nil) then - local per = (100*adc.read(0)/1024) + local per = math.floor(100*adc.read(0)/1000) briPercent = math.floor( ((briPercent * 4) + per) / 5) print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(briPercent) .. "% current: " .. tostring(per) .. "%") data.colorFg = string.char(string.byte(colorForground,1) * briPercent / 100, string.byte(colorForground,2) * briPercent / 100, string.byte(colorForground,3) * briPercent / 100)