ok I've been monkeying with the code, I've added to the scrolling text, and I
tried moving the "delay(del)" from the slidePattern function.
I thought it was responsible for the scroll speed, and when I change the arg,
it appears so, but when I remove the delay(del), and put one in the main
loop, I get crazyness... it runs very fast... not what I expected.
Dealt with above I hope.
Do the interrupts only interrupt the main loop?...
No they interrupt slidePattern as well. The main loop and slidePattern just manipulate the contents of the leds array variable; the interrupt routine (display) takes whatever's in the leds array when it fires and puts it out on the actual LEDs.
I suppose the interrupt could fire while slidePattern is halfway through changing a column in the array and you'd get a weird pattern on the matrix, but it's there so briefly you'd never notice it. To do it "properly" you might want to disable the interrupt routine before updating the array but then that would stop the matrix being refreshed in the meantime and you might get flicker. Perhaps you could use a double buffer - one array that's currently being shown and another you update, then you swap them over. Since it works visually at the moment though I'm certainly not going to bother.
kudos on the code, I still don't fully understand it, but they way you mapped
pins, to rows, and cols is great it makes the rest very compact, it makes the
defines for letters very easy, and the looping easy to understand....
Thanks! The way the letters are stored is actually very inefficient memory-wise. You'll find you can't add more than a few more letters to the message without running out of memory. What needs to be done is store each row of a letter as a byte so a definition would look something like this:
define L { \
B10000000,
B10000000,
B10000000,
B10000000,
B10000000,
B10000000,
B10000000,
B11111111
}
...
byte patterns[numPatterns][8] = {
H,E,L,L,O,SPACE
};
Then you've got 8 times the pattern space, but it makes the display() function more complicated (now you'll need bitwise operators). I'll leave that as an exercise for the reader...
Andrew
PS You've got the movie "Sweeney Todd" to thank for me being up and typing this. Just got back from the cinema and was too wired to go to bed. It's an excellent film! Stephen Sondheim musical crossed with a Tim Burton razor slasher flick - how could it fail?