Go Down

Topic: Help needed: direct drive LED matrix (Read 1 time) previous topic - next topic

Designrats

I was playing with this example:
http://www.arduino.cc/playground/Main/DirectDriveLEDMatrix

In the first code, it is rolling text to the left.

I am wondering what do I need to change to make it be able to roll the text to the other directions, such as right/up/down.

Hope those programming masters in this forum can help me out.

Thanks,
Designrats

halley

Code: [Select]
void slidePattern(int pattern, int del) {
 for (int l = 0; l < 8; l++) {
   for (int i = 0; i < 7; i++) {
     for (int j = 0; j < 8; j++) {
       leds[j][i] = leds[j][i+1];
     }
   }
   for (int j = 0; j < 8; j++) {
     leds[j][7] = patterns[pattern][j][0 + l];
   }
   delay(del);
 }
}


This function on that page is responsible for "sliding" the existing contents of the leds[][] array out of view, and replacing them with another pattern.  In particular, leds[j] = leds[j][i+1]; sets a given LED to the value on its right-- do this for all LEDs in the correct order, and you'll see the whole image shift leftward one spot.  Then the statement leds[j][7] = patterns[pattern][j][0 + l]; deals with an LED in the rightmost column, by filling it with the appropriate cell in the next column of the new pattern.

It's a very straight-forward routine.  You could write three other similar routines that slide the contents in other directions.

Andrew

#2
Apr 02, 2009, 11:28 am Last Edit: Apr 02, 2009, 11:30 am by Andrew Reason: 1
Back when I wrote this code people were asking about it so I produced a commented version. Hopefully this will help you figure out what to do (also you can see the original thread at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203747843/17#17).

Code: [Select]
void slidePattern(int pattern, int del) {
 // Loop 8 times, once for each column of new character to scroll in
 for (int loop = 0; loop < 8; loop++) {
   // First shuffle existing columns 1 to 7 into cols 0 to 6
   for (int i = 0; i < 7; i++) {
     // Do each row of each column
     for (int j = 0; j < 8; j++) {
       leds[j][i] = leds[j][i+1];
     }
   }
   // Now copy new column from pattern onto end column of display
   for (int j = 0; j < 8; j++) {
     leds[j][7] = patterns[pattern][j][0 + loop];
   }
   // Wait for a bit
   delay(del);
 } // end loop for each column of new pattern
} // end function


Andrew

halley

Designrats, if you've tried a bit of tinkering there, but came up with ugly results, then perhaps you might not have noticed a key phrase in my reply:   do this for all LEDs in the correct order.

If you're scrolling columns rightward, you will need to visit all the columns in the opposite order as the given loop, otherwise each copy will damage data you've just written.

Likewise, if you're sliding up or down, then the order you visit the columns isn't important, but the order you copy the rows is key.

ason_cool

I've tried to compile the code but could not succeed

is warning / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

What is the purpose of warning?
how to handle it?

Go Up