Daft Punk Visor Orientation issue using MAX7219 Chips

Hello,

I am building a daft punk helmet led display.

I am using an UNO and 4 MAX7219 chips to control a series of animations.

I lack the programming skills to start from scratch. i have sourced this code on line and managed to get it to work.

When I play the stock code the animations are 90degrees out, i.e scrolling the wrong way. After some playing around i found that changing the part of the code

lcf.setRow(0,i,matrix[0]); to lcf.setColumn(0,i,matrix[0]);
the animations are then played in the correct orientation but at a much slower speed.
See the video of the problem here:
Daft Punk Visor Trouble - YouTube
I have tried fiddling with the delay times in the code but I’m really stumped here.
How may I speed up the animation? Is it possible? Or is this speed constrained by the way the code was written?
Any suggestions or pointers would be very helpful thanks!
The code is from this project:
http://efeion.blogspot.co.uk/search?updated-min=2011-01-01T00:00:00-05:00&updated-max=2012-01-01T00:00:00-05:00&max-results=3

Hi,

The setColumn() is much slower than the setRow() function in the led control library. If you read the library page, it does warn about that problem.

A note on performance…

There is an important difference between the way the setRow()- and the setColumn()- methods update the Leds:

setRow() only needs to send a single int-value to the MAX72XX in order to update all 8 Leds in a row.
setColumn() uses the setLed()-method internally to update the Leds. The library has to send 8 ints to the driver, so there is a performance penalty when using setColumn(). You won’t notice that visually when using only 1 or 2 cascaded Led-boards, but if you have a long queue of devices (6…8) which all have to be updated at the same time, that could lead to some delay that is actually visible.

There may be other ways to speed up your code, I will take a look.

Paul

EDIT: looks like the only part of the code that uses setRow() is this:

void display(){
 int i = 0;
 for(i=0; i<8; i++){
 lcf.setRow(0,i,matrix[0][i]); 
 lcf.setRow(1,i,matrix[1][i]); 
 lcf.setRow(2,i,matrix[2][i]); 
 lcf.setRow(3,i,matrix[3][i]); 
 }
 lcs.setRow(0,0,slight[0]); 
 lcs.setRow(0,1,slight[1]); 
 lcs.setRow(0,2,slight[2]); 
 lcs.setRow(0,3,elight[0]); 
 lcs.setRow(0,4,elight[1]); 
}

Is that the only part you changed when you replaced with setColumn(), and did you change all of them, or just the first 4?

(Horrible code, by the way…)

Try changing it to this:

void display(){
  int i = 0;
  unsigned char matrix2[4][8];
  for (byte m = 0; m < 4; m++) {
    for (byte r = 0; r < 8; r++) {
      for (byte c = 0; c < 8; c++) {
        bitWrite(matrix2[m][r], c, bitRead(matrix[m][c], r));
      }
    }
  }
  for(i=0; i<8; i++){
    lcf.setRow(0,i,matrix2[0][i]); 
    lcf.setRow(1,i,matrix2[1][i]); 
    lcf.setRow(2,i,matrix2[2][i]); 
    lcf.setRow(3,i,matrix2[3][i]); 
  }
  lcs.setRow(0,0,slight[0]); 
  lcs.setRow(0,1,slight[1]); 
  lcs.setRow(0,2,slight[2]); 
  lcs.setRow(0,3,elight[0]); 
  lcs.setRow(0,4,elight[1]); 
}

I can’t test it, but it compiles OK.

Hi Paul,

I can't thank you enough! The code works and now scrolls nicely in the correct orientation. It does however display the text and animations upside down. I could move the matrices round 180degrees to solve this problem but it would make the wiring a bit more messy.

The changes I made to the code where only to the first 4 entries. It could certainly be tidied up, the original creator was controlling 2 other led systems (ears and sidebars).

Thanks again for your input!

Try this:

bitWrite(matrix2[m][7-r], c, bitRead(matrix[m][c], r));

You may be interested in the Daft Punk example I have in the MD_MAX72xx library. See the link in the signature below - libraries.

hi marco_c,

Thanks for the suggestion the codes are way better! I had seen your Parola demonstration on youtube and was going to ask if this would be the way to go.

I have the demo running but again it is 90 degrees out. The letters are back to front and it scrolls the wrong way.

Would the code suggested by PaulRB be the way to fix this issue or should I focus on changing setRow and setColumn?

I tried the code you suggested Paul but it was unsuccessful.

Any help would be fantastic. This is the last step in what has been a long build!

Please read the documentation for MD_MAX72xx, especially the section on adapting to hardware.

So... is it 90 or 180 degrees out now?

I'm now using marcos parola codes, they are 90 degrees out. Trying to educate myself on compile time switches.

I'm using generic modules so I take it I have to declare that first,

#define USE_GENERIC_HW 1

Then I will use a combination of

HW_DIG_ROWS (0 or 1)
HW_REV_ROWS (0 or 1)
HW_REV_COLS (0 or 1)

To correct the orientation.
Im not sure how to enter these or where they go in the code?
I read one post which said you need to modify the MD_MAX27xx_lib.h file on notepad to get it to work?

I have tried unsuccessfully to enter the above codes, and I have tried getting the mapper code up and working.

Ill try and sift through more forum posts and get it sorted. If you have any pointers that would be awesome!

Just change the values in the MD_MAX72xx header file and make sure only one is actually selected (ie, not USE_PAROLA and USE_GENERIC at the same time).

The way that Arduino header files are mashed means that you cannot change this outside of the actual header library, unfortunately. Also, once you change it for your hardware types, it is pretty much set for all your projects.

Brilliant I got it sorted it looks amazing! Thanks everyone for the help!