Go Down

Topic: 10x led matrix with 7219 for clock (Read 3516 times)previous topic - next topic

pixelmagic

Nov 03, 2013, 01:50 pm
Hi all,

I have started a project to make a large digital clock (12cm height and 30cm wide) with LED matrix displays, 10 in total with the clock having two rows. I want to add a RTC and alarm option to it but before i can get to them I need some help in the best way of driving the displays to get the output I want. I indent to use the code from here.

The layout I want is shown in the attachment, the problem I have is with addressing the right displays with a specific number of the time, the first and last digit are on 1 matrix, so I see no problem here. The middle two digits overlap to the next matrix and here is where I am lost at the moment. The middle matrix need to display the outer row from its neigbours digit, and in the perfect world I would like the dots ( to blink.

I have been thinking on making patterns for every minute from 00:00 up to 23:59 but that seems like total overkill. Second option i have is making the basic patterns for digit 1 and 4 and and for digit 2 and 3 separate patterns and re-using the double one. Then I need a conversion table to use what patterns for what time to display.

All together it seems like a lot of overhead and I wonder if there could be some better way in doing this, basicly only needing the patterns for the digits itself and some code to light the right LEDs. Any help is appreciated !

Erwin

fungus

#1
Nov 03, 2013, 02:21 pm
If you rotate the matrices 90 degrees clockwise then the problem vanishes. You get 40 rows of 16  pixels and it's easy to draw a digit starting at any row (which is the real problem).

If you can't physically rotate the matrices then do the same thing in software:

Store an imaginary clock display as 80 bytes in RAM (two bytes per row, 40 rows) as if the matrix were rotated. This really simplifies the drawing code. Update your imaginary display in those 80 bytes of RAM.

Now you need a function to shuffle those bits around to match the hardware layout, then copy them to the physical matrix.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

arduinodlb

#2
Nov 03, 2013, 08:29 pmLast Edit: Nov 03, 2013, 08:34 pm by arduinodlb Reason: 1
Or,

Think of the matrix as 40 columns by 16 rows (no rotation). Then, just write a function to display a number at an offset from the left most column (0) to the right most column (39).

So, to display the time, you would have something like:

Code: [Select]

void DrawCurrentTime()
{
// the first parameter is the column to draw in, the second parameter is the character to draw
DrawNum(0, '8');   // draw the number '8' on the very left
DrawNum(9, '8');   // draw the number '8' starting in the 9th column
DrawNum(19, ':');  // draw the ':'
DrawNum(23, '8');
DrawNum(32, '8');
}
Do not IM me. I will not respond. Ask questions in the forum.

#3
Nov 03, 2013, 10:32 pm
Or just spread the 1,2 and 4,5 digits apart so that real space makes the gap instead of an LED that will not be on.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

marco_c

#4
Nov 03, 2013, 11:11 pmLast Edit: Nov 04, 2013, 01:08 am by marco_c Reason: 1
Agree with Crossroads. unless you are going to do animations or other graphics type fancy stuff, then you really only need the matrices for digits 1, 2, 3, 4. The ':' between the digits can just be LEDs (two or more), driven directly from the microcontroller.

If you want to use the displays as you have them, you may also want to look at the hardware and code for the Parola displays (see the signature block below). You can define your own character set as the top and bottom half of each digit and then write the data using the offset technique, as stated in a previous post.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

fungus

#5
Nov 04, 2013, 12:57 am

Agree with Crossroads. unless you are going to do animations or other graphics type fancy stuff, then you really only need the matrices for digits 1, 2, 3, 4. The ':' between the digits can just be LEDs (two or more), driven directly from the microcontroller.

It won't look as pretty. The extra column of pixels on the digits adds a lot.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

#6
Nov 04, 2013, 01:01 am

Think of the matrix as 40 columns by 16 rows (no rotation). Then, just write a function to display a number at an offset from the left most column (0) to the right most column (39).

Writing code to do that isn't easy.

The whole point of rotating the matrices/data was to make that part of the code easy at the expense of having to transpose the data later on (not too difficult).
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#7
Nov 04, 2013, 01:02 am
Put a bezel in front, enhances viewability, disguises the fact that you don't have 42 columns.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#8
Nov 04, 2013, 01:42 amLast Edit: Nov 04, 2013, 02:05 am by CrossRoads Reason: 1
I agree with the data as columns idea.
Write the fonts as ints, upper byte goes to upper MAX7219, lower byte goes to lower MAX7219.
For example:
Code: [Select]

c 01234567
0 01111110
1 11111111
2 11000011
3 11000011
4 11000011
5 11000011
6 11000011
7 01111110
8 01111110
a 11000011
b 11000011
c 11000011
d 11000011
e 11111111
f 01111110

So the int's would be (just the columns above):
Code: [Select]

digitArray[] = {
0b0111111001111110,  // 8 ints for #8
0b1100000110000011,
0b1100000110000011,
0b1100000110000011,
0b1100000110000011,
0b1100000110000011,
0b1100000110000011,
0b0111111001111110,
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

arduinodlb

#9
Nov 04, 2013, 02:42 amLast Edit: Nov 04, 2013, 02:46 am by arduinodlb Reason: 1

Think of the matrix as 40 columns by 16 rows (no rotation). Then, just write a function to display a number at an offset from the left most column (0) to the right most column (39).

Writing code to do that isn't easy.

Yes it is.

Quote

The whole point of rotating the matrices/data was to make that part of the code easy at the expense of having to transpose the data later on (not too difficult).

I get that. I'm just providing an alternative. Conceptually, it's easier to think of the panel in the horizontal plane so if it were me, I would do it that way. The code is no harder, just different.
Do not IM me. I will not respond. Ask questions in the forum.

pixelmagic

#10
Nov 04, 2013, 04:49 pm
Thanks for the ideas so far !

Rotating is an good option since I have not build anything, I will take this as a first choice at the moment and search for some good solutions from there. I have only got 2 matrices at the moment, orderd some more but will try to make some code soon for testing the rotated matrix with those two.

Keeping a 'gap' between the matrix is not an option, I want to be able to change the layout later on to display the alarm time when set on a side (90 degrees rotated or so) and then make the digits smaller.

fungus

#11
Nov 04, 2013, 06:30 pm
If you can physically rotate the matrices than it's definitely, 100% the way to go.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#12
Nov 04, 2013, 09:55 pm
I don't see how rotating an 8x8 matrix helps?
If they are common cathode, they really need to be arranged as 8 vertical columns, otherwise you have to mess around a lot in software to rotate things.
If you have an array of 40 ints holding your digits or pattern or whatever, then you only need to send the upper byte to one display and the byte to the display below, and work your way thru 40 bytes across the 5 pairs of MAX7219s.
Want to change a digit? Pull the 8 ints from progmem and put them in the array, then send the array to the MAX7219s.
Is there any chance we are saying the same thing but in different words?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

fungus

#13
Nov 04, 2013, 10:14 pm

I don't see how rotating an 8x8 matrix helps?

It makes the code for drawing the graphics much easier.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

#14
Nov 04, 2013, 10:17 pm

Think of the matrix as 40 columns by 16 rows (no rotation). Then, just write a function to display a number at an offset from the left most column (0) to the right most column (39).

Writing code to do that isn't easy.

Yes it is.

No it isn't. Drawing text at an arbitrary horizontal position needs a lot of bit shifting and twiddling. It's basically a monochrome sprite routine.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up

Please enter a valid email to subscribe