@@ -862,6 +862,32 @@ void convertBrightness(StaticJsonDocument<200> data, uint8_t& val)
862862 val = brightness;
863863}
864864
865+ void convertPixels (JsonArray data, CRGB *leds, int numToFill)
866+ {
867+ for (JsonObject pixel : data)
868+ {
869+ int n = pixel[" n" ];
870+ CRGB color;
871+ color.r = pixel[" r" ];
872+ color.g = pixel[" g" ];
873+ color.b = pixel[" b" ];
874+ if (n < numToFill)
875+ {
876+ #if 0
877+ Serial.print("Setting pixel ");
878+ Serial.print(n);
879+ Serial.print(" r:");
880+ Serial.print(color.r);
881+ Serial.print(" g:");
882+ Serial.print(color.g);
883+ Serial.print(" b:");
884+ Serial.println(color.b);
885+ #endif
886+ leds[n] = color;
887+ }
888+ }
889+ }
890+
865891void setColors (uint8_t r, uint8_t g, uint8_t b, CRGB& color, uint8_t & hue)
866892{
867893 color.setRGB (r, g, b);
@@ -943,6 +969,12 @@ void mqttCallback(char* topic, byte* payload, unsigned int length)
943969 printLedStatus ();
944970 }
945971 }
972+
973+ if (data.containsKey (" pixels" ))
974+ {
975+ convertPixels (data[" pixels" ].as <JsonArray>(), leds1, numberLed1);
976+ }
977+
946978 // Update the content on the display
947979 need_redraw = true ;
948980
@@ -988,6 +1020,12 @@ void mqttCallback(char* topic, byte* payload, unsigned int length)
9881020 printLedStatus ();
9891021 }
9901022 }
1023+
1024+ if (data.containsKey (" pixels" ))
1025+ {
1026+ convertPixels (data[" pixels" ].as <JsonArray>(), leds2, numberLed2);
1027+ }
1028+
9911029 // Update the content on the display
9921030 need_redraw = true ;
9931031
@@ -1191,6 +1229,7 @@ bool publishLightDiscovery(int ledId)
11911229 effects.add (" confetti" );
11921230 effects.add (" bpm" );
11931231 effects.add (" juggle" );
1232+ effects.add (" mqtt" );
11941233
11951234 String deviceSuffix = machineId + String (" -led" ) + String (ledId);
11961235
@@ -1610,6 +1649,10 @@ void processEffects(CRGB *leds, bool power, const char* effect, uint8_t hue, uin
16101649 {
16111650 juggle (leds, hue, val, numToFill);
16121651 }
1652+ else if (0 == strcmp (effect, " mqtt" ))
1653+ {
1654+ // Do nothing here.
1655+ }
16131656 else
16141657 {
16151658 // Turn off LEDs if the effect is not supported
0 commit comments