1 (edited by Guillaume 2017-03-02 01:22:08)

Topic: Manual modification of the array

  • This information is for RemoteXY library version 2.2.5, it may not work in future versions.

  • Please read 2 or 3 times before asking questions.



Full description of the array:

The array is made of an header, followed by Elements, sorted by category :

CONF =
{
  HEADER,
  INPUTS,
  OUTPUTS,
  DECORATIONS
}

Legend:

HF : Header Flags
SO : Screen Orientation
PE : Pages Enabled

 
Header:

The array starts with 7 bytes that forms the header:

Header bytes :  A  B  C  D  E  F  G
Default value : 0, 0, 3, 0, 6, 5, 0

A   : Total bytes used by inputs in the struct, see an input's decription below for details
B   : Total bytes used by outputs in the struct, see an output's decription below for details
C-D : 16 bits number (C is the low byte, D is the high byte).
      This number is the size of the array minus 4 (number of bytes after D until the end of the array).
      In a new empty project, there is only the header in the array, so there are 3 bytes after D, so C-D = 3
E   : ? Array version ? Doesn't seem to change.
F   : Background Color2
G   : HF Bits
        0-1 : SO ( 0b00 = landscape, 0b01 = portrait, 0b10 = both )
        2   : PE ( 0 = no, 1 = yes ). Set this bit to 1 if you use one or more Page elements.
      Example : 0b00000101 (5) : pages enabled = yes, screen orientation = portrait

A, B and C-D must be increased according to each Element you add in the array. See below each Element's description for details.



Elements:

The value of HF defines how much bytes an Element will add in the array:

  • If SO = 0b10 (both), then 4 additional bytes, X2, Y2, W2 and H2, are required by an Element, after the H1 byte, to set the position and size for the Portrait orientation.

  • If PE = 1, then 1 additional byte, P, is required by an Element, after the Color byte, to set the page ID this Element must be attached to. Setting this byte to 0 will show the Element on all Pages.


The code boxes below describes each byte of each Element. The values shown are the default values when adding the Element in the top left corner.


General information and legend:

  • T : Type of the Element (Button = 1, LED = 65, Panel = 130, etc)

  • F : Flags

  • If SO = Landscape OR Portrait :
      X1, Y1, W1, H1 are values for the choosen orientation (obviously)
      X2, Y2, W2, H2 must not exist!
    else if SO = Both :
      X1, Y1, W1, H1 are values for the landscape orientation
      X2, Y2, W2, H2 are values for the portrait orientation

  • X1,X2 : position of the left edge of the Element :
    Landscape: 0 (left) to 100 (right), can be set to < 0 or > 100 for moving outside of editor's screen.
    Portrait:  0 (left) to 63  (right), can be set to < 0 or >  63 for moving outside of editor's screen.

  • Y1,Y2 : position of the top edge of the Element :
    Landscape : 0  (top) to  63 (bottom), can be set to < 0 or >  63 for moving outside of editor's screen.
    Portrait: 0  (top) to 100 (bottom), can be set to < 0 or > 100 for moving outside of editor's screen.

  • W1,W2 : width of the Element

  • H1,H2 : height of the Element

  • C : Color1:https://i.solidfiles.com/62MLQYA5qpk6Z.png Color2:https://i.solidfiles.com/Wwj5YM63qkgeq.png

  • P : PageID of the corresponding Page Element, or set to 0 to show on all Pages.
    This byte must not exist if PE = 0.




Inputs

BUTTON

HF VALUE            ELEMENT BYTES                                LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  x...  
0b000 or 0b001      1, 0, 0, 0,12,12,             2,   88, 0     7 + n
0b100 or 0b101      1, 0, 0, 0,12,12,             2, 0,88, 0     8 + n
0b010               1, 0, 0, 0,12,12, 0, 0,12,12, 2,   88, 0     11 + n
0b110               1, 0, 0, 0,12,12, 0, 0,12,12, 2, 0,88, 0     12 + n

n : Length of the caption string, including null character.
F : Bits
      0 : shape ( 0 = round, 1 = rectangular )
    Example : 0b00000001 (1) : shape = rectangular
C : Color1
x : Caption (null-terminated ASCII string)

Header bytes :                 A  B  C  D  E  F  G
Default value :                0, 0, 3, 0, 6, 5, 0
After adding default Button:   1, 0,12, 0, 6, 5, 0
A += 1 : requires one input variable
C += 9 : HF = 0b000, so Length = 7 + 2 characters ("X\0")

SWITCH

HF VALUE            ELEMENT BYTES                                               LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  x..................
0b000 or 0b001      2, 0, 0, 0,22,11,             2,   79,78, 0,79,70,70, 0     7 + n
0b100 or 0b101      2, 0, 0, 0,22,11,             2, 0,79,78, 0,79,70,70, 0     8 + n
0b010               2, 0, 0, 0,22,11, 0, 0,22,11, 2,   79,78, 0,79,70,70, 0     11 + n
0b110               2, 0, 0, 0,22,11, 0, 0,22,11, 2, 0,79,78, 0,79,70,70, 0     12 + n

n : Length of both captions strings including both null characters.
F : Unused, always = 0
C : Color1
x : Caption ON and Caption OFF (null-terminated ASCII strings)

Header bytes :                 A  B  C  D  E  F  G
Default value :                0, 0, 3, 0, 6, 5, 0
After adding default Switch:   1, 0,17, 0, 6, 5, 0
A += 1  : requires one input variable
C += 14 : HF = 0b000, so Length = 7 + 7 characters ("ON\0OFF\0")

SELECT

HF VALUE            ELEMENT BYTES                          LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001      3, 3, 0, 0, 8,22,             2        7
0b100 or 0b101      3, 3, 0, 0, 8,22,             2, 0     8
0b010               3, 3, 0, 0, 8,22, 0, 0, 8,22, 2        11
0b110               3, 3, 0, 0, 8,22, 0, 0, 8,22, 2, 0     12

F : Bit
      0-3 : count of positions (ex: 0b0101 = 5)
      7   : orientation ( 0 = vertical, 1 = horizontal )
    Example: 0b10000101 (133) : orientation = horizontal, positions = 5
C : Color1

Header bytes :                 A  B  C  D  E  F  G
Default value :                0, 0, 3, 0, 6, 5, 0
After adding default Select:   1, 0,10, 0, 6, 5, 0
A += 1 : requires one input variable
C += 7 : HF = 0b000, so Length = 7

SLIDER

HF VALUE             ELEMENT BYTES                          LENGTH
                     T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001       4, 0, 0, 0, 7,18,             2        7
0b100 or 0b101       4, 0, 0, 0, 7,18,             2, 0     8
0b010                4, 0, 0, 0, 7,18, 0, 0, 7,18, 2        11
0b110                4, 0, 0, 0, 7,18, 0, 0, 7,18, 2, 0     12

F : Bit
      4   : automatically center ( 0 = disabled, 1 = enabled )
      5-6 : slider center pos 00 = bottom, 01 = middle, 10 = top
      7   : orientation ( 0 = vertical, 1 = horizontal )
    Example: 0b11010000 (208) : orientation = horizontal, center pos = top, auto center = enabled
C : Color1

Header bytes :                 A  B  C  D  E  F  G
Default value :                0, 0, 3, 0, 6, 5, 0
After adding default Slider:   1, 0,10, 0, 6, 5, 0
A += 1 : requires one input variable
C += 7 : HF = 0b000, so Length = 7

JOYSTICK

HF VALUE            ELEMENT BYTES                            LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001      5, 0, 0, 0,30,30,             2          7
0b100 or 0b101      5, 0, 0, 0,30,30,             2, 0       8
0b010               5, 0, 0, 0,30,30, 0, 0,30,30, 2          11
0b110               5, 0, 0, 0,30,30, 0, 0,30,30, 2, 0       12

F : Bit
      0-4 : center button and g-sensor button's positions:
              center   : hide = 0, TR = 1, BR =  2, BL =  3, TL =  4
              g-sensor : hide = 0, TR = 5, BR = 10, BL = 15, TL = 20
              value = CB + GSB, example : (CB = BR = 2) + (GSB = TL = 20) = 22
      5   : automatically center ( 0 = disabled, 1 = enabled )
    Example : 0b00101011 (43) : auto center = enabled, center button pos = TR, g-sensor button pos = BR
C : Color1

Header bytes :                 A  B  C  D  E  F  G
Default value :                0, 0, 3, 0, 6, 5, 0
After adding default Joystick: 2, 0,10, 0, 6, 5, 0
A += 2 : requires 2 inputs variables (X and Y)
C += 7 : HF = 0b000, so Length = 7

COLOR PICKER

HF VALUE            ELEMENT BYTES                            LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001      6, 0, 0, 0,20,20,             2          7
0b100 or 0b101      6, 0, 0, 0,20,20,             2, 0       8
0b010               6, 0, 0, 0,20,20, 0, 0,20,20, 2          11
0b110               6, 0, 0, 0,20,20, 0, 0,20,20, 2, 0       12

F : Unused, always = 0
C : Color1

Header bytes :                      A  B  C  D  E  F  G
Default value :                     0, 0, 3, 0, 6, 5, 0
After adding default Color Picker : 3, 0,10, 0, 6, 5, 0
A += 3 : requires 3 inputs variables (R, G, B)
C += 7 : HF = 0b000, so Length = 7

EDIT FIELD

HF VALUE            ELEMENT BYTES                             LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  x
0b000 or 0b001      7,36, 0, 0,20, 5,             2,   11     7 or 8*
0b100 or 0b101      7,36, 0, 0,20, 5,             2, 0,11     8 or 9*
0b010               7,36, 0, 0,20, 5, 0, 0,20, 5, 2,   11     11 or 12*
0b110               7,36, 0, 0,20, 5, 0, 0,20, 5, 2, 0,11     12 or 13*
   
* Depending on Input type (see F and x below)

F : Bit
      0-1 : Align ( 0b00 = left, 0b01 = center, 0b10 = right )
      2   : Background ( 0 = hide, 1 = show )
      3-4 : Input type ( 0b00 = string, 0b01 = float, 0b10 = integer )
      5   : Clear button ( 0 = hide, 1 = show )
    Example : 0b00001101 (13) : clear button = hide, type = float, background = show, align = center
C : Color1
x : Only required if Input type is String or Float. If type is Integer, do not put this byte in the array.
      If type is String, this byte is the max text length.
      If type is Float, it's the amount of decimals :
        0 = not limited
        1..7 = n-1 decimals, example : 3 = 2 decimals
        
Header bytes :                    A  B  C  D  E  F  G
Default value :                   0, 0, 3, 0, 6, 5, 0
After adding default Edit Field: 11, 0,11, 0, 6, 5, 0
A += 11 : requires 11 characters
C +=  8 : HF = 0b000, Input Type = String, so Length = 8



Outputs:

LED

HF VALUE            ELEMENT BYTES                            LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001     65, 4, 0, 0, 9, 9,             2          7
0b100 or 0b101     65, 4, 0, 0, 9, 9,             2, 0       8
0b010              65, 4, 0, 0, 9, 9, 0, 0, 9, 9, 2          11
0b110              65, 4, 0, 0, 9, 9, 0, 0, 9, 9, 2, 0       12

F : Bit
      0-2 : BGR color channels ( 0 = channel disabled, 1 = channel enabled )
      3   : Shape ( 0 = round, 1 = rectangular )
    Example : 0b00001100 (12) : shape = rectangular, color = red
H1 : if shape = round, this byte should have the same value than W1 )
H2 : if shape = round, this byte should have the same value than W2 )
C : Unused, always = 2

Header bytes :            A  B  C  D  E  F  G
Default value :           0, 0, 3, 0, 6, 5, 0
After adding default LED: 0, 1,10, 0, 6, 5, 0
B += 1 : requires one output per R,G,B channel: default LED is red only, so one output is required.
C += 7 : HF = 0b000, so Length = 7

LEVELS

HF VALUE            ELEMENT BYTES                            LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001     66, 1, 0, 0, 7,16,             2          7
0b100 or 0b101     66, 1, 0, 0, 7,16,             2, 0       8
0b010              66, 1, 0, 0, 7,16, 0, 0, 7,16, 2          11
0b110              66, 1, 0, 0, 7,16, 0, 0, 7,16, 2, 0       12

F : Bit
      0-2 : Type ( 0b001 = linear, 0b010 = arc, 0b011 = linear division, 0b100 = arc division )
      5-6 : Center pos ( 0b00 = left/bottom, 0b01 = middle, 0b10 = right/top )
      7   : Orientation ( 0 = vertical, 1 = horizontal )
    Example : 0b00100010 (34) : type = arc level, orientation = vertical, center pos = middle
C : Color1

Header bytes :                      A  B  C  D  E  F  G
Default value :                     0, 0, 3, 0, 6, 5, 0
After adding default Linear Level : 0, 1,10, 0, 6, 5, 0
B += 1 : requires one output.
C += 7 : HF = 0b000, so Length = 7

TEXT STRING

HF VALUE            ELEMENT BYTES                              LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  L
0b000 or 0b001     67, 4, 0, 0,20, 5,             2,   11      8
0b100 or 0b101     67, 4, 0, 0,20, 5,             2, 0,11      9
0b010              67, 4, 0, 0,20, 5, 0, 0,20, 5, 2,   11      12
0b110              67, 4, 0, 0,20, 5, 0, 0,20, 5, 2, 0,11      13

F : Bit
      0-1 : Align ( 0b00 = left, 0b01 = center, 0b10 = right )
      2   : Background ( 0 = hide, 1 = show )
    Example : 0b00000110 (34) : background = show, align = right
C : Color1
L : Max string length

Header bytes :                     A  B  C  D  E  F  G
Default value :                    0, 0, 3, 0, 6, 5, 0
After adding default Text String : 0,11,11, 0, 6, 5, 0
B += 11 : the max text lenght is 10, so 11 for null at the end of string.
C += 8  : HF = 0b000, so Length = 8



Decoration:

LABEL

HF VALUE            ELEMENT BYTES                                              LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  x.................
0b000 or 0b001    129, 0, 0, 0,18, 6,             9,   76,97,98,101,108, 0     7 + n
0b100 or 0b101    129, 0, 0, 0,18, 6,             9, 0,76,97,98,101,108, 0     8 + n
0b010             129, 0, 0, 0,18, 6, 0, 0,18, 6, 9,   76,97,98,101,108, 0     11 + n
0b110             129, 0, 0, 0,18, 6, 0, 0,18, 6, 9, 0,76,97,98,101,108, 0     12 + n

n : Length of the label string, including null character.
F : Unused, always = 0
C : Color2
x : Text (null-terminated ASCII strings)

Header bytes :               A  B  C  D  E  F  G
Default value :              0, 0, 3, 0, 6, 5, 0
After adding default Label : 0, 0,16, 0, 6, 5, 0
C += 13 : HF = 0b000, so Length = 7 + 6 characters ("Label\0")

PANEL

HF VALUE            ELEMENT BYTES                           LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P
0b000 or 0b001    130, 1, 0, 0,20,20,             9         7
0b100 or 0b101    130, 1, 0, 0,20,20,             9, 0      8
0b010             130, 1, 0, 0,20,20, 0, 0,20,20, 9         11
0b110             130, 1, 0, 0,20,20, 0, 0,20,20, 9, 0      12

F : Bit
      0-2 : bevel cut( 0b00 = linear, 0b01 = raised, 0b10 = lowered )
    Example 0b00000010 (2) : bevel cut = lowered
C : Color2

Header bytes :               A  B  C  D  E  F  G
Default value :              0, 0, 3, 0, 6, 5, 0
After adding default Panel : 0, 0,10, 0, 6, 5, 0
C += 7 : HF = 0b000, so Length = 7

PAGE

HF VALUE            ELEMENT BYTES                                          LENGTH
                    T  F X1 Y1 W1 H1 X2 Y2 W2 H2  C  P  x.............
0b100 or 0b101    131, 1, 0, 0,20, 7,             2, 1,80,97,103,101,0     8 + n
0b110             131, 1, 0, 0,20, 7, 0, 0,20, 7, 2, 1,80,97,103,101,0     12 + n

n : Length of the Page name string, including null character.
F : Bit
      0 : main page ( 0 = no, 1 = yes ) (only one page can be the main page!)
    Example : 0b00000001 (1) : main page = yes
C : Color1
P : Page ID, starts at 1, must be increased for each page
x : Page name (null-terminated ASCII strings)

Header bytes :              A  B  C  D  E  F  G
Default value :             0, 0, 3, 0, 6, 5, 0
After adding default Page : 0, 0,16, 0, 6, 5, 4
C += 13 : After adding the Page Element, HF = 0b100, so Length = 8 + 5 characters ("Page\0")
G = HF = 0b100 = 4




How to manually modify or create the array?

Editing the array and struct in the code can be much faster than building with the editor! So how do we do that?


First, let's take a look at an example project. With the Editor, I added a few Elements randomly to an empty new project, in this order:

  • Button

  • Switch

  • LED

  • Linear Level

  • Another Button

  • Another Switch


This is the generated code

uint8_t RemoteXY_CONF[] =
  { 4,2,63,0,6,5,0,1,0,4
  ,4,12,12,2,88,0,2,0,21,4
  ,22,11,2,79,78,0,79,70,70,0
  ,1,0,79,3,12,12,2,88,0,2
  ,0,4,23,22,11,2,79,78,0,79
  ,70,70,0,65,4,50,5,9,9,2
  ,66,1,65,3,7,16,2 };
  
// this structure defines all the variables of your control interface 
struct {

    // input variable
  uint8_t button_1; // =1 if button pressed, else =0 
  uint8_t switch_1; // =1 if switch ON and =0 if OFF 
  uint8_t button_2; // =1 if button pressed, else =0 
  uint8_t switch_2; // =1 if switch ON and =0 if OFF 

    // output variable
  uint8_t led_1_r; // =0..255 LED Red brightness 
  int8_t level_1; // =0..100 level position 

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

} RemoteXY;

Now let's split the array according to what we have learned previously wink

uint8_t RemoteXY_CONF[] =
{
    // header is 7 bytes
    // byte G (last byte) = 0, so HF = 0b000 
    4,2,63,0,6,5,0,

    // inputs:
    1,0,4,4,12,12,2,88,0, // button_1
    2,0,21,4,22,11,2,79,78,0,79,70,70,0, //switch_1
    1,0,79,3,12,12,2,88,0, // button_2
    2,0,4,23,22,11,2,79,78,0,79,70,70,0, //switch_2

    // outputs:
    65,4,50,5,9,9,2, // led_1
    66,1,65,3,7,16,2 // level_1
};

Notice how when the Editor generated this array and struct, the elements were sorted by category, but not by type (button_2 is after switch_1).


Why header bytes A, B and C-D = 4,2,63,0 ? Well, let's do some simple additions... The initial value of C is always 3, and the value of HF in this example, is 0b000. So:

  • Each Button takes one input and 9 bytes:
    A +=  2 = 2
    C += 18 = 21

  • Each Switch takes one input and 14 bytes:
    A +=  2 = 4
    C += 28 = 49

  • The LED takes one output and 7 bytes:
    B +=  1 = 1
    C +=  7 = 56

  • The Level takes one output and 7 bytes:
    B +=  1 = 2
    C +=  7 = 63

Nice, we have calculated our A, B, and C-D values!


We can rearrange the Elements by type, by moving their lines where we want, in both the array and the struct:

uint8_t RemoteXY_CONF[] =
{
    // Header:
    4,2,63,0,6,5,0,

    // Inputs:
    // Buttons
    1,0, 4,4,12,12,2,88,0, // button_1
    1,0,79,3,12,12,2,88,0, // button_2 
    // Switches
    2,0,21,4,22,11,2,79,78,0,79,70,70,0, // switch_1
    2,0,4,23,22,11,2,79,78,0,79,70,70,0, // switch_2

    // Outputs:
    // LEDs
    65,4,50,5,9,9,2, // led_1
    // Levels
    66,1,65,3,7,16,2 // level_1
};

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

  // Inputs:
  // Buttons
  uint8_t button_1; // =1 if button pressed, else =0 
  uint8_t button_2; // =1 if button pressed, else =0 
  // Switches
  uint8_t switch_1; // =1 if switch ON and =0 if OFF
  uint8_t switch_2; // =1 if switch ON and =0 if OFF 

  // Outputs:
  // LEDs
  uint8_t led_1_r; // =0..255 LED Red brightness
  // Levels
  int8_t level_1; // =0..100 level position

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

} RemoteXY;

Why rearrange elements by type? Not only because it looks nicer. It allows to simplify your code by using arrays (with some limitations) in the struct:

struct {

  // Inputs:
  uint8_t buttons[2]; // =1 if button pressed, else =0 
  uint8_t switches[2]; // =1 if switch ON and =0 if OFF

  // Outputs:
  uint8_t led_1_r; // =0..255 LED Red brightness
  int8_t  level_1; // =0..100 level position

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

} RemoteXY;


Have fun wink

2

Re: Manual modification of the array

- Reserved -

More to come, maybe smile

3

Re: Manual modification of the array

Great investigative work, Guillaume, but I can't see how the colour numbers relate to the palette colours.

And it would be great to know the R,G,B values for those palette colours as well, just in case we need to "hide" things.

Everything works with smoke - if you let it out, things stop working....

4

Re: Manual modification of the array

Hello and thanks! Yes, some things have changed in RemoteXY, since I wrote this. I will eventually update this topic some day but I'm lazy... ^^

5

Re: Manual modification of the array

I would not say "lazy", just "busy doing other things."

I am currently finishing off a spreadsheet which gives the RGB values of the pre-defined 256 colours. Something that might be useful to some people.

For example, I tried to "hide" some things with a panel in front of the object I wanted to hide, but then discovered that a panel has to have a border. Then I realised I could use a borderless LED indicator in front, but then the choice of RGB values for the LED was a nightmare.  The application has a "collection" of 256 colours, but an LED can be driven to 16,777,216 colours  !!

For me, I will be extracting the "back_colour" from the header, and I will write code to return the LED r,g,b values of that colour. It is going to need an array of 256 * 3 bytes, but the overhead may be worth it.  I'll post the whole array when I have completed it.

So far my experience with RemoteXY has been extremely postive, and inevitably work-arounds will be needed.

A lot of "messing about" could be removed if things could have a "visibilty" tag (default to "yes") that the sketch can turn off when it needs to.

There is so much that "could" be done to make RemoteXY a far better product, but so far I am finding it streets ahead of other interfaces.  Blynk didn't get off the ground for me, needing either an internet connection, or a local server, and who wants to take that with them when they go fishing .....

Everything works with smoke - if you let it out, things stop working....

6 (edited by Daba 2018-05-11 16:12:38)

Re: Manual modification of the array

Daba wrote:

...... I will be extracting the "back_colour" from the header (No, you can't read values from that array, for some reason and I will write code to return the LED r,g,b values of that colour. It is going to need an array of 256 * 3 bytes, but the overhead may be worth it.  I'll post the whole array when I have completed it.

// This array contains the RGB values for all of the 256
// palette colours used by RemoteXY

// Use an index of Colour Number * 3, for the Red, and the
// next two successive bytes are the Green and Blue values.

// eg. RemoteXY_CONF[8] = 178 in this project, so....
// Red = RemoteXY_COLOURS[RemoteXY_CONF[8]*3]
// Grn = RemoteXY_COLOURS[RemoteXY_CONF[8]*3+1]  
// Blu = RemoteXY_COLOURS[RemoteXY_CONF[8]*3+2]  

// THE ABOVE DOES NOT COMPILE - I ASSUME RemoteXY_CONF[] ARRAY IS NOT ACCESSIBLE

[u][b]ARRAY DELETED DUE TO AN ERROR - SEE LATER POST FOR CORRECTED ARRAY TO GO HERE[/b][/u]

You can use it like this...

      get_LED_RGB(colour);
      RemoteXY.valid_r = red;
      RemoteXY.valid_g = grn;
      RemoteXY.valid_b = blu;

and here's the void

// Get the RGB values for an LED from the palette colour number

void get_LED_RGB(uint8_t col) {
  int index = col*3;
  red = RemoteXY_COLOURS[index];
  grn = RemoteXY_COLOURS[index + 1];  
  blu = RemoteXY_COLOURS[index + 2];  
}

red, grn, and blu are declared as global uint8_t variables.

Everything works with smoke - if you let it out, things stop working....

7

Re: Manual modification of the array

The order of the colors seems wrong in your array, color with id 0 is grey 174,174,174.

Why not use a multi dimensional array, or an array of simple color structs ? Something like this:

struct remoteXyColor { uint8_t r, g, b; };

remoteXyColor remoteXyColors[] =
{
    { 174, 174, 174 },
    ...
};

...

uint8_t r = remoteXyColors[ RemoteXY_CONF[8] ].r;
...

8

Re: Manual modification of the array

Yes, you are right, Guillaume, I had "Assumed" they were numbered sequentially on the pallette. Stupid of me.

I'll get the order fixed and repost over the weekend.

And I didn't bother with multidimensional arrasys or structs, because the whole array was auto-generated from Excel spreadsheet.

Incidentally, on my project, colour 178 IS the exact colour of my background, so when I colour a borderless LED that colour, using my r,g,b indexing, it is correct.

Everything works with smoke - if you let it out, things stop working....

9

Re: Manual modification of the array

Yes, the colour number order of the first palette is strange....

16,17,18,19,20,21,22,23
 0, 1, 2, 3, 4, 5, 6, 7
 8, 9,10,11,12,13,14,15
16,17,18,19,20,21,22,23

The second larger palette looks OK, 32 to 255 sequentially left-to-right, and down

I'll fix the array data, and repost it.....

Everything works with smoke - if you let it out, things stop working....

10 (edited by Daba 2018-05-12 12:44:48)

Re: Manual modification of the array

Here is the corrected array......

uint8_t RemoteXY_COLOURS[] = 
{ 174, 174, 174, 237, 17, 17, 255, 141, 32, 223, 229, 47, 
124, 178, 100, 109, 156, 212, 29, 29, 205, 173, 104, 158, 
41, 41, 41, 155, 59, 59, 206, 150, 0, 178, 180, 0, 
28, 130, 0, 1, 154, 145, 72, 86, 174, 154, 1, 127, 
242, 242, 242, 255, 199, 144, 255, 224, 224, 254, 255, 174, 
192, 255, 187, 187, 255, 243, 211, 196, 255, 253, 209, 250, 
0, 0, 0, 36, 36, 36, 72, 72, 72, 108, 108, 108, 
145, 145, 145, 182, 182, 182, 218, 218, 218, 255, 255, 255, 
63, 0, 0, 112, 0, 0, 160, 0, 0, 209, 0, 0, 
255, 0, 0, 255, 43, 43, 255, 86, 86, 255, 130, 130, 
255, 173, 173, 255, 216, 216, 226, 174, 174, 199, 137, 137, 
173, 113, 113, 139, 88, 88, 76, 19, 0, 122, 30, 0, 
168, 42, 0, 214, 53, 0, 255, 63, 0, 255, 96, 43, 
255, 128, 86, 255, 161, 130, 255, 193, 173, 255, 226, 216, 
230, 188, 173, 200, 152, 136, 174, 130, 115, 137, 101, 89, 
63, 31, 0, 112, 56, 0, 160, 80, 0, 209, 104, 0, 
255, 127, 0, 255, 149, 43, 255, 170, 86, 255, 192, 130, 
255, 214, 173, 255, 235, 216, 228, 199, 172, 197, 165, 134, 
171, 142, 115, 139, 113, 89, 51, 38, 0, 102, 76, 0, 
153, 114, 0, 204, 153, 0, 255, 191, 0, 255, 202, 43, 
255, 212, 86, 255, 223, 130, 255, 234, 173, 255, 245, 216, 
234, 219, 175, 198, 182, 137, 170, 156, 114, 136, 123, 86, 
51, 38, 0, 84, 84, 0, 131, 131, 0, 186, 186, 2, 
213, 213, 2, 238, 238, 0, 255, 255, 0, 255, 255, 73, 
255, 255, 145, 255, 255, 216, 231, 231, 175, 198, 198, 135, 
175, 175, 117, 139, 139, 89, 41, 63, 0, 68, 96, 0, 
101, 136, 0, 136, 183, 0, 168, 214, 0, 207, 255, 0, 
208, 255, 32, 218, 255, 90, 232, 255, 154, 243, 255, 211, 
216, 232, 174, 181, 197, 137, 155, 171, 114, 123, 137, 86, 
31, 63, 0, 51, 102, 0, 70, 140, 0, 89, 178, 0, 
108, 216, 0, 127, 255, 0, 155, 255, 56, 182, 255, 109, 
209, 255, 163, 235, 255, 216, 198, 228, 170, 166, 198, 136, 
141, 171, 113, 114, 141, 89, 0, 51, 0, 0, 91, 0, 
0, 132, 0, 0, 173, 0, 0, 173, 0, 0, 255, 0, 
56, 255, 56, 109, 255, 109, 163, 255, 163, 216, 255, 216, 
173, 229, 173, 138, 200, 138, 115, 173, 115, 87, 136, 87, 
0, 38, 19, 0, 81, 40, 0, 124, 62, 0, 168, 84, 
0, 211, 105, 0, 255, 127, 56, 255, 155, 109, 255, 182, 
163, 255, 209, 216, 255, 235, 174, 228, 200, 137, 198, 167, 
113, 170, 141, 90, 140, 114, 0, 51, 42, 0, 84, 70, 
0, 117, 97, 0, 150, 125, 0, 197, 165, 0, 230, 192, 
0, 255, 212, 73, 255, 224, 145, 255, 236, 216, 255, 248, 
177, 231, 221, 138, 197, 186, 114, 173, 162, 88, 137, 128, 
0, 33, 51, 0, 61, 91, 0, 88, 132, 0, 115, 173, 
0, 142, 214, 0, 169, 255, 56, 188, 255, 109, 206, 255, 
163, 224, 255, 216, 242, 255, 174, 212, 231, 134, 176, 197, 
113, 151, 170, 89, 121, 137, 0, 17, 51, 0, 34, 102, 
0, 51, 153, 0, 68, 204, 0, 85, 255, 43, 113, 255, 
86, 142, 255, 130, 171, 255, 173, 200, 255, 216, 229, 255, 
171, 191, 230, 138, 157, 197, 120, 138, 174, 93, 109, 140, 
0, 0, 63, 0, 0, 112, 0, 0, 160, 0, 0, 209, 
0, 0, 255, 43, 43, 255, 86, 86, 255, 130, 130, 255, 
173, 173, 255, 216, 216, 255, 173, 173, 229, 137, 137, 198, 
117, 117, 175, 93, 93, 140, 25, 0, 51, 51, 0, 102, 
76, 0, 153, 102, 0, 204, 127, 0, 255, 149, 43, 255, 
170, 86, 255, 192, 130, 255, 214, 173, 255, 235, 216, 255, 
200, 173, 228, 165, 136, 196, 143, 114, 173, 112, 89, 136, 
51, 0, 51, 91, 0, 91, 132, 0, 132, 173, 0, 173, 
214, 0, 214, 255, 0, 255, 255, 56, 255, 255, 109, 255, 
255, 163, 255, 255, 216, 255, 227, 168, 227, 198, 137, 198, 
170, 113, 170, 138, 89, 138, 51, 0, 25, 102, 0, 51, 
153, 0, 76, 204, 0, 102, 255, 0, 127, 255, 43, 149, 
255, 86, 170, 255, 130, 192, 255, 173, 214, 255, 216, 235, 
230, 178, 203, 199, 139, 168, 172, 116, 143, 141, 92, 116 };
Everything works with smoke - if you let it out, things stop working....

11

Re: Manual modification of the array

Guillaume wrote:
uint8_t r = remoteXyColors[ RemoteXY_CONF[8] ].r;
...

If I put this in my sketch .....

  uint8_t mycolour = RemoteXY_COLOURS[ RemoteXY_CONF[ 8 ] ];

I get a compile error

"exit status 1
Error compiling for board Arduino Nano."

I have assumed that the RemoteXY_CONF[] array is not accessible to the sketch, I would like to know why not, or if there is a work-around....

Everything works with smoke - if you let it out, things stop working....

12

Re: Manual modification of the array

Yes I forgot that this array is placed in progmem. You need to use pgm_read_byte_near function.

13

Re: Manual modification of the array

Guillaume wrote:

Yes I forgot that this array is placed in progmem. You need to use pgm_read_byte_near function.

I am at a loss with this - compiler says "expected ')' before ';' token" on this line of code.   (colour = ).   If I comment it out it compiles OK.  I really cannot see what is wrong with it....

if (! data_valid) {

   colour = pgm_read_byte_near( RemoteXY_CONF[ 8 ] );

   get_LED_RGB(colour);
   RemoteXY.valid_r = red;
   RemoteXY.valid_g = grn;
   RemoteXY.valid_b = blu;
   }
Everything works with smoke - if you let it out, things stop working....

14 (edited by Guillaume 2018-05-12 22:27:51)

Re: Manual modification of the array

You must pass an memory address to this function. Try

colour = pgm_read_byte_near( RemoteXY_CONF + 8 );
// or
colour = pgm_read_byte_near( &RemoteXY_CONF[8] );

I use a modified version of library which doesnt store this array in progmem so I can not only read it directly but also write to it after program started, with more changes in the library it could be developed for creating interfaces programmatically, with functions like RemoteXyButton myButton = remoteXy.addButton(x, y, w, h, text, style, ...) then methods like myButton.isPressed() etc.. With some efforts RemoteXY could be much better indeed ^^

15 (edited by Daba 2018-05-12 23:10:50)

Re: Manual modification of the array

Guillaume wrote:

You must pass an memory address to this function. Try

colour = pgm_read_byte_near( RemoteXY_CONF + 8 );
// or
colour = pgm_read_byte_near( &RemoteXY_CONF[8] );

I use a modified version of library which doesnt store this array in progmem so I can not only read it directly but also write to it after program started, with more changes in the library it could be developed for creating interfaces programmatically, with functions like RemoteXyButton myButton = remoteXy.addButton(x, y, w, h, text, style, ...) then methods like myButton.isPressed() etc.. With some efforts RemoteXY could be much better indeed ^^

I have had a tedious conversation on the Arduino community forum, which upset me a little....

It seems as though the problem is caused by RemoteXY_CONF being #define'd as a macro in the library.

I got some very terse responses at first, then we honed in on the problem.  Then I got some insults.  Feel free to check out the thread https://forum.arduino.cc/index.php?topic=547063.0

Why do they always want you to post the whole code ???   This could be commercial property, and divulging it before safeguards are in place may not be appropriate.

EDIT: Neither of your two suggestions worked. sad

Everything works with smoke - if you let it out, things stop working....

16 (edited by Guillaume 2018-05-13 04:08:58)

Re: Manual modification of the array

Yes it's defined as:

#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM

So the true name of the array is RemoteXY_CONF_PROGMEM.

You can rename the array if you want, see here http://forum.remotexy.com/viewtopic.php?id=15 .

17

Re: Manual modification of the array

Guillaume wrote:

Yes it's defined as:

#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM

So the true name of the array is RemoteXY_CONF_PROGMEM.

You can rename the array if you want, see here http://forum.remotexy.com/viewtopic.php?id=15 .

Thanks for that, Guillaume, works a treat....

  if (! data_valid) {
      get_LED_RGB(pgm_read_byte_near(RemoteXY_CONF_PROGMEM[8]));
      RemoteXY.valid_r = red;
      RemoteXY.valid_g = grn;
      RemoteXY.valid_b = blu;
      }
Everything works with smoke - if you let it out, things stop working....

18

Re: Manual modification of the array

Guillaume, where is ReomoteXY Admin ?  No response to the suggestions I have made, and his last post on here was 20-04-2018.  There is no point in making "Ideas and Suggestions" posts if they are not going to be read by Evgeny ....

Now I have another suggestion, as you may have read on http://forum.remotexy.com/viewtopic.php?id=364 to allow us to set the transmission rate or interval.  An update of slider and joystick positions at 3 to 4 times a second is simply not good enough.   

EDIT : I have just measured, and captured, waveforms that show that joystick (and presumably slider) data is transmitted at somewhere near 500mS intervals!!!. I have put the picture on DropBox if you want to have a look at it.

https://www.dropbox.com/s/bwzl9wpf1rytp … k.bmp?dl=0

The image was grabbed while I was throwing the joystick in all directions continuously, the thicker blue traces are the joystick data blocks being received by the BLE module - the cursors measure the time gap between those thick blocks - 522 mS !!

I don't know why the data exchange can't just recur as soon as it has completed, that way the only thing that will degrade the performance will be using too many analog controls....

Everything works with smoke - if you let it out, things stop working....

19 (edited by Guillaume 2018-05-15 15:24:26)

Re: Manual modification of the array

I don't know more than you where he is.

As for your problem, I don't know... I have used RemoteXY sliders to control the color of a led strip and it responds very quick, but every ~10 seconds there is a one second of lag where the slider doesn't respond to my finger, and I can't find the cause of it, very annoying too.. In another project I have many textboxes to make lines of a console, and I have tried to fill it and scroll it (with a slider as a scrollbar) as fast as possible, it is very responsive, no problem.

Edit: Due to how RemoteXY works (I believe it sends everything everytime huge waste of bandwidth), using BLE, with packet size of only 20 bytes, might not be a good choice.