Mini 8x8 LED Matrix w/I2c backpack

by compukid on Mon Sep 17, 2012 7:44 am

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 12:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

by adafruit_support_rick on Mon Sep 17, 2012 8:13 am

If you look at the example code, you'll see some shapes already coded in:
Code: Select all
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
smilie.png (560.24 KiB) Viewed 1835 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
User avatar
adafruit_support_rick
 
Posts: 8613
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Mini 8x8 LED Matrix w/I2c backpack

by compukid on Tue Sep 18, 2012 7:51 am

Your the greatest (Pun intended)

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
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
Image

Image


again, thank you so very much for the help I appreciate it.
compukid
 
Posts: 18
Joined: Fri Jun 15, 2012 12:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

by adafruit_support_rick on Tue Sep 18, 2012 9:50 am

Looks great! Well done! :D
User avatar
adafruit_support_rick
 
Posts: 8613
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Mini 8x8 LED Matrix w/I2c backpack

by Bentpins on Fri Sep 28, 2012 1:21 am

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
  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 12:19 am

Re: Mini 8x8 LED Matrix w/I2c backpack

by compukid on Fri Sep 28, 2012 8:18 am

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
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
 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 12:19 am
Location: New York

Re: Mini 8x8 LED Matrix w/I2c backpack

by pburgess on Fri Sep 28, 2012 8:51 am

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
matrix.drawBitmap(x, 0, smile_bmp, 8, 8, LED_ON);
User avatar
pburgess
 
Posts: 2193
Joined: Sun Oct 26, 2008 1:29 am

Re: Mini 8x8 LED Matrix w/I2c backpack

by Bentpins on Tue Oct 02, 2012 10:36 pm

This worked great. Thank you so much for the help!!!!
Bentpins
 
Posts: 5
Joined: Wed Sep 14, 2011 12:19 am

Re: Mini 8x8 LED Matrix w/I2c backpack

by holaparc on Sat Dec 01, 2012 11:51 pm

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 10:21 am

Re: Mini 8x8 LED Matrix w/I2c backpack

by adafruit_support_rick on Mon Dec 03, 2012 9:49 am

@holaparc
There are several posts earlier in this thread that explain how to create and scroll bitmaps.
User avatar
adafruit_support_rick
 
Posts: 8613
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY