From 95aad4f254c934e1150fc119c900550f28f76272 Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 15 Jan 2021 20:32:39 +0100 Subject: [PATCH] Fix color --- mqtt.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mqtt.lua b/mqtt.lua index 350551f..3b8e5f6 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -20,7 +20,7 @@ function handleSingleCommand(client, topic, data) else red, green, blue = string.match(data, "(%d+),(%d+),(%d+)") end - colorBg=string.char(red* briPercent / 100, green * briPercent / 100, blue * briPercent / 100) + colorBg=string.char(green * briPercent / 100, red * briPercent / 100, blue * briPercent / 100) print("Updated BG: " .. tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue) ) m:publish(mqttPrefix .. "/background", tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0) if (displayTime~= nil) then @@ -71,8 +71,8 @@ function registerMqtt() tmr.alarm(3, 1000, 0, function() -- publish a message with data = hello, QoS = 0, retain = 0 client:publish(mqttPrefix .. "/ip", tostring(wifi.sta.getip()), 0, 0) - local red = string.byte(colorBg,1) - local green = string.byte(colorBg,2) + local red = string.byte(colorBg,2) + local green = string.byte(colorBg,1) local blue = string.byte(colorBg,3) client:publish(mqttPrefix .. "/background", tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0) end)