neopixels in a zigzag pattern.
That is called a serpentine raster.
There are two ways of making a matrix like this, one is with strips on the columns, the other with the strip on the rows. This is a column matrix.
Now the way to drive this is to write a function to translate the X and Y coordinates into the LED number.
LED number = Y + (X * number of LEDs in a column)
However for odd numbered columns the conversion is :-
LED number = (X * number of LEDs in a column) + (number of LEDs in a column -1 -Y)
To determine if the X coordinate is odd or even, simply look at the least significant bit of the X value and if it is a zero then it is an even column or if it is a one it is an odd column. So all the software has to do is to examine the X - coordinate and decide what formula to use. It is simple enough to make a function that returns the LED number given the X & Y values.
int getLEDpos(int x, int y){ // for a serpentine raster
int pos;
if(x & 0x1) { // is X odd
pos = x * yMax + (yMax -1 - y) ;
} else { // x is even
pos = x * yMax + y;
}
return pos;
}
Where yMax is the number of LEDs in a column.
Then you can treat your matrix just like a two dimensional display. Of course if you have a row serpentine matrix or wire your matrix backwards, that is from right to left, you have to reflect that in the above function.
Now to get something to scroll you transfer the matrix defining the display you want with a one column offset into the LED buffer. This shifts the whole pattern over to the right or left depending on the sign of the offset.
