1 (edited by Gunner 2021-06-10 19:27:56)

Topic: Random RGB Matrix

I did something similar with Blynk ages ago... and again now with RemoteXY... just because tongue

I would normally use a for() loop and random number to chose the element, but as I haven't figured out how to dynamically represent a variable name...

RemoteXY.led_[RANDOM_NUMBER_HERE]_r = random(256);

... I simply coded in each of the 67 elements... thrice... for each of the RGB values.  Ugly coding for the win! smile

BTW, if you want to see it run as it is intended (AKA fast) then you have to use the Free App, due some added feature in the Pro App that adds a lot of latency.  However, I did interlace the row order and reverse the column order for the odd rows, just to make it blend a wee bit better in the slower Pro App.

Enjoy...

https://www.dropbox.com/s/3iladlxx9mxnr … 3.png?dl=0

EDIT... Please DO NOT use this long and messy code sad   See my improved version a few posts below

/*
   -- LED Matrix --

   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.4.3 or later version
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
     - for ANDROID 4.7.12 or later version;
     - for iOS 1.4.7 or later version;

   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RGB Matrix"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377


// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255, 0, 0, 201, 0, 149, 1, 11, 13, 0,
  65, 7, 5, 12, 9, 9, 65, 7, 15, 12,
  9, 9, 65, 7, 25, 12, 9, 9, 65, 7,
  35, 12, 9, 9, 65, 7, 45, 12, 9, 9,
  65, 7, 55, 12, 9, 9, 65, 7, 65, 12,
  9, 9, 65, 7, 75, 12, 9, 9, 65, 7,
  85, 12, 9, 9, 65, 7, 10, 4, 9, 9,
  65, 7, 20, 4, 9, 9, 65, 7, 30, 4,
  9, 9, 65, 7, 40, 4, 9, 9, 65, 7,
  50, 4, 9, 9, 65, 7, 60, 4, 9, 9,
  65, 7, 70, 4, 9, 9, 65, 7, 80, 4,
  9, 9, 65, 7, 90, 4, 9, 9, 65, 7,
  0, 4, 9, 9, 65, 7, 5, 28, 9, 9,
  65, 7, 15, 28, 9, 9, 65, 7, 25, 28,
  9, 9, 65, 7, 35, 28, 9, 9, 65, 7,
  45, 28, 9, 9, 65, 7, 55, 28, 9, 9,
  65, 7, 65, 28, 9, 9, 65, 7, 75, 28,
  9, 9, 65, 7, 85, 28, 9, 9, 65, 7,
  0, 20, 9, 9, 65, 7, 10, 20, 9, 9,
  65, 7, 20, 20, 9, 9, 65, 7, 30, 20,
  9, 9, 65, 7, 40, 20, 9, 9, 65, 7,
  50, 20, 9, 9, 65, 7, 60, 20, 9, 9,
  65, 7, 70, 20, 9, 9, 65, 7, 80, 20,
  9, 9, 65, 7, 90, 20, 9, 9, 65, 7,
  5, 44, 9, 9, 65, 7, 15, 44, 9, 9,
  65, 7, 25, 44, 9, 9, 65, 7, 35, 44,
  9, 9, 65, 7, 45, 44, 9, 9, 65, 7,
  55, 44, 9, 9, 65, 7, 65, 44, 9, 9,
  65, 7, 75, 44, 9, 9, 65, 7, 85, 44,
  9, 9, 65, 7, 0, 52, 9, 9, 65, 7,
  10, 52, 9, 9, 65, 7, 20, 52, 9, 9,
  65, 7, 30, 52, 9, 9, 65, 7, 40, 52,
  9, 9, 65, 7, 50, 52, 9, 9, 65, 7,
  60, 52, 9, 9, 65, 7, 70, 52, 9, 9,
  65, 7, 80, 52, 9, 9, 65, 7, 90, 52,
  9, 9, 65, 7, 0, 36, 9, 9, 65, 7,
  10, 36, 9, 9, 65, 7, 20, 36, 9, 9,
  65, 7, 30, 36, 9, 9, 65, 7, 40, 36,
  9, 9, 65, 7, 50, 36, 9, 9, 65, 7,
  60, 36, 9, 9, 65, 7, 70, 36, 9, 9,
  65, 7, 80, 36, 9, 9, 65, 7, 90, 36,
  9, 9
};

// this structure defines all the variables and events of your control interface
struct {

  // output variables
  uint8_t led_10_r; // =0..255 LED Red brightness
  uint8_t led_10_g; // =0..255 LED Green brightness
  uint8_t led_10_b; // =0..255 LED Blue brightness
  uint8_t led_11_r; // =0..255 LED Red brightness
  uint8_t led_11_g; // =0..255 LED Green brightness
  uint8_t led_11_b; // =0..255 LED Blue brightness
  uint8_t led_12_r; // =0..255 LED Red brightness
  uint8_t led_12_g; // =0..255 LED Green brightness
  uint8_t led_12_b; // =0..255 LED Blue brightness
  uint8_t led_13_r; // =0..255 LED Red brightness
  uint8_t led_13_g; // =0..255 LED Green brightness
  uint8_t led_13_b; // =0..255 LED Blue brightness
  uint8_t led_14_r; // =0..255 LED Red brightness
  uint8_t led_14_g; // =0..255 LED Green brightness
  uint8_t led_14_b; // =0..255 LED Blue brightness
  uint8_t led_15_r; // =0..255 LED Red brightness
  uint8_t led_15_g; // =0..255 LED Green brightness
  uint8_t led_15_b; // =0..255 LED Blue brightness
  uint8_t led_16_r; // =0..255 LED Red brightness
  uint8_t led_16_g; // =0..255 LED Green brightness
  uint8_t led_16_b; // =0..255 LED Blue brightness
  uint8_t led_17_r; // =0..255 LED Red brightness
  uint8_t led_17_g; // =0..255 LED Green brightness
  uint8_t led_17_b; // =0..255 LED Blue brightness
  uint8_t led_18_r; // =0..255 LED Red brightness
  uint8_t led_18_g; // =0..255 LED Green brightness
  uint8_t led_18_b; // =0..255 LED Blue brightness
  uint8_t led_1_r; // =0..255 LED Red brightness
  uint8_t led_1_g; // =0..255 LED Green brightness
  uint8_t led_1_b; // =0..255 LED Blue brightness
  uint8_t led_2_r; // =0..255 LED Red brightness
  uint8_t led_2_g; // =0..255 LED Green brightness
  uint8_t led_2_b; // =0..255 LED Blue brightness
  uint8_t led_3_r; // =0..255 LED Red brightness
  uint8_t led_3_g; // =0..255 LED Green brightness
  uint8_t led_3_b; // =0..255 LED Blue brightness
  uint8_t led_4_r; // =0..255 LED Red brightness
  uint8_t led_4_g; // =0..255 LED Green brightness
  uint8_t led_4_b; // =0..255 LED Blue brightness
  uint8_t led_5_r; // =0..255 LED Red brightness
  uint8_t led_5_g; // =0..255 LED Green brightness
  uint8_t led_5_b; // =0..255 LED Blue brightness
  uint8_t led_6_r; // =0..255 LED Red brightness
  uint8_t led_6_g; // =0..255 LED Green brightness
  uint8_t led_6_b; // =0..255 LED Blue brightness
  uint8_t led_7_r; // =0..255 LED Red brightness
  uint8_t led_7_g; // =0..255 LED Green brightness
  uint8_t led_7_b; // =0..255 LED Blue brightness
  uint8_t led_8_r; // =0..255 LED Red brightness
  uint8_t led_8_g; // =0..255 LED Green brightness
  uint8_t led_8_b; // =0..255 LED Blue brightness
  uint8_t led_9_r; // =0..255 LED Red brightness
  uint8_t led_9_g; // =0..255 LED Green brightness
  uint8_t led_9_b; // =0..255 LED Blue brightness
  uint8_t led_0_r; // =0..255 LED Red brightness
  uint8_t led_0_g; // =0..255 LED Green brightness
  uint8_t led_0_b; // =0..255 LED Blue brightness
  uint8_t led_29_r; // =0..255 LED Red brightness
  uint8_t led_29_g; // =0..255 LED Green brightness
  uint8_t led_29_b; // =0..255 LED Blue brightness
  uint8_t led_30_r; // =0..255 LED Red brightness
  uint8_t led_30_g; // =0..255 LED Green brightness
  uint8_t led_30_b; // =0..255 LED Blue brightness
  uint8_t led_31_r; // =0..255 LED Red brightness
  uint8_t led_31_g; // =0..255 LED Green brightness
  uint8_t led_31_b; // =0..255 LED Blue brightness
  uint8_t led_32_r; // =0..255 LED Red brightness
  uint8_t led_32_g; // =0..255 LED Green brightness
  uint8_t led_32_b; // =0..255 LED Blue brightness
  uint8_t led_33_r; // =0..255 LED Red brightness
  uint8_t led_33_g; // =0..255 LED Green brightness
  uint8_t led_33_b; // =0..255 LED Blue brightness
  uint8_t led_34_r; // =0..255 LED Red brightness
  uint8_t led_34_g; // =0..255 LED Green brightness
  uint8_t led_34_b; // =0..255 LED Blue brightness
  uint8_t led_35_r; // =0..255 LED Red brightness
  uint8_t led_35_g; // =0..255 LED Green brightness
  uint8_t led_35_b; // =0..255 LED Blue brightness
  uint8_t led_36_r; // =0..255 LED Red brightness
  uint8_t led_36_g; // =0..255 LED Green brightness
  uint8_t led_36_b; // =0..255 LED Blue brightness
  uint8_t led_37_r; // =0..255 LED Red brightness
  uint8_t led_37_g; // =0..255 LED Green brightness
  uint8_t led_37_b; // =0..255 LED Blue brightness
  uint8_t led_19_r; // =0..255 LED Red brightness
  uint8_t led_19_g; // =0..255 LED Green brightness
  uint8_t led_19_b; // =0..255 LED Blue brightness
  uint8_t led_20_r; // =0..255 LED Red brightness
  uint8_t led_20_g; // =0..255 LED Green brightness
  uint8_t led_20_b; // =0..255 LED Blue brightness
  uint8_t led_21_r; // =0..255 LED Red brightness
  uint8_t led_21_g; // =0..255 LED Green brightness
  uint8_t led_21_b; // =0..255 LED Blue brightness
  uint8_t led_22_r; // =0..255 LED Red brightness
  uint8_t led_22_g; // =0..255 LED Green brightness
  uint8_t led_22_b; // =0..255 LED Blue brightness
  uint8_t led_23_r; // =0..255 LED Red brightness
  uint8_t led_23_g; // =0..255 LED Green brightness
  uint8_t led_23_b; // =0..255 LED Blue brightness
  uint8_t led_24_r; // =0..255 LED Red brightness
  uint8_t led_24_g; // =0..255 LED Green brightness
  uint8_t led_24_b; // =0..255 LED Blue brightness
  uint8_t led_25_r; // =0..255 LED Red brightness
  uint8_t led_25_g; // =0..255 LED Green brightness
  uint8_t led_25_b; // =0..255 LED Blue brightness
  uint8_t led_26_r; // =0..255 LED Red brightness
  uint8_t led_26_g; // =0..255 LED Green brightness
  uint8_t led_26_b; // =0..255 LED Blue brightness
  uint8_t led_27_r; // =0..255 LED Red brightness
  uint8_t led_27_g; // =0..255 LED Green brightness
  uint8_t led_27_b; // =0..255 LED Blue brightness
  uint8_t led_28_r; // =0..255 LED Red brightness
  uint8_t led_28_g; // =0..255 LED Green brightness
  uint8_t led_28_b; // =0..255 LED Blue brightness
  uint8_t led_48_r; // =0..255 LED Red brightness
  uint8_t led_48_g; // =0..255 LED Green brightness
  uint8_t led_48_b; // =0..255 LED Blue brightness
  uint8_t led_49_r; // =0..255 LED Red brightness
  uint8_t led_49_g; // =0..255 LED Green brightness
  uint8_t led_49_b; // =0..255 LED Blue brightness
  uint8_t led_50_r; // =0..255 LED Red brightness
  uint8_t led_50_g; // =0..255 LED Green brightness
  uint8_t led_50_b; // =0..255 LED Blue brightness
  uint8_t led_51_r; // =0..255 LED Red brightness
  uint8_t led_51_g; // =0..255 LED Green brightness
  uint8_t led_51_b; // =0..255 LED Blue brightness
  uint8_t led_52_r; // =0..255 LED Red brightness
  uint8_t led_52_g; // =0..255 LED Green brightness
  uint8_t led_52_b; // =0..255 LED Blue brightness
  uint8_t led_53_r; // =0..255 LED Red brightness
  uint8_t led_53_g; // =0..255 LED Green brightness
  uint8_t led_53_b; // =0..255 LED Blue brightness
  uint8_t led_54_r; // =0..255 LED Red brightness
  uint8_t led_54_g; // =0..255 LED Green brightness
  uint8_t led_54_b; // =0..255 LED Blue brightness
  uint8_t led_55_r; // =0..255 LED Red brightness
  uint8_t led_55_g; // =0..255 LED Green brightness
  uint8_t led_55_b; // =0..255 LED Blue brightness
  uint8_t led_56_r; // =0..255 LED Red brightness
  uint8_t led_56_g; // =0..255 LED Green brightness
  uint8_t led_56_b; // =0..255 LED Blue brightness
  uint8_t led_57_r; // =0..255 LED Red brightness
  uint8_t led_57_g; // =0..255 LED Green brightness
  uint8_t led_57_b; // =0..255 LED Blue brightness
  uint8_t led_58_r; // =0..255 LED Red brightness
  uint8_t led_58_g; // =0..255 LED Green brightness
  uint8_t led_58_b; // =0..255 LED Blue brightness
  uint8_t led_59_r; // =0..255 LED Red brightness
  uint8_t led_59_g; // =0..255 LED Green brightness
  uint8_t led_59_b; // =0..255 LED Blue brightness
  uint8_t led_60_r; // =0..255 LED Red brightness
  uint8_t led_60_g; // =0..255 LED Green brightness
  uint8_t led_60_b; // =0..255 LED Blue brightness
  uint8_t led_61_r; // =0..255 LED Red brightness
  uint8_t led_61_g; // =0..255 LED Green brightness
  uint8_t led_61_b; // =0..255 LED Blue brightness
  uint8_t led_62_r; // =0..255 LED Red brightness
  uint8_t led_62_g; // =0..255 LED Green brightness
  uint8_t led_62_b; // =0..255 LED Blue brightness
  uint8_t led_63_r; // =0..255 LED Red brightness
  uint8_t led_63_g; // =0..255 LED Green brightness
  uint8_t led_63_b; // =0..255 LED Blue brightness
  uint8_t led_64_r; // =0..255 LED Red brightness
  uint8_t led_64_g; // =0..255 LED Green brightness
  uint8_t led_64_b; // =0..255 LED Blue brightness
  uint8_t led_65_r; // =0..255 LED Red brightness
  uint8_t led_65_g; // =0..255 LED Green brightness
  uint8_t led_65_b; // =0..255 LED Blue brightness
  uint8_t led_66_r; // =0..255 LED Red brightness
  uint8_t led_66_g; // =0..255 LED Green brightness
  uint8_t led_66_b; // =0..255 LED Blue brightness
  uint8_t led_38_r; // =0..255 LED Red brightness
  uint8_t led_38_g; // =0..255 LED Green brightness
  uint8_t led_38_b; // =0..255 LED Blue brightness
  uint8_t led_39_r; // =0..255 LED Red brightness
  uint8_t led_39_g; // =0..255 LED Green brightness
  uint8_t led_39_b; // =0..255 LED Blue brightness
  uint8_t led_40_r; // =0..255 LED Red brightness
  uint8_t led_40_g; // =0..255 LED Green brightness
  uint8_t led_40_b; // =0..255 LED Blue brightness
  uint8_t led_41_r; // =0..255 LED Red brightness
  uint8_t led_41_g; // =0..255 LED Green brightness
  uint8_t led_41_b; // =0..255 LED Blue brightness
  uint8_t led_42_r; // =0..255 LED Red brightness
  uint8_t led_42_g; // =0..255 LED Green brightness
  uint8_t led_42_b; // =0..255 LED Blue brightness
  uint8_t led_43_r; // =0..255 LED Red brightness
  uint8_t led_43_g; // =0..255 LED Green brightness
  uint8_t led_43_b; // =0..255 LED Blue brightness
  uint8_t led_44_r; // =0..255 LED Red brightness
  uint8_t led_44_g; // =0..255 LED Green brightness
  uint8_t led_44_b; // =0..255 LED Blue brightness
  uint8_t led_45_r; // =0..255 LED Red brightness
  uint8_t led_45_g; // =0..255 LED Green brightness
  uint8_t led_45_b; // =0..255 LED Blue brightness
  uint8_t led_46_r; // =0..255 LED Red brightness
  uint8_t led_46_g; // =0..255 LED Green brightness
  uint8_t led_46_b; // =0..255 LED Blue brightness
  uint8_t led_47_r; // =0..255 LED Red brightness
  uint8_t led_47_g; // =0..255 LED Green brightness
  uint8_t led_47_b; // =0..255 LED Blue brightness

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////



void setup() {
  RemoteXY_Init ();
}



void loop() {
  RemoteXY_Handler ();

  // Row 0
  RemoteXY.led_0_r = random(256);
  RemoteXY.led_0_g = random(256);
  RemoteXY.led_0_b = random(256);
  RemoteXY.led_1_r = random(256);
  RemoteXY.led_1_g = random(256);
  RemoteXY.led_1_b = random(256);
  RemoteXY.led_2_r = random(256);
  RemoteXY.led_2_g = random(256);
  RemoteXY.led_2_b = random(256);
  RemoteXY.led_3_r = random(256);
  RemoteXY.led_3_g = random(256);
  RemoteXY.led_3_b = random(256);
  RemoteXY.led_4_r = random(256);
  RemoteXY.led_4_g = random(256);
  RemoteXY.led_4_b = random(256);
  RemoteXY.led_5_r = random(256);
  RemoteXY.led_5_g = random(256);
  RemoteXY.led_5_b = random(256);
  RemoteXY.led_6_r = random(256);
  RemoteXY.led_6_g = random(256);
  RemoteXY.led_6_b = random(256);
  RemoteXY.led_7_r = random(256);
  RemoteXY.led_7_g = random(256);
  RemoteXY.led_7_b = random(256);
  RemoteXY.led_8_r = random(256);
  RemoteXY.led_8_g = random(256);
  RemoteXY.led_8_b = random(256);
  RemoteXY.led_9_r = random(256);
  RemoteXY.led_9_g = random(256);
  RemoteXY.led_9_b = random(256);

  // Row 2
  RemoteXY.led_19_r = random(256);
  RemoteXY.led_19_g = random(256);
  RemoteXY.led_19_b = random(256);
  RemoteXY.led_20_r = random(256);
  RemoteXY.led_20_g = random(256);
  RemoteXY.led_20_b = random(256);
  RemoteXY.led_21_r = random(256);
  RemoteXY.led_21_g = random(256);
  RemoteXY.led_21_b = random(256);
  RemoteXY.led_22_r = random(256);
  RemoteXY.led_22_g = random(256);
  RemoteXY.led_22_b = random(256);
  RemoteXY.led_23_r = random(256);
  RemoteXY.led_23_g = random(256);
  RemoteXY.led_23_b = random(256);
  RemoteXY.led_24_r = random(256);
  RemoteXY.led_24_g = random(256);
  RemoteXY.led_24_b = random(256);
  RemoteXY.led_25_r = random(256);
  RemoteXY.led_25_g = random(256);
  RemoteXY.led_25_b = random(256);
  RemoteXY.led_26_r = random(256);
  RemoteXY.led_26_g = random(256);
  RemoteXY.led_26_b = random(256);
  RemoteXY.led_27_r = random(256);
  RemoteXY.led_27_g = random(256);
  RemoteXY.led_27_b = random(256);
  RemoteXY.led_28_r = random(256);
  RemoteXY.led_28_g = random(256);
  RemoteXY.led_28_b = random(256);

  // Row 4
  RemoteXY.led_38_r = random(256);
  RemoteXY.led_38_g = random(256);
  RemoteXY.led_38_b = random(256);
  RemoteXY.led_39_r = random(256);
  RemoteXY.led_39_g = random(256);
  RemoteXY.led_39_b = random(256);
  RemoteXY.led_40_r = random(256);
  RemoteXY.led_40_g = random(256);
  RemoteXY.led_40_b = random(256);
  RemoteXY.led_41_r = random(256);
  RemoteXY.led_41_g = random(256);
  RemoteXY.led_41_b = random(256);
  RemoteXY.led_42_r = random(256);
  RemoteXY.led_42_g = random(256);
  RemoteXY.led_42_b = random(256);
  RemoteXY.led_43_r = random(256);
  RemoteXY.led_43_g = random(256);
  RemoteXY.led_43_b = random(256);
  RemoteXY.led_44_r = random(256);
  RemoteXY.led_44_g = random(256);
  RemoteXY.led_44_b = random(256);
  RemoteXY.led_45_r = random(256);
  RemoteXY.led_45_g = random(256);
  RemoteXY.led_45_b = random(256);
  RemoteXY.led_46_r = random(256);
  RemoteXY.led_46_g = random(256);
  RemoteXY.led_46_b = random(256);
  RemoteXY.led_47_r = random(256);
  RemoteXY.led_47_g = random(256);
  RemoteXY.led_47_b = random(256);

  // Row 6
  RemoteXY.led_57_r = random(256);
  RemoteXY.led_57_g = random(256);
  RemoteXY.led_57_b = random(256);
  RemoteXY.led_58_r = random(256);
  RemoteXY.led_58_g = random(256);
  RemoteXY.led_58_b = random(256);
  RemoteXY.led_59_r = random(256);
  RemoteXY.led_59_g = random(256);
  RemoteXY.led_59_b = random(256);
  RemoteXY.led_60_r = random(256);
  RemoteXY.led_60_g = random(256);
  RemoteXY.led_60_b = random(256);
  RemoteXY.led_61_r = random(256);
  RemoteXY.led_61_g = random(256);
  RemoteXY.led_61_b = random(256);
  RemoteXY.led_62_r = random(256);
  RemoteXY.led_62_g = random(256);
  RemoteXY.led_62_b = random(256);
  RemoteXY.led_63_r = random(256);
  RemoteXY.led_63_g = random(256);
  RemoteXY.led_63_b = random(256);
  RemoteXY.led_64_r = random(256);
  RemoteXY.led_64_g = random(256);
  RemoteXY.led_64_b = random(256);
  RemoteXY.led_65_r = random(256);
  RemoteXY.led_65_g = random(256);
  RemoteXY.led_65_b = random(256);
  RemoteXY.led_66_r = random(256);
  RemoteXY.led_66_g = random(256);
  RemoteXY.led_66_b = random(256);

  // Row 1 - reversed order
  RemoteXY.led_18_r = random(256);
  RemoteXY.led_18_g = random(256);
  RemoteXY.led_18_b = random(256);
  RemoteXY.led_17_r = random(256);
  RemoteXY.led_17_g = random(256);
  RemoteXY.led_17_b = random(256);
  RemoteXY.led_16_r = random(256);
  RemoteXY.led_16_g = random(256);
  RemoteXY.led_16_b = random(256);
  RemoteXY.led_15_r = random(256);
  RemoteXY.led_15_g = random(256);
  RemoteXY.led_15_b = random(256);
  RemoteXY.led_14_r = random(256);
  RemoteXY.led_14_g = random(256);
  RemoteXY.led_14_b = random(256);
  RemoteXY.led_13_r = random(256);
  RemoteXY.led_13_g = random(256);
  RemoteXY.led_13_b = random(256);
  RemoteXY.led_12_r = random(256);
  RemoteXY.led_12_g = random(256);
  RemoteXY.led_12_b = random(256);
  RemoteXY.led_11_r = random(256);
  RemoteXY.led_11_g = random(256);
  RemoteXY.led_11_b = random(256);
  RemoteXY.led_10_r = random(256);
  RemoteXY.led_10_g = random(256);
  RemoteXY.led_10_b = random(256);

  // Row 3 - reversed order
  RemoteXY.led_37_r = random(256);
  RemoteXY.led_37_g = random(256);
  RemoteXY.led_37_b = random(256);
  RemoteXY.led_36_r = random(256);
  RemoteXY.led_36_g = random(256);
  RemoteXY.led_36_b = random(256);
  RemoteXY.led_35_r = random(256);
  RemoteXY.led_35_g = random(256);
  RemoteXY.led_35_b = random(256);
  RemoteXY.led_34_r = random(256);
  RemoteXY.led_34_g = random(256);
  RemoteXY.led_34_b = random(256);
  RemoteXY.led_33_r = random(256);
  RemoteXY.led_33_g = random(256);
  RemoteXY.led_33_b = random(256);
  RemoteXY.led_32_r = random(256);
  RemoteXY.led_32_g = random(256);
  RemoteXY.led_32_b = random(256);
  RemoteXY.led_31_r = random(256);
  RemoteXY.led_31_g = random(256);
  RemoteXY.led_31_b = random(256);
  RemoteXY.led_30_r = random(256);
  RemoteXY.led_30_g = random(256);
  RemoteXY.led_30_b = random(256);
  RemoteXY.led_29_r = random(256);
  RemoteXY.led_29_g = random(256);
  RemoteXY.led_29_b = random(256);

  // Row 5 - reversed order
  RemoteXY.led_56_r = random(256);
  RemoteXY.led_56_g = random(256);
  RemoteXY.led_56_b = random(256);
  RemoteXY.led_55_r = random(256);
  RemoteXY.led_55_g = random(256);
  RemoteXY.led_55_b = random(256);
  RemoteXY.led_54_r = random(256);
  RemoteXY.led_54_g = random(256);
  RemoteXY.led_54_b = random(256);
  RemoteXY.led_53_r = random(256);
  RemoteXY.led_53_g = random(256);
  RemoteXY.led_53_b = random(256);
  RemoteXY.led_52_r = random(256);
  RemoteXY.led_52_g = random(256);
  RemoteXY.led_52_b = random(256);
  RemoteXY.led_51_r = random(256);
  RemoteXY.led_51_g = random(256);
  RemoteXY.led_51_b = random(256);
  RemoteXY.led_50_r = random(256);
  RemoteXY.led_50_g = random(256);
  RemoteXY.led_50_b = random(256);
  RemoteXY.led_49_r = random(256);
  RemoteXY.led_49_g = random(256);
  RemoteXY.led_49_b = random(256);
  RemoteXY.led_48_r = random(256);
  RemoteXY.led_48_g = random(256);
  RemoteXY.led_48_b = random(256);
}
"And voila, which is French for.......'and then I found out.'"

2

Re: Random RGB Matrix

Nice!

All variables are located in memory one after another. You can get a reference to the first variable and use all variables as an array. This is possible in C ++

  uint8_t * leds = (uint8_t *)(&RemoteXY.led_10_r);
  for (int i = 0; i<30; i++) leds[i]=255;

Second option. You can replace all consecutive variables of the same type with an array. But this must be done carefully so that the length of the array strictly corresponds to the number of replaced variables.

/*
struct {

  // output variables
  uint8_t led_10_r; // =0..255 LED Red brightness
  uint8_t led_10_g; // =0..255 LED Green brightness
  uint8_t led_10_b; // =0..255 LED Blue brightness
  uint8_t led_11_r; // =0..255 LED Red brightness
  uint8_t led_11_g; // =0..255 LED Green brightness
  uint8_t led_11_b; // =0..255 LED Blue brightness
  uint8_t led_12_r; // =0..255 LED Red brightness
  uint8_t led_12_g; // =0..255 LED Green brightness
  uint8_t led_12_b; // =0..255 LED Blue brightness
  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
*/

// updated structure
struct {

  // output variables
  uint8_t leds[9]; 

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;

void setup()  {
  RemoteXY_Init ();
  for (int i = 0; i<9; i++) RemoteXY.leds[i]=255;
}

3 (edited by Gunner 2021-07-04 04:30:05)

Re: Random RGB Matrix

Thanks for the clear examples... I was able to learn me some more array stuffs tongue

And that really cleaned up the code...

/*
   -- LED Matrix --

   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.4.3 or later version
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
     - for ANDROID 4.7.12 or later version;
     - for iOS 1.4.7 or later version;

   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RGB Matrix"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,201,0,149,1,11,8,0,
  65,7,5,12,9,9,65,7,15,12,
  9,9,65,7,25,12,9,9,65,7,
  35,12,9,9,65,7,45,12,9,9,
  65,7,55,12,9,9,65,7,65,12,
  9,9,65,7,75,12,9,9,65,7,
  85,12,9,9,65,7,10,4,9,9,
  65,7,20,4,9,9,65,7,30,4,
  9,9,65,7,40,4,9,9,65,7,
  50,4,9,9,65,7,60,4,9,9,
  65,7,70,4,9,9,65,7,80,4,
  9,9,65,7,90,4,9,9,65,7,
  0,4,9,9,65,7,5,28,9,9,
  65,7,15,28,9,9,65,7,25,28,
  9,9,65,7,35,28,9,9,65,7,
  45,28,9,9,65,7,55,28,9,9,
  65,7,65,28,9,9,65,7,75,28,
  9,9,65,7,85,28,9,9,65,7,
  0,20,9,9,65,7,10,20,9,9,
  65,7,20,20,9,9,65,7,30,20,
  9,9,65,7,40,20,9,9,65,7,
  50,20,9,9,65,7,60,20,9,9,
  65,7,70,20,9,9,65,7,80,20,
  9,9,65,7,90,20,9,9,65,7,
  5,44,9,9,65,7,15,44,9,9,
  65,7,25,44,9,9,65,7,35,44,
  9,9,65,7,45,44,9,9,65,7,
  55,44,9,9,65,7,65,44,9,9,
  65,7,75,44,9,9,65,7,85,44,
  9,9,65,7,0,52,9,9,65,7,
  10,52,9,9,65,7,20,52,9,9,
  65,7,30,52,9,9,65,7,40,52,
  9,9,65,7,50,52,9,9,65,7,
  60,52,9,9,65,7,70,52,9,9,
  65,7,80,52,9,9,65,7,90,52,
  9,9,65,7,0,36,9,9,65,7,
  10,36,9,9,65,7,20,36,9,9,
  65,7,30,36,9,9,65,7,40,36,
  9,9,65,7,50,36,9,9,65,7,
  60,36,9,9,65,7,70,36,9,9,
  65,7,80,36,9,9,65,7,90,36,
  9,9 };

// this structure defines all the variables and events of your control interface
struct {
  // output variables
  uint8_t RGBLED[201]; // Total number of LED element references.  Eg. 67 LED elements each with Red, Green, Blue variables
} RemoteXY;

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////



void setup() {
  randomSeed(analogRead(0));
  RemoteXY_Init ();
}



void loop() {
  RemoteXY_Handler ();
  RemoteXY.RGBLED[random(202)] = random(256);  // Pick an LED variable from 0-201 and apply value 0-255
}
"And voila, which is French for.......'and then I found out.'"