Calculating Color

A project log for 2014 DEFCON Hat

What is that on your head?

Mike SzczysMike Szczys 07/25/2014 at 21:520 Comments

Okay, so it's fun to have multiple colors -- otherwise why use RGB strips?

So far I have two colors, red for stock messages and green for hacked messages. What's the big deal, how hard could it be to add more colors? Well, there's a few things to consider.

First off, I'm using a bit-packed array as a frame buffer. That is to say, each pixel is one bit in an array so there is no room for a different color code for each pixel. At the very least this would require one byte for each of pixels in the 32x7 array. To make that meaninful I'd need equally large arrays to store the messages. Not this time around.

The second thing that makes color choices tricky is that I'm limited on how much current I can supply. This display is running from a 6000 mAh external cellphone battery. I'd like to pull less that 2A. I figure the character "8" has the most illuminated pixels. If filled the display with 8's and drove those pixels with all three colors at full brightness: 5.3 characters x 17 pixels x 60 mA = 5.4A. 

Even though I could pull 2A, I want the battery to last longer than that. So I want to run single colors at 66% intensity, and mixed colors at an equal level.

Primary colors are easy:

Mathematically mixes should sum to decimal 170:

I'm not sure if there's a simple way to do this programmatically. For now I'm going to store these values in a PROGMEM array.