16x32 RGB led matrix color functions

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Todts
 
Posts: 4
Joined: Sat Mar 22, 2014 5:16 am

16x32 RGB led matrix color functions

Post by Todts »

Hello,

After testing my new adafruit 16x32 RGB led matrix I found out that I also can set my colors as following instead of using matrix.drawPixel(1,1,matrix.Color333(0,7,0));

- matrix.drawPixel(1,1,2016); --> givs me green
- matrix.drawPixel(1,1,63488); --> givs me red

Even if I set my argument to 1 000 000 it givs me orange. I have no idea how this works.
which number do i need if I want pruple?

grtz

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 16x32 RGB led matrix color functions

Post by adafruit_support_rick »

Color333 returns a number which contains the 3 color components packed into a single integer. It does this according to the following formula:

Code: Select all

(r * 8192) + (g * 256) + (b * 4)
where r <= 7, g <= 7 and b <= 7

So, Color333(0, 7, 0) returns
(0 * 8192) + (7 * 256) + (0 * 4) = 1792

Purple might be Color333(5, 7, 0) -> 42752

You can get finer control over color by using the Color444 function, which uses the following formula:

Code: Select all

(r * 4096) + (g * 128) + (b * 2)
where r <= 15, g <= 15 and b <= 15

Todts
 
Posts: 4
Joined: Sat Mar 22, 2014 5:16 am

Re: 16x32 RGB led matrix color functions

Post by Todts »

thank u !!!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”