Question about NeoMatrix Library.

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Kayrozen
 
Posts: 4
Joined: Tue Jan 19, 2016 12:33 pm

Question about NeoMatrix Library.

Post by Kayrozen »

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 !

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Question about NeoMatrix Library.

Post by adafruit_support_rick »

The matrix library wouldn't support that.

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

Re: Question about NeoMatrix Library.

Post by Kayrozen »

Thank you for your rapid answer. :)

User avatar
Disciple
 
Posts: 852
Joined: Tue Jan 06, 2015 8:13 pm

Re: Question about NeoMatrix Library.

Post by Disciple »

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.
Not a board game...or is it?
Not a board game...or is it?
HexRemap01.png (6.02 KiB) Viewed 659 times
Then constructing your matrix object as a 9x9 grid, a remap function might look like this.

Code: Select all

// 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

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

Re: Question about NeoMatrix Library.

Post by Kayrozen »

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

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

Re: Question about NeoMatrix Library.

Post by Kayrozen »

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.

User avatar
caitlinsdad
 
Posts: 627
Joined: Fri Feb 24, 2012 4:23 pm

Re: Question about NeoMatrix Library.

Post by caitlinsdad »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”