Hi all,
Im currently playing with a 8x32 led matrix (an ICSTATION clone i believe obtained via ebay) all worked well with the MAX72xx.h library (i had to edit the library to use USE_ICSTATION_HW to get it displaying correctly with the input on the right as i read in the docs)
my problem however is when using the LEDCONTROL library, i cant figure out how to achieve the same rotation?...i could flip the fonts to fix it (or phisically rotate the display upside down)..but it seems like a bit of a bodge - is there a way to rotate what is displayed 180degrees when using the LEDCONTROL library?
Thanks in advance,
Sparkzter
I just finished "rotating" code myself for some 8x8 LED matrix and associated MAX7219 on a PCB.
As far as I can tell there is not "rotation" function with the LedControl library.
I had to do that myself in code.
As far as I can tell, the LedControl library assumes row 1 is at the top and column 1 is on the left.
Cheers for the reply, i just spotted your recent post..looking at the text you did well to find that blog entry via google!
the 'rotating' code you speak of, was that just flipping the font library or something else?
cheers,
Sparkzter
I use the setRow function of the LedControl library, so I had to remember that row1 is actually row 8, etc. and change the code accordingly. In other words, when you use the LedControl library to write to row1, you are now writing to the bottom row of LEDs. Also, the value to be written needs to be "flipped", because column 1 is on the right now --- MSB is now the LSB.
I hope that makes sense.
i figured that changing
void printBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a*2+1]; // Get high buffer entry
byte y = x; // Mask off first character
lc.setRow(3,a,y); // Send row to relevent MAX7219 chip
x = bufferLong [a*2]; // Get low buffer entry
y = (x>>24); // Mask off second character
lc.setRow(2,a,y); // Send row to relevent MAX7219 chip
y = (x>>16); // Mask off third character
lc.setRow(1,a,y); // Send row to relevent MAX7219 chip
y = (x>>8); // Mask off forth character
lc.setRow(0,a,y); // Send row to relevent MAX7219 chip
}
to
void printBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a*2+1]; // Get high buffer entry
byte y = x; // Mask off first character
lc.setRow(0,a,y); // Send row to relevent MAX7219 chip
x = bufferLong [a*2]; // Get low buffer entry
y = (x>>24); // Mask off second character
lc.setRow(1,a,y); // Send row to relevent MAX7219 chip
y = (x>>16); // Mask off third character
lc.setRow(2,a,y); // Send row to relevent MAX7219 chip
y = (x>>8); // Mask off forth character
lc.setRow(3,a,y); // Send row to relevent MAX7219 chip
}
got the tiles displaying in the right order to allow readable text to scroll across the screen (sorta swapping left to right) but its upside down - im struggling to figure out how i can swap the bottom to the top?
a now becomes 8 - a - 1 for my code
Well, im getting somewhere...
changing to this get the text up the right way...
void printBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a*2+1]; // Get high buffer entry
byte y = x; // Mask off first character
lc.setRow(0,8-a-1,y); // Send row to relevent MAX7219 chip
x = bufferLong [a*2]; // Get low buffer entry
y = (x>>24); // Mask off second character
lc.setRow(1,8-a-1,y); // Send row to relevent MAX7219 chip
y = (x>>16); // Mask off third character
lc.setRow(2,8-a-1,y); // Send row to relevent MAX7219 chip
y = (x>>8); // Mask off forth character
lc.setRow(3,8-a-1,y); // Send row to relevent MAX7219 chip
}
}
however its still back to front and scrolling from left to right as opposed to the expected right to left.
im thinking i need to do the same thing as we achived above with the 'up and down', this time swapping the columns on the right with the ones on the left of each display.. struggling to figure out how thats done tho :s
As I wrote before, both the rows and columns are reversed.
Hi ieee488,
I looked at your code and what I believe that needs to be done is you need to reverse the byte being send so that it will display upright in addition to flipping the rows. That should "rotate" the image from upside down to right side up.
You can reverse the byte using a function like this:
byte reverse(byte in) {
byte out = 0;
for(int i=0; i < 8; i++)
out |= ((in >> i) & 1) << (7 - i);
return out;
}
So if what you are sending is:
Row 0: 00110000
Row 1: 01001000
Row 2: 10000100
Row 3: 10000100
Row 4: 11111100
Row 5: 10000100
Row 6: 10000100
Row 7: 00000000
but you see this:
Row 0: 00000000
Row 1: 00100001
Row 2: 00100001
Row 3: 00111111
Row 4: 00100001
Row 5: 00100001
Row 6: 00010010
Row 7: 00001100
then you put the data that would go to Row 7 into Row 0 but reversed and that will rotate your image to be right side up.
for(int row = 0; x < 8; x++) {
send( reverse( data[7 - row] ), row);
}
There are some performance issues because for each byte you send you have to reverse it. You could just use a table to reverse them and access that instead of programmatically doing it on the fly.
The only other way to do it is to create your data in a reverse before sending it to your matrix.
Hope that helps. 
dmilton2004:
Hi ieee488,
I looked at your code and what I believe that needs to be done is you need to reverse the byte being send so that it will display upright in addition to flipping the rows. That should "rotate" the image from upside down to right side up.
Thanks, but it is not my code.

Sorry ieee488. I typed the wrong name. LOL Your post was under sparkzter's and I was responding to them.
My bad and a good lesson to review before posting! 