Background can be changed via MQTT
This commit is contained in:
parent
30343fe638
commit
b44eb6f13e
@ -54,7 +54,7 @@ end
|
||||
local data={}
|
||||
|
||||
-- Module displaying of the words
|
||||
local generateLEDs = function(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, invertRows, amountOfChars)
|
||||
local generateLEDs = function(words, colorBg, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, invertRows, amountOfChars)
|
||||
-- Set the local variables needed for the colored progress bar
|
||||
if (words == nil) then
|
||||
return nil
|
||||
@ -103,9 +103,14 @@ local generateLEDs = function(words, colorFg, colorMin1, colorMin2, colorMin3, c
|
||||
end
|
||||
data.drawnCharacters=0
|
||||
local charsPerLine=11
|
||||
|
||||
-- Space / background has no color by default
|
||||
local space=string.char(0,0,0)
|
||||
|
||||
if (colorBg ~= nil) then
|
||||
space = colorBg
|
||||
end
|
||||
|
||||
-- Set the foreground color as the default color
|
||||
local buf=data.colorFg
|
||||
local line=space
|
||||
|
2
main.lua
2
main.lua
@ -72,7 +72,7 @@ function displayTime()
|
||||
invertRows=true
|
||||
end
|
||||
local characters = displayword.countChars(words)
|
||||
ledBuf = displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows, characters)
|
||||
ledBuf = displayword.generateLEDs(words, colorBg, color, color1, color2, color3, color4, invertRows, characters)
|
||||
end
|
||||
displayword = nil
|
||||
if (ledBuf ~= nil) then
|
||||
|
16
mqtt.lua
16
mqtt.lua
@ -16,15 +16,21 @@ function registerMqtt()
|
||||
elseif (data == "OFF") then
|
||||
briPercent=0
|
||||
m:publish(mqttPrefix .. "/clock", "OFF", 0, 0)
|
||||
elseif (data:sub(1,1) == "#" and data:len() == 7) then
|
||||
red = tonumber(data:sub(2,3), 16)
|
||||
green = tonumber(data:sub(4,5), 16)
|
||||
blue = tonumber(data:sub(6,7), 16)
|
||||
colorBg=string.char(red, green, blue)
|
||||
elseif (data:sub(1,1) == "#" and data:len() == 7) then
|
||||
red = tonumber(data:sub(2,3), 16)
|
||||
green = tonumber(data:sub(4,5), 16)
|
||||
blue = tonumber(data:sub(6,7), 16)
|
||||
colorBg=string.char(red, green, blue)
|
||||
print("Updated BG: " .. tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue) )
|
||||
if (displayTime~= nil) then
|
||||
displayTime()
|
||||
end
|
||||
else
|
||||
if (tonumber(data) >= 0 and tonumber(data) <= 100) then
|
||||
briPercent=tonumber(data)
|
||||
m:publish(mqttPrefix .. "/clock", tostring(data), 0, 0)
|
||||
else
|
||||
print "Unknown MQTT command"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user