From a11f756c4200f054ebba6c4a95433a6cabec3850 Mon Sep 17 00:00:00 2001 From: ollo Date: Sat, 27 Apr 2019 00:14:27 +0200 Subject: [PATCH] Round percentage of adc --- displayword.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/displayword.lua b/displayword.lua index 91e59a9..3142b2c 100644 --- a/displayword.lua +++ b/displayword.lua @@ -57,7 +57,7 @@ function generateLEDs(words, colorForground, colorMin1, colorMin2, colorMin3, co end if (adc ~= nil) then local per = (100*adc.read(0)/1024) - briPercent = ( ((briPercent * 4) + per) / 5) + 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) data.colorMin1 = string.char(string.byte(colorMin1,1) * briPercent / 100, string.byte(colorMin1,2) * briPercent / 100, string.byte(colorMin1,3) * briPercent / 100)