All colors can be changed via MQTT
This commit is contained in:
parent
23bcd36a34
commit
8b58d4a39f
20
Readme.md
20
Readme.md
@ -42,7 +42,8 @@ Mandatory:
|
||||
* GPIO2 LEDs
|
||||
* GPIO0 Bootloader (at start)
|
||||
* GPIO0 factory reset (long during operation)
|
||||
Optinal:
|
||||
|
||||
Optional:
|
||||
* ADC VT93N2, 48k light resistor
|
||||
* GPIO4 DS18B20 Temperatur sensor
|
||||
|
||||
@ -50,6 +51,11 @@ Optinal:
|
||||
### Status
|
||||
* **basetopic**/brightness **Current brightness in percent**
|
||||
* **basetopic**/background **Current background color**
|
||||
* **basetopic**/color **Current foreground color**
|
||||
* **basetopic**/color1 **Current foreground color for first minute**
|
||||
* **basetopic**/color2 **Current foreground color for second minute**
|
||||
* **basetopic**/color3 **Current foreground color for third minute**
|
||||
* **basetopic**/color4 **Current foreground color for fourth minute**
|
||||
* **basetopic**/row1 **Current background color**
|
||||
* **basetopic**/temp **Temperatur**
|
||||
|
||||
@ -60,8 +66,18 @@ Optinal:
|
||||
* 0-100 **Set brightness to given value**
|
||||
* #rrggbb **Background color is set to hex representation of red, green and blue**
|
||||
* 0-255,0-255,0-255 **Background color is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/color
|
||||
* 0-255,0-255,0-255 **Foreground color is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/color1
|
||||
* 0-255,0-255,0-255 **Foreground color for first minute is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/color2
|
||||
* 0-255,0-255,0-255 **Foreground color for second minute is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/color3
|
||||
* 0-255,0-255,0-255 **Foreground color for third minute is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/color4
|
||||
* 0-255,0-255,0-255 **Foreground color for fourth minute is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/telnet
|
||||
* ignored **Stop MQTT server and start telnetserver at port 23**
|
||||
* ignored **Stop MQTT server, clock and start telnetserver at port 23**
|
||||
* **basetopic**/cmd/row1
|
||||
* 0-255,0-255,0-255 **Background color is set to decimal representation of red, green an blue**
|
||||
* **basetopic**/cmd/row1
|
||||
|
28
mqtt.lua
28
mqtt.lua
@ -39,7 +39,8 @@ end
|
||||
-- Parse MQTT data and extract color
|
||||
-- @param data MQTT information
|
||||
-- @param row string of the row e.g. "row1" used to publish current state
|
||||
function parseBgColor(data, row)
|
||||
-- @param per percent the color should be dimmed
|
||||
function parseBgColor(data, row, per)
|
||||
local red=nil
|
||||
local green=nil
|
||||
local blue=nil
|
||||
@ -52,7 +53,11 @@ function parseBgColor(data, row)
|
||||
end
|
||||
if ((red ~= nil) and (green ~= nil) and (blue ~= nil) ) then
|
||||
m:publish(mqttPrefix .. "/"..row, tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0)
|
||||
return string.char(green * briPer / 100, red * briPer / 100, blue * briPer / 100)
|
||||
if (per ~= nil) then
|
||||
return string.char(green * per / 100, red * per / 100, blue * per / 100)
|
||||
else
|
||||
return string.char(green , red , blue )
|
||||
end
|
||||
else
|
||||
return nil
|
||||
end
|
||||
@ -104,10 +109,25 @@ function registerMqtt()
|
||||
else
|
||||
print("Cannost start Telnet Server!")
|
||||
end
|
||||
else
|
||||
elseif (string.match(topic, "color$")) then
|
||||
color = parseBgColor(data, "color")
|
||||
print("Updated color" .. tostring(i) )
|
||||
elseif (string.match(topic, "color1$")) then
|
||||
color1 = parseBgColor(data, "color1")
|
||||
print("Updated color1" .. tostring(i) )
|
||||
elseif (string.match(topic, "color2$")) then
|
||||
color = parseBgColor(data, "color2")
|
||||
print("Updated color2" .. tostring(i) )
|
||||
elseif (string.match(topic, "color3$")) then
|
||||
color = parseBgColor(data, "color3")
|
||||
print("Updated color3" .. tostring(i) )
|
||||
elseif (string.match(topic, "color4$")) then
|
||||
color = parseBgColor(data, "color4")
|
||||
print("Updated color4" .. tostring(i) )
|
||||
else
|
||||
for i=1,10,1 do
|
||||
if (string.match(topic, "row".. tostring(i) .."$")) then
|
||||
rowbgColor[i] = parseBgColor(data, "row" .. tostring(i))
|
||||
rowbgColor[i] = parseBgColor(data, "row" .. tostring(i), briPer)
|
||||
print("Updated row" .. tostring(i) )
|
||||
return
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user