Always keep the LEDs at a minimum

This commit is contained in:
Ollo 2020-12-08 20:30:43 +01:00
parent df7f33bbf0
commit de47de1e6f
2 changed files with 13 additions and 4 deletions

View File

@ -54,6 +54,9 @@ function displayTime()
local words = display_timestat(time.hour, time.minute)
if ((dim ~= nil) and (dim == "on")) then
words.briPercent=briPercent
if (words.briPercent ~= nil and words.briPercent < 3) then
words.briPercent=3
end
else
words.briPercent=nil
end
@ -164,7 +167,7 @@ function normalOperation()
end
end)
-- Start the time Thread
tmr.alarm(1, 10000, 1 ,function()
tmr.alarm(1, 5000, 1 ,function()
displayTime()
collectgarbage()
end)

View File

@ -9,13 +9,16 @@ function startMqtt()
if (data == "ON") then
briPercent=100
m:publish(mqttPrefix .. "/clock", "ON", 0, 0)
displayTime()
elseif (data == "OFF") then
briPercent=0
m:publish(mqttPrefix .. "/clock", "OFF", 0, 0)
displayTime()
else
if (tonumber(data) >= 0 and tonumber(data) <= 100) then
briPercent=tonumber(data)
m:publish(mqttPrefix .. "/clock", tostring(data), 0, 0)
displayTime()
end
end
end
@ -37,8 +40,11 @@ end
if (mqttServer ~= nil and mqttPrefix ~= nil) then
startMqtt()
print "Started MQTT client"
tmr.alarm(5, 30000, 1 ,function()
oldBrightness=0
tmr.alarm(5, 10000, 1 ,function()
if (oldBrightness <> briPercent) then
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
end
oldBrightness = briPercent
end)
end