0

Question about NeoMatrix Library.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Question about NeoMatrix Library.

by Kayrozen on Tue Jan 19, 2016 12:42 pm

Hi ! I'm currently playing with the NeoMatrix library and i'm searching for an info about irrégular layout of matrices.

In my next project, i want to do a hexagonal layout of 19 leds placed like this (numbers dont care, it's from google images):
Image

How could i represent this in the remap function ? Is there a better method to animate this layout ?

Thx a lot !

Kayrozen
 
Posts: 4
Joined: Tue Jan 19, 2016 12:33 pm

Re: Question about NeoMatrix Library.

by adafruit_support_rick on Wed Jan 20, 2016 5:25 am

The matrix library wouldn't support that.

adafruit_support_rick
 
Posts: 35058
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Question about NeoMatrix Library.

by Kayrozen on Wed Jan 20, 2016 7:35 am

Thank you for your rapid answer. :)

Kayrozen
 
Posts: 4
Joined: Tue Jan 19, 2016 12:33 pm

Re: Question about NeoMatrix Library.

by Disciple on Wed Jan 20, 2016 9:53 am

If there are really 19 NeoPixels in the cluster, you might be able to brute-force a remap function, treating the cells as part of a larger matrix with most of the boxes empty. I use a similar function.
HexRemap01.png
Not a board game...or is it?
HexRemap01.png (6.02 KiB) Viewed 277 times

Then constructing your matrix object as a 9x9 grid, a remap function might look like this.
Code: Select all | TOGGLE FULL SIZE
// Brute force address conversion, XY to Hex cells
uint16_t hexedGrid01(uint16_t x, uint16_t y) {

  y = 9 * y + x;  // Compute index number based on 9x9 matrix

  switch(y) {     // Only 19 locations contain a NeoPixel
    case 40:
      return 0;
    case 11:
      return 1;
    case 36:
      return 2;
    case 65:
      return 3;
    case 51:
      return 4;
    case 26:
      return 5;
    case 22:
      return 6;
    case 47:
      return 7;
    case 69:
      return 8;
    case 44:
      return 9;
    case 15:
      return 10;
    case 29:
      return 11;
    case 76:
      return 12;
    case 62:
      return 13;
    case 33:
      return 14;
    case 4:
      return 15;
    case 18:
      return 16;
    case 54:
      return 17;
    case 58:
      return 18;
    default:
      return 20;  // Empty matrix location = nonexistent pixel address
  }
}
Of course, the number pairs would need to match your pixel arrangement, and of course, only simple functions from the GFX library would be discernible, like a filled circle that spreads from the center or a rectangle wiping downward. Do post a picture if you get it to work. (c:

Hallelujah!
Disciple

Disciple
 
Posts: 544
Joined: Tue Jan 06, 2015 8:13 pm

Re: Question about NeoMatrix Library.

by Kayrozen on Wed Jan 20, 2016 1:02 pm

WOW ! Great idea. I'll test it this w-e. Thanks a lot.

Kayrozen
 
Posts: 4
Joined: Tue Jan 19, 2016 12:33 pm

Re: Question about NeoMatrix Library.

by Kayrozen on Sat Feb 13, 2016 11:32 am

So, it took me a little longer to test this out and it worked ! I changed values to match my led sequence and voilà ! Pic incomming asap.

Thanks a lot to @Disciple for helping me with the brute force remap function.

Kayrozen
 
Posts: 4
Joined: Tue Jan 19, 2016 12:33 pm

Re: Question about NeoMatrix Library.

by caitlinsdad on Thu May 24, 2018 10:14 pm

I think your remapping question will depend more on a matter of what animations you were going to do. Then you want to figure out how to implement that in the easiest way possible, by software or the way you physically wire up the neopixels in your hex matrix. Usually you code in loops to address neopixels sequentially so you have to imagine you have a long strip. Are you winding it around the center and calling start pixel 0 at the center or at the end - or just an irregular zig-zag stacked bunch of rows or columns.

What I have seen done is you diagram it all out to get the pixel numbers as they are physically wired up in sequential order. Then assign pixel order numbers as if you addressing it as a continuous strip - going around the hex shape. You can then place that in order in a list(16,11,10,6,14,9...) with its real pixel number in an array variable. So when you use the pixel{i], it will get the i th position in the array corresponding to the remapped neopixel. So, you can code to start lighting up the outer edge of the hex shape and spiral in and so forth. Good luck.

caitlinsdad
 
Posts: 493
Joined: Fri Feb 24, 2012 4:23 pm

Please be positive and constructive with your questions and comments.