Brightness control can be activated and deactivated

This commit is contained in:
ollo
2019-05-03 22:11:44 +02:00
parent 13343fa645
commit 69a2158ca6
4 changed files with 11 additions and 10 deletions

View File

@@ -49,11 +49,6 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
return nil
end
-- Initial value of percentage
if (words.briPercent == nil) then
words.briPercent=50
end
local minutes=1
if (words.min1 == 1) then
minutes = minutes + 1
@@ -64,7 +59,7 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
elseif (words.min4 == 1) then
minutes = minutes + 4
end
if (adc ~= nil) then
if ( (adc ~= nil) and (words.briPercent ~= nil) ) then
local per = math.floor(100*adc.read(0)/1000)
words.briPercent = tonumber( ((words.briPercent * 4) + per) / 5)
print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(words.briPercent) .. "% current: " .. tostring(per) .. "%")