Ok... so the previous posts of mine were interesting,

Ok… so the previous posts of mine were interesting, but now i think its going to get complicated…

in the top section, this is the current setup. the leds are looped around in a cube format so 1 is left, 2 is front, 3 is right, 4 is back, 5 is top and 6 is bottom.

i have working code to get the side leds (horizontal) when the cube is in place.

now im working on the vertical, and im not sure what to call the other one, sidevertical i guess… y is done, x and z to do…

and thinking forward, is the bottom more final setup.

now before i proceed on, i was thinking how i can make this work in the next section, and was going to use the xy matrix (but lots of them) and then use this code to link… but before i go on, i was wondering if there was a simpler / more obvious way?

i havent wired the main thing up, so its open to any physical change / layout!

the beautifully working code i already have (which i am actually quite proud of… :: LOL ::)

i guess its a little cheaty, as i created a 2d array, with the relevant positions in order.

byte sideState[6][4] = {
{4, 6, 2, 5}, // 1 0,1
{5, 1, 6, 3}, // 2 2,3
{5, 2, 6, 4}, // 3 4,5
{3, 6, 1, 5}, // 4 6,7
{4, 1, 2, 3}, // 5 8,9
{3, 2, 1, 4} // 6 10,11
};

// assignSideLeds
int g = 0;
for (int i = 0; i < NUM_SIDES; i++) {
for (int j = 0; j < NUM_LEDS_IN_SEGMENT; j++) {
sideLeds2[g] = ((sideState[state - 1][i] * NUM_LEDS_IN_SEGMENT) - NUM_LEDS_IN_SEGMENT) + j;
g++;
}
}

88e25d4a9f2046243f2e0bf8f654b61d.png

Maybe, you can extend my cLEDMatrix fork (based on Aaaron) with the Z geometry.
Currently you can define a matrix of x,y - but also define multiple matrix tiles.:

you can do this also with a formula. I expain it in three steps, but sumarize it to one single line.
First things first:

  • always start counting from 0 (not from 1) as this makes calculation of addresses much easier. In you example the “State” blocks should start with 0, also the led-address, also the x-/y-coordinates
  • use some variables or constants to define the dimensions of one block for more flexibility. The follwing step by step tutorial uses block_w for the width of a state block and block_h for the height of a state block. In our example the dimensions are 3 for both, width and height.
  • type cast (int) is used to cut off decimal precisions of division on purpose

Now, step by step:

Step 1: calculate base-address of the block
address = ((int)(x/block_w) * (block_w * block_h)

Step 2: add the offset for all preceiding lines within one block
address = address + (y*block_w)

So far its easy, comming to the last step which es a bit more difficult as it alternates between even and uneven line numbers. We can use the modulo operation to determine which line it is and add different calculated values

Step 3: add remaining x within the block
for even line-numbers:
address = address + (((y+0) % 2) * ((block_w-1) - (x-(((int)(x/block_w))*block_w))))
for uneven line-numbers:
address = address + (((y+1) % 2) * (x-(((int)(x/block_w))*block_w)))

And finaly all at once:

address = (((int)(x/block_w) * (block_w * block_h)) + (y*block_w) + (((y+0) % 2) * ((block_w-1) - (x-(((int)(x/block_w))*block_w)))) + (((y+1) % 2) * (x-(((int)(x/block_w))*block_w)))

Blown away! I’ll have a look at this tonight! Thanks!

@Jurgen_Skrotzky any idea on how to use this with nscale8…
cannot convert ‘cLEDMatrix<3u, 3u, 8u>’ to ‘CRGB*’ for argument ‘1’ to ‘void fadeToBlackBy(CRGB*, uint16_t, uint8_t)’

If you want the data, you can just get it by leds[0]
E.g.: cLEDMatrix<3u,3u,8u> leds;

fadeToBlack(leds[0],…)

got it…!

in the line >>FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());

fadeToBlackBy(leds[0], leds.Size(), 30);

[] operator gives you the CRGB data
(idx) operator gives you reference of led index idx
(x, y) operator gives you reference of led by x and y

yeah, kinda.

I have a simple test setup, where the adxl345 is sending data from -255 > 255, and this is mapped across a 3x3 matrix.

and the ledmatrix code is working nicely, for the x and y positions, but it has the 0,0 0,3 3,0 and 3,3 (the corners) are coming out opposite :confused:

Hmmm, thought your cube has a dimension of 3x3. If so, your corners are 0,0 0,2 2,2 2,0…

yeah, it does, and that was confusing me too… if i put in 0, 2 then its erratic data, as is 1, 3. 0,3 has the x and y correct…
:-/

Can you please paste the declaration of your matrix type?
So the part with cLEDMatrix<… > leds;

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

#define MATRIX_WIDTH 3
#define MATRIX_HEIGHT 3
#define MATRIX_TYPE (MTX_MATRIX_TOP + MTX_MATRIX_LEFT + MTX_MATRIX_ROWS + MTX_MATRIX_ZIGZAG)

0,2 video https://www.youtube.com/watch?v=TnDOZ9crdKw

0,3 video https://youtu.be/QYWKJBh_VZY

ran out of memory on phone :: LOL ::.