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):
How could i represent this in the remap function ? Is there a better method to animate this layout ?
Thx a lot !
Question about NeoMatrix Library.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Question about NeoMatrix Library.
The matrix library wouldn't support that.
- Kayrozen
- Posts: 4
- Joined: Tue Jan 19, 2016 12:33 pm
Re: Question about NeoMatrix Library.
Thank you for your rapid answer. :)
- Disciple
- Posts: 852
- Joined: Tue Jan 06, 2015 8:13 pm
Re: Question about NeoMatrix Library.
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.
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
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
}
}
Hallelujah!
Disciple
- Kayrozen
- Posts: 4
- Joined: Tue Jan 19, 2016 12:33 pm
Re: Question about NeoMatrix Library.
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.
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.
Thanks a lot to @Disciple for helping me with the brute force remap function.
- caitlinsdad
- Posts: 627
- Joined: Fri Feb 24, 2012 4:23 pm
Re: Question about NeoMatrix Library.
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.
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.
Please be positive and constructive with your questions and comments.