Mini 8x8 LED Matrix w/I2c backpack
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 18
- Joined: Fri Jun 15, 2012 1:19 am
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.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Mini 8x8 LED Matrix w/I2c backpack
If you look at the example code, you'll see some shapes already coded in:
Let's look at smile_bmp. It looks like this on the matrix:
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:
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
For reference, here are the bit patterns for each of the 16 hexadecimal digits:
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};
Converting 3C to binary we get:
- 0011 1100
- 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
- on off off on off on off on
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: 18
- Joined: Fri Jun 15, 2012 1:19 am
Re: Mini 8x8 LED Matrix w/I2c backpack
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.
Here is what it looks like
again, thank you so very much for the help I appreciate it.
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};
again, thank you so very much for the help I appreciate it.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Mini 8x8 LED Matrix w/I2c backpack
Looks great! Well done!
- bentpins
- Posts: 5
- Joined: Wed Sep 14, 2011 1:19 am
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
Thanks for you help!
Bent
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);
Bent
-
- Posts: 18
- Joined: Fri Jun 15, 2012 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
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 to another number to change the rotation and that will rotate the image.
I hope this helps.
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};
Code: Select all
matrix.setRotation(3);
I hope this helps.
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
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:
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);
- bentpins
- Posts: 5
- Joined: Wed Sep 14, 2011 1:19 am
Re: Mini 8x8 LED Matrix w/I2c backpack
This worked great. Thank you so much for the help!!!!
-
- Posts: 24
- Joined: Fri Oct 19, 2012 11:21 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.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 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.
There are several posts earlier in this thread that explain how to create and scroll bitmaps.
Please be positive and constructive with your questions and comments.