Pages: [1]   Go Down
Author Topic: how to rotate matrix scroll by 90 degrees in code  (Read 1290 times)
0 Members and 1 Guest are viewing this topic.
Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys...I have a 16 x 8 matrix scrolling and adding on 2 more 8 x 8 matrices to make a 32 x 8 matrix scroll.....however, the I have to physically rotate the matrices...how can you do it in code because its difficult for this to work with how the pinouts get placed.....my code is attached

* Scroll_Across.ino (13.23 KB - downloaded 13 times.)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 597
Posts: 33301
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just rotate your character definitions.

Just write down the columns as rows.
« Last Edit: December 05, 2012, 02:57:33 pm by Grumpy_Mike » Logged

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

could you look at my code and explain where I would do that though please
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 597
Posts: 33301
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am on my iPad and it won't copy your code but I will try.
Code:
B00110011;
B11001111;
B00111000;
B01010101;
B11011100;
B11110000;
B00000000;
B00011100;

Would be
B11010000;
B11000000;
And so on, each coloumn becomes a row. This rotates the pattern you se.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you look at your code, it is using printLED(). In particular, it uses this line:

Code:
   int c = font8x8[(number * 7) + a];      // Index into character table to get row data

All you need to do is to rewrite that line.
Logged

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sorry I don't follow.....how would you rewrite it
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure.

Code:
   int c = (font8x8[(number * 7) + 0] & (1<<a))?0x80:0;      // Index into character table to get row data
   c |= (font8x8[(number * 7) + 1] & (1<<a))?0x40:0;
   c |= (font8x8[(number * 7) + 2] & (1<<a))?0x20:0;
   c |= (font8x8[(number * 7) + 3] & (1<<a))?0x10:0;
   c |= (font8x8[(number * 7) + 4] & (1<<a))?0x08:0;
   c |= (font8x8[(number * 7) + 5] & (1<<a))?0x04:0;
   c |= (font8x8[(number * 7) + 6] & (1<<a))?0x02:0;
   c |= (font8x8[(number * 7) + 7] & (1<<a))?0x01:0;

This rotates the display 90/270 degrees. Depending on your physical orientation, it may be right-side-left. In that case, switch 0x80 with 0x01; 0x40 with 0x02; ...
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26322
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sometimes its easier to just look at youyr hardware a different way and rewire it to match.
For example, here are two parts advertised as common cathode and common anode (from futurlec.com).
You can see that if you orient them so the common anodes are connected in rows going across and the common cathodes are connected in columns going up, they are the same functionally, with just different IO pins.
So you can use them interchangeably as long as you determine where the top left corner LED is for instance and connect your anode and cathode accordingly and follow suit for the rest of the pins.
For these parts for example:
common cathode, anode-pin9 and cathode-pin16 turns on the top left; common anode, anode-pin8 and cathode-pin9 turns on the top left.


* CommonAnode_vs_CommonCathode.jpg (59.3 KB, 960x720 - viewed 31 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey crossroads.....how ya been.....so I'm working on a new 32x8, my first one worked ok, all the matrices showed the same letter as it scrolled each one individually ...that was with my mega2560......but now I've got a 16x8 scrolling perfect.....I did just rotate the matrices physically....however I add on two more to make it 32x8 and the 3and 4 matrix are blank while 1and 2 scroll across.....I have them cascaded, all caps and resistors in place.....I'm using a nano this time.......ill paste my code in the morning....
Logged

Pages: [1]   Go Up
Jump to: