Can someone explain the role of setColumn function from this library? I couldn't find any description of its functions.
It simulates the setRow function, except due to the multiplexing, it does some internal wizardry to compensate for the row updating sequence.
It basically lets you pick off/on state for columns with defined bits.
Something like... setColumn of pixels?
and what's the function of writeSprite?
The code is here to read
and what's the function of writeSprite?
Surprisingly it writes a sprite to the matrix.
Still have no clue
void MaxMatrix::writeSprite(int x, int y, const byte* sprite)
{
int w = sprite[0];
int h = sprite[1];
if (h == 8 && y == 0)
for (int i=0; i<w; i++)
{
int c = x + i;
if (c>=0 && c<80)
setColumn(c, sprite[i+2]);
}
else
for (int i=0; i<w; i++)
for (int j=0; j<h; j++)
{
int c = x + i;
int r = y + j;
if (c>=0 && c<80 && r>=0 && r<8)
setDot(c, r, bitRead(sprite[i+2], j));
}
}
Do you know what a sprite is?
It is a 2D array or picture.
If I could understand code above I wouldn't put this question. I know what a sprite is but I want to understand how this library works with sprites.
The line
void MaxMatrix::writeSprite(int x, int y, const byte* sprite)
Takes a pointer to a byte sprite array and plots it on the display matrix at the location of the passed x and y coordinates.
The first two bytes of the sprite array contain the width and height of the sprite.
Whatćs for the rest? what's w, h? What about sprite[0] and sprite[1]?
int w = sprite[0];
int h = sprite[1];
if (h == 8 && y == 0)
for (int i=0; i<w; i++)
{
int c = x + i;
if (c>=0 && c<80) // why 80?
setColumn(c, sprite[i+2]); //what exactly this means?
}
what's w,
width of the sprite
h?
height of the sprite
What about sprite[0] and sprite[1]?
I told you in reply #7
The first two bytes of the sprite array contain the width and height of the sprite.
I've got it now
sprite[0] and sprite[1] are first two bytes of sprite's definition. All time I was thinking that there are two different sprites. [0] contains width and [1] is height.
I've got a 32x8 LED matrix and tried to scroll some text with the help of MaxMatrix library code. My sketch which worked fine with 8x8 matrix doesn't work correctly with this new matrix. I've tried to change mx.shiftLeft() to shiftRight(), shiftUp() and shiftDown() but this time matrix didn't show anything. Changing rotate parameter of these methods also didn't work. Any idea?
does anyone have code based on MaxMatrix library which works fine on the 8x32 LED matrix?