CYBER MONDAY SALE - Get 15% off! Use the code CYBERMONDAY15 on checkout *some restrictions apply.

Mini 8x8 LED Matrix w/I2c backpack

I have downloaded the adafruit backpack and GFX libraries for the Mini 8x8 LED Matrix w/I2c backpack and everything is working great. I have to play with he code so I understand what effect certain changes make. The only thing I want to do out of the box that I am having trouble with is a heart shape. Does anyone have code to draw a heart? or is there an update to the GFX to include a heart shape? Any help is appreciated.
compukid

Posts: 18
Joined: Fri Jun 15, 2012 1:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

If you look at the example code, you'll see some shapes already coded in:
Code: Select all | TOGGLE FULL SIZE
`static uint8_t __attribute__ ((progmem)) smile_bmp[]={0x3C, 0x42, 0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C};static uint8_t __attribute__ ((progmem)) frown_bmp[]={0x3C, 0x42, 0xA5, 0x91, 0x91, 0xA5, 0x42, 0x3C};static uint8_t __attribute__ ((progmem)) neutral_bmp[]={0x3C, 0x42, 0x95, 0x91, 0x91, 0x95, 0x42, 0x3C};`

Let's look at smile_bmp. It looks like this on the matrix:
smilie.png (560.24 KiB) Viewed 2081 times

The numbers in smile_bmp are hexadecimal (base 16) numbers. Each digit is made up of 4 binary bits. The first number is 3C (the "0x" is a notation which indicates a hexadecimal number).

Converting 3C to binary we get:
0011 1100
If you look at the left-most column of the matrix in the picture, you'll see this same pattern, where 0 is an unlit LED and 1 is a lit LED:
off off on on on on off off
.

So, each hexadecimal number represents a column on the matrix. The next thing to know is that the bit-order is from bottom to top. Look at the third column. The hex value is 95, which is
10010101
We see the same pattern in the picture - from bottom to top in column three:
on off off on off on off on

If you draw your heart on a piece of graph paper, you can then transcribe the columns into your own heart_bmp array.

For reference, here are the bit patterns for each of the 16 hexadecimal digits:
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111

Posts: 22594
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Mini 8x8 LED Matrix w/I2c backpack

This was so very helpful. I am not an artist at all, but I think it came out ok. Here is he code if anyone needs a quick heart.

Code: Select all | TOGGLE FULL SIZE
`static uint8_t __attribute__ ((progmem)) heart1_bmp[]={0x00, 0x0E, 0x11, 0x21, 0x42, 0x21, 0x11, 0x0E};static uint8_t __attribute__ ((progmem)) heart2_bmp[]={0x00, 0x0E, 0x1F, 0x3F, 0x7E, 0x3F, 0x1F, 0x0E};`

Here is what it looks like

again, thank you so very much for the help I appreciate it.
compukid

Posts: 18
Joined: Fri Jun 15, 2012 1:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

Looks great! Well done! :D

Posts: 22594
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Mini 8x8 LED Matrix w/I2c backpack

I was wondering if someone could explain how you would scroll the "smile_bmp" for example?

I took the intuitive step below but it doesn't scroll? Just smiles at me sideways now :)

Code: Select all | TOGGLE FULL SIZE
`  matrix.setRotation(3);  for (uint8_t x=7; x>=-36; x--) {    matrix.clear();    matrix.setCursor(x,0);    matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);    matrix.writeDisplay();    delay(100);`

Thanks for you help!

Bent

bentpins

Posts: 5
Joined: Wed Sep 14, 2011 1:19 am

Re: Mini 8x8 LED Matrix w/I2c backpack

Good question. I am by no means any expert, but I would assume you have to have a line for each movement of the image. like so

Code: Select all | TOGGLE FULL SIZE
`static uint8_t __attribute__ ((progmem)) smile_bmp1[]={0x3C, 0x42, 0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C};static uint8_t __attribute__ ((progmem)) smile_bmp2[]={ 0x42, 0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp3[]={0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp4[]={0xA1, 0xA1, 0x95, 0x42, 0x3C, 0x00, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp5[]={0xA1, 0x95, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp6[]={0x95, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp7[]={0x42, 0x3C, 0x00 0x00, 0x00, 0x00, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp8[]={0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};static uint8_t __attribute__ ((progmem)) smile_bmp9[]={0x00, 0x00, 0x000, 0x00, 0x00, 0x00, 0x00, 0x00};`

again this is a guess and I am sure you can come up with a routine or something that will meet your needs. Oh and to get it to smile at you right side up you have to change the 3 on the following line
Code: Select all | TOGGLE FULL SIZE
` matrix.setRotation(3);`
to another number to change the rotation and that will rotate the image.

I hope this helps.
compukid

Posts: 18
Joined: Fri Jun 15, 2012 1:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

Howdy howdy,

setCursor() relates specifically to text. To position a bitmap, the first two parameters to drawBitmap() are X/Y, so you'd want something like this:

Code: Select all | TOGGLE FULL SIZE
`matrix.drawBitmap(x, 0, smile_bmp, 8, 8, LED_ON);`

pburgess

Posts: 3265
Joined: Sun Oct 26, 2008 2:29 am

Re: Mini 8x8 LED Matrix w/I2c backpack

This worked great. Thank you so much for the help!!!!

bentpins

Posts: 5
Joined: Wed Sep 14, 2011 1:19 am

Re: Mini 8x8 LED Matrix w/I2c backpack

Would anyone please show would I do the heart in a raspberry pi . And how do I make it scroll? Thank u.
holaparc

Posts: 24
Joined: Fri Oct 19, 2012 11:21 am

Re: Mini 8x8 LED Matrix w/I2c backpack

@holaparc
There are several posts earlier in this thread that explain how to create and scroll bitmaps.