Today I posted a library to Github which implements a hardware driver for Adafruit's GFX library for the cheap MAX7219 8x8 led matrix. It is rather basic, but does support double buffering to prevent screen flicker, especially useful for applications like a ticker tape.
CrossRoads:
Why not use SPI for sending data to the MAX7219?
It works quite well with the default settings (4 MHz clock).
As opposed to the MAX7221, the MAX7219 is not fully SPI compatible. The MAX7219 reads the DIN line even when LOAD (~CS) is low. From the MAXIM datasheet:
For the MAX7219, serial data at DIN, sent in 16-bit packets, is shifted into the internal 16-bit shift register
with each rising edge of CLK regardless of the state of LOAD. For the MAX7221, CS must be low to clock data
in or out. The data is then latched into either the digit or control registers on the rising edge of LOAD/CS.
LOAD/CS must go high concurrently with or after the 16th rising clock edge, but before the next rising clock
edge or data will be lost.
I would say this doen't matter, so I tried to use Arduino's SPI library. But the display isn't properly addressed, most of the time the whole display lights up. So this won't work for a MAX7219:
Currently, the library does not support cascade displays positioned vertically. So the last digit should always be 1.
I have checked the code for bugs for multiple horizontal displays, but found none. Unfortunately, I own only a single 8x8 display, so It's a bit difficult to fix the code as I can't test it.
The examples I wrote didn't support multiple horizontal displays. I fixed this, so please download and install the library again.
I suggest you first try the MadFly example (which doesn't use double buffering), attach the Data OUT pin of the first display to the Data IN pin of the second, and give it another try. If it fails, someone owning multiple displays might try to fix it (or someone send me a display for testing, in which case I'll add support for multiple vertical displays too )
I have not cascaded them either, just connected up 4 in parallel with unique SS for each so I didn't have to fool with sending out a bunch of No-ops thru 3 chips to access a register on the 4th.
I used mine for a scrolling display, didn't the software hassle of having to send out every 8th byte from the array where I was storing the messge being displayed.
Only have serial and the 4MAX7219's connected, so plenty of free pins available for unique SS outputs.
Here's a video of it working www.crossroadsfencing.com/BobuinoRev17/Scroll_Test.AVI
Later version of the software holds each position for 40 or 50mS, faster than that it was hard to read as the text whipped by.
Got a you tube version somewhere, have to find the link.
CrossRoads:
I have not cascaded them either, just connected up 4 in parallel with unique SS for each so I didn't have to fool with sending out a bunch of No-ops thru 3 chips to access a register on the 4th.
The Max72xxPanel library uses double buffering, so no NOPs involved. Still, each refresh the number of pixels times two are serially send out to DIN.
Later version of the software holds each position for 40 or 50mS, faster than that it was hard to read as the text whipped by.
I never knew fake MAX7219's existed until I stumbled upon the site mentioned earlier. Back to topic: I miswired DIN to MISO, after doing to right, the <SPI.h> library worked. So I'll probably switch Max72xxPanel to using the SPI library. Sorry for the confusion...
alessiocavalieri:
I'm trying to use the code with two matrix modules but i don't understand how.
I've just commited some changes to support multiple vertically connected displays. Any set of matrices in the form of a rectangular should work now. Connect them in cascade, starting from the upper left to the bottom right:
1 2
3 4
5 6
Please give it a try, as I have only a single display and can't test the modifications for multiple displays myself.
alessiocavalieri:
SPI, works fine, but some tuning in cascade is required, my test downloadable as movie + readme:
Thank you for your report. As I don't have the hardware to test, it's rather difficult to fix it. But I did found a bug in my rotation code in case of multiple matrices, so you might give the library another try.