Round percentage of adc
This commit is contained in:
parent
aeb5dab9fd
commit
a11f756c42
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user