Go Down

Topic: Code for Dot Matrix custom icons (Read 2259 times) previous topic - next topic

WWouter

Hey everybody,
I've connected a MAX7219 dot matrix display to my arduino. What code do I need to just show custom icons, so not regular ASCII symbols. eventually I want to skip to 7 icons with a simpel pushbutton.
I've tried a lot of example sketches, but I cannot understand them enough to change them for my purpose.

Thanks a bunch.

CrossRoads

Make yourself a chart like this, I used Excel, and translate your icon into 1s & 0s. You will then send these bytes to the MAX72319 to display.
Using HEX format makes it easy to keep the program size smaller.
Can also use binary format: 0b00000001 vs 0x01, 0b01000001 vs 0x41, etc.
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.

WWouter

Thanks, good tip, i'm going to try that.

WWouter

Hey one more question. what function do i need for the hex format? something like setChar or something? i can't seem to make this happen.

CrossRoads

No function needed.
SPI.transfer(0x41);

or
byte fontArray [] = {
0x00, 0x41, 0x25, 0x91, 0x47,
};

then
SPI.transfer(fontArray[2]); // looks up 3rd element in the array (array index starts at 0),
so 0x25 in this example
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.

WWouter

Your example doesn't do anything, and I don't understand it enough to make it work. Can you perhaps explain it a bit more?

CrossRoads

Your code will periodically send data to the MAX7219 registers, which then get multiplexed onto the display.

To send the data, you can call this:
Code: [Select]

// do an update
for (x=1; x<9; x=x+1){
digitalWrite (ssPin, LOW);
SPI.transfer(x); // send data register address, 1 to 8
SPI.transfer (dataArray[x-1]); // arrays are indexed starting at 0
digitalWrite (ssPin, HIGH);
}

This will put 8 bytes of data into 8 data registers for display.
There 4 or 5 control registers, you will set them up with data the same way in setup() as they only need to run once. See Table 2 in the data sheet:
shutdown register - set to normal mode
no-decode mode - your data is used as is
lamp-test - can turn on & then off to make all LEDs flash once
intensity - sets brightness of the LEDs
scan limit - how many columns (digits) are being used - for an 8x8 matrix, set for 8
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.

Go Up