Always keep the LEDs at a minimum
This commit is contained in:
parent
df7f33bbf0
commit
de47de1e6f
5
main.lua
5
main.lua
@ -54,6 +54,9 @@ function displayTime()
|
|||||||
local words = display_timestat(time.hour, time.minute)
|
local words = display_timestat(time.hour, time.minute)
|
||||||
if ((dim ~= nil) and (dim == "on")) then
|
if ((dim ~= nil) and (dim == "on")) then
|
||||||
words.briPercent=briPercent
|
words.briPercent=briPercent
|
||||||
|
if (words.briPercent ~= nil and words.briPercent < 3) then
|
||||||
|
words.briPercent=3
|
||||||
|
end
|
||||||
else
|
else
|
||||||
words.briPercent=nil
|
words.briPercent=nil
|
||||||
end
|
end
|
||||||
@ -164,7 +167,7 @@ function normalOperation()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
-- Start the time Thread
|
-- Start the time Thread
|
||||||
tmr.alarm(1, 10000, 1 ,function()
|
tmr.alarm(1, 5000, 1 ,function()
|
||||||
displayTime()
|
displayTime()
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
end)
|
end)
|
||||||
|
10
mqtt.lua
10
mqtt.lua
@ -9,13 +9,16 @@ function startMqtt()
|
|||||||
if (data == "ON") then
|
if (data == "ON") then
|
||||||
briPercent=100
|
briPercent=100
|
||||||
m:publish(mqttPrefix .. "/clock", "ON", 0, 0)
|
m:publish(mqttPrefix .. "/clock", "ON", 0, 0)
|
||||||
|
displayTime()
|
||||||
elseif (data == "OFF") then
|
elseif (data == "OFF") then
|
||||||
briPercent=0
|
briPercent=0
|
||||||
m:publish(mqttPrefix .. "/clock", "OFF", 0, 0)
|
m:publish(mqttPrefix .. "/clock", "OFF", 0, 0)
|
||||||
|
displayTime()
|
||||||
else
|
else
|
||||||
if (tonumber(data) >= 0 and tonumber(data) <= 100) then
|
if (tonumber(data) >= 0 and tonumber(data) <= 100) then
|
||||||
briPercent=tonumber(data)
|
briPercent=tonumber(data)
|
||||||
m:publish(mqttPrefix .. "/clock", tostring(data), 0, 0)
|
m:publish(mqttPrefix .. "/clock", tostring(data), 0, 0)
|
||||||
|
displayTime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -37,8 +40,11 @@ end
|
|||||||
if (mqttServer ~= nil and mqttPrefix ~= nil) then
|
if (mqttServer ~= nil and mqttPrefix ~= nil) then
|
||||||
startMqtt()
|
startMqtt()
|
||||||
print "Started MQTT client"
|
print "Started MQTT client"
|
||||||
|
oldBrightness=0
|
||||||
tmr.alarm(5, 30000, 1 ,function()
|
tmr.alarm(5, 10000, 1 ,function()
|
||||||
|
if (oldBrightness <> briPercent) then
|
||||||
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
|
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
|
||||||
|
end
|
||||||
|
oldBrightness = briPercent
|
||||||
end)
|
end)
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user