Dim functionality is always activated
This commit is contained in:
parent
467f525764
commit
13343fa645
@ -38,8 +38,6 @@ local round = function(num)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Initial value of percentage
|
|
||||||
local briPercent=50
|
|
||||||
local data={}
|
local data={}
|
||||||
|
|
||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
@ -50,6 +48,11 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
|
|||||||
if (words == nil) then
|
if (words == nil) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Initial value of percentage
|
||||||
|
if (words.briPercent == nil) then
|
||||||
|
words.briPercent=50
|
||||||
|
end
|
||||||
|
|
||||||
local minutes=1
|
local minutes=1
|
||||||
if (words.min1 == 1) then
|
if (words.min1 == 1) then
|
||||||
@ -63,8 +66,8 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
|
|||||||
end
|
end
|
||||||
if (adc ~= nil) then
|
if (adc ~= nil) then
|
||||||
local per = math.floor(100*adc.read(0)/1000)
|
local per = math.floor(100*adc.read(0)/1000)
|
||||||
briPercent = math.floor( ((briPercent * 4) + per) / 5)
|
words.briPercent = tonumber( ((words.briPercent * 4) + per) / 5)
|
||||||
print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(briPercent) .. "% current: " .. tostring(per) .. "%")
|
print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(words.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.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)
|
data.colorMin1 = string.char(string.byte(colorMin1,1) * briPercent / 100, string.byte(colorMin1,2) * briPercent / 100, string.byte(colorMin1,3) * briPercent / 100)
|
||||||
data.colorMin2 = string.char(string.byte(colorMin2,1) * briPercent / 100, string.byte(colorMin2,2) * briPercent / 100, string.byte(colorMin2,3) * briPercent / 100)
|
data.colorMin2 = string.char(string.byte(colorMin2,1) * briPercent / 100, string.byte(colorMin2,2) * briPercent / 100, string.byte(colorMin2,3) * briPercent / 100)
|
||||||
|
5
main.lua
5
main.lua
@ -40,7 +40,7 @@ function syncTimeFromInternet()
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
briPercent = 50
|
||||||
function displayTime()
|
function displayTime()
|
||||||
local sec, usec = rtctime.get()
|
local sec, usec = rtctime.get()
|
||||||
-- Handle lazy programmer:
|
-- Handle lazy programmer:
|
||||||
@ -49,6 +49,7 @@ function displayTime()
|
|||||||
end
|
end
|
||||||
local time = getTime(sec, timezoneoffset)
|
local time = getTime(sec, timezoneoffset)
|
||||||
local words = display_timestat(time.hour, time.minute)
|
local words = display_timestat(time.hour, time.minute)
|
||||||
|
words.briPercent=briPercent
|
||||||
dp = dofile("displayword.lc")
|
dp = dofile("displayword.lc")
|
||||||
if (dp ~= nil) then
|
if (dp ~= nil) then
|
||||||
ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4)
|
ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4)
|
||||||
@ -82,7 +83,7 @@ function displayTime()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- cleanup
|
-- cleanup
|
||||||
|
briPercent=words.briPercent
|
||||||
words=nil
|
words=nil
|
||||||
time=nil
|
time=nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
|
Loading…
Reference in New Issue
Block a user