RGB LED COLOR Library

So I am looking at a Library that controls the colors of an RGB LED and considering it's RGB it can do pretty much any color right?

So as I examined the code I found the part in rgbled.cpp which is as follows:

void LED::setBackgroundColor(byte index, Color color)
{
	index %= _section_count;
	_buff[index] &= 0x1fff;
	_buff[index] |= color << 13;
}

and this references rgbled.h

which defines colors as:

enum Color
{
	White, Magenta, Cyan, Blue, 
	Yellow, Red, Green, Black,
};

How does it tell the LED exactly what colors to use? How do I add more?

I don't understand how it's converting the string for the color say "Green" and sending that to the LED as such.

Anyone know?

Find where it defines values for White, Magenta, Cyan, Blue, Yellow, Red, Green, and Black. That should tell you how many bits are set aside for each primary color.

Well I did but it has nothing else that references colors... Would you mind looking at the whole library?

I have attached it.

Thank You

NixieTube.zip (3.75 KB)

Silly me! The 'enum' assigns values to the identifiers.

White == 0
Magenta == 1
Cyan == 2
Blue == 3
Yellow == 4
Red == 5
Green == 6
Black == 7

Looks like the top 3 bits represent: Not Blue, Not Red, Not Green. Turn off all three to to get White. Turn on all three to get Black.

The remaining 13 bits could be a brightness value but the color seems to be limited to those 8 values.

Well I do appreciate the information you have provided thus far that is way more then even I was able to figure out. I even tried adding new colors to the list but got pretty weird results.

So if I understand you correctly it's not possible to add new colors based on the way it presently functions or have I misunderstood?

If I could just get purple that would mean the world to me. lol

Pyrex:
So if I understand you correctly it's not possible to add new colors based on the way it presently functions or have I misunderstood?

That appears to be the case. Magenta is as close as you will get to purple.

But why is it impossible? I still can't make heads or tails of how it even works in the first place...

void LED::setBackgroundColor(byte index, Color color)
{
	index %= _section_count;
	_buff[index] &= 0x1fff;
	_buff[index] |= color << 13;
}

Whatever 0x1fff is must have something to do with it right?

Whatever 0x1fff is must have something to do with it right?

That value preserves the part of each output word that is NOT the background color. Those other parts of the word seem to control which digits are illuminated in the nixie tube and which of the two colon dots are illuminated. If you want more control over the background color you can connect the RGB LEDs to PWM output pins and control them directly rather than driving them from the shift registers that drive the Nixie tubes. There are plenty of examples of controlling RGB LEDs with PWM pins.

It would not be possible in this case as the units are modular.

The unit in the little bad is the NIXI TUBE Module.

I wrote an RGB Library today that drives a similar RGB LED behind the tubes but I did not think about trying to make it work behind a shift register, I assume it's not possible? Or can it somehow be done?

The developer sent me this chart and said the following "Now the library is only provide simple colors, if you want an RGB color, you need a PWM control base on serial data." (was in Chinese so it is a little odd sounding)

So what do you think

Also found this topic: Arduino, 74HC595 and PWM; how? - Syntax & Programs - Arduino Forum

Maybe with some help someone can maybe help me do this? =/

Or am I just screwed... ?

There are chips that can do PWM dimming on a bunch of LEDs:

I believe these will drive Common Anode RGB LEDs. The 24-channel model will allow full color control of eight RGB LEDs and the 12-channel model will control four RGB LEDs.

If your LEDs are Common Cathode you may be out of luck.

This code below gives me purple but as I need the loop for clock functions I do not know how practical it would be...

/*
 * PURPLE NIXI TUEBE POC
 *     BY: JONATHAN MAES
*/

#include <NixieTube.h>
 
NixieTube tube(11, 12, 13, 10, 1);  // NixieTube(DIN,ST,SH,OE,NUM)

void setup(){
   tube.setBrightness(0xff);
   tube.display();
}
 
void loop(){

    tube.setBackgroundColor ((Color) 5);
    tube.display();
 
delay (5);

    tube.setBackgroundColor ((Color) 3);
    tube.display();
    
delay (18);

}