HI, I want to learn how to manipulate an XYMatrix and am starting off

HI,

I want to learn how to manipulate an XYMatrix and am starting off with the example code provided in FastLED but I need some pointers on how to begin.

I want to start by making each column the same random colour, changing every second, then the same with rows.

I think I need to be able to copy the pixel colour from one to another within the matrix and that is what I’m struggling with.

Eventually I’d like to be able to code in concentric rectangles moving in from the 4 edges that is dynamic to the size of the xy matrix…

at the moment I am starting with the very basic example:

for ( uint8_t x = 0; x < kMatrixWidth; x++) {
for ( uint8_t y = 0; y < kMatrixHeight; y++) {

  // Here's the x, y to 'led index' in action:
  leds[ XY( x, y) ] = CHSV( random8(), 255, 255);
}

}

I have a feeling it should be easy to group the columns or rows, but I am struggling with the first steps.

Thanks for any advice!

I have been thinking about this and starting with ROWS is this the right way of thinking about it:

Create a new function to use instead of XY like this:

uint16_t row (uint8_t y) {

// receives row number
// creates an array of LEDS for that row with a size of kMatrixWidth
// assign each LED in the array an actual LED number
// returns the array that can be controlled with a for loop

}

I think I’m getting the hang of it - http://pastebin.com/KLuTp0YQ

I will write some examples of how this is useful when I have got all the maths for the different patterns worked out :slight_smile:

Hi, my Matrix class probably does what you want https://github.com/AaronLiddiment/LEDMatrix
But sometimes its better to take the time to do it yourself :slight_smile: as your coding skills can only get better :wink:

@Aaron_Liddiment That’s great, very useful! many thanks :slight_smile: