MAX7221 goes real SPI

I modfied the existing LedControl Library for using the real SPI. I got a problem of my Drivers wich was dasychained. I get some flicker while switching the different LEDS. so i modified to war with the MAX7221 with SPI Library. The will remove the flicker because i changed the shiftout to real SPI. But now i dont know how i bring it up to the playground?
Can i get some little help of you guys?
Theres only one little problem i had to move the two SPI Libray files (SPI.h + SPI.cpp) into my LEDControlSPI folder to use it. If i edit the LED Lib and add the includes with #include <SPI.h> or #include "SPI.h". I get some error while compiling wich sound like these (No such file in these directory). It only works if i copy the both SPI files in the same folder to get no errors. I attached LEDContorlSPI Lib.

LedControlSPI.zip (5.99 KB)

This is nice if it lets new users like myself use it the same way as the original LedContrl library.. (same public methods available..etc)

However.. speaking as a noob myself if there is a ton of library switching and directories changing.. if its not 'clear' in step-by-step directions. it'll be more difficult to use/implement.

So I'm unclear.. is there anything to do or not? just un-zip your 'lib' to our libraries directory? not other changing of files/headers/libs?

thanks! :slight_smile:

Yes it is the way to handle you can Change only the header from LEDControl.h to LEDControlSPI.h. You can use the same handling like the original. The only changing is the the class will be initilize with only two Parameters: like these:
LedControl LC=LedControl(PNI,MANY); // On Pin the you have write where your ChipSelect is connected to, on Many you have to write how many MAX7221 you connect in 1-8 for each init.
The other pins connect to the hardware SPI.
Data to MOSI (Pin11)
Clock to CLK (Pin13).

hmm.. over my head. (not understanding what you wrote really)

but thanks. Im sure others will get good use out of it. :slight_smile:

Has it been updated so it works with 1.0 as well?

Yes i work with this Lib in 1.0.
Greeting
Daniel

Im trying to use this with Arduino IDE 22+ (not 1.0)

but am getting errors..

Also, do you have any documentation or examples for YOUR version? on how to initiate the objects and use the methods/functions..

(I think you said more things are the same.. this just uses SPI?)

Also.. in your examples.. can you post the PINOUT? Im assuming pins 13, 11, 10? and not 12, 11, 10 like previous?

thanks

Hi,

Can you clarify your instructions a little bit?

I have LEDcontrol set up now for just one max72xx, and I'd like to simply swap your library in so I can use real SPI.

I now have:

#include "LedControl.h"
LedControl lc=LedControl(11,13,10,1);  // lc is our object
/* format is: LedControl(data pin, clock pin, load pin, 1) */
/* arduino pin 11 is connected to DATA [pin 1 on max7219]  */
/* arduino pin 13 is connected to CLK [pin 13 on max7219] */
/* arduino pin 10 is connected to LOAD [pin 12 on max7219] */

void setup() 
{
  lc.shutdown(0,false);       // The MAX72XX is in power-saving mode on startup,we have to do a wake up call
  lc.setIntensity(0,5);         // set the brightness to a value 1-15
  lc.clearDisplay(0);            // clear the display
  lc.setScanLimit(0,1);        // set chip number 0 to drive 2 digits

  lc.setChar(0,0,'d',false);
  lc.setChar(0,1,'b',false);

Can you suggest what small changes to code need to made to this setup, and what files/directory structure to create to use your library?

Thanks very much.