Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

"Adding" neopixel colors
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

"Adding" neopixel colors

by whatamidoing on Mon Mar 09, 2020 8:51 pm

I'm working on a neopixel ring clock. I'm using an Uno, RTC shield, and a 60 pixel ring (except no white)

When the minutes pixel is at the same position as the hours pixel one will overwrite the other, which is the expected behaviour. But is there a simple way for me to "add" the two colors? So if I have say RGB=0,50,0 plus RGB=0,10,50 I get a pixel that is RGB=0,60,50?

It's not too hard for that case where I'm just looking at two pixels, but it becomes tricky when I want to have 12 pixels for the hour markers.

whatamidoing
 
Posts: 26
Joined: Wed Jan 30, 2013 4:49 pm

Re: "Adding" neopixel colors

by whatamidoing on Mon Mar 09, 2020 9:42 pm

This is the two that I want to add together when they at the same pixel.

Code: Select all | TOGGLE FULL SIZE
    while (var < 59) {
       pixels.setPixelColor(var, pixels.Color(hourred, hourgreen, hourblue));
       var = var + 5;
    }
    pixels.setPixelColor(hourspixel, pixels.Color(0, 40, 0)); // this is the hour pixel
    pixels.setPixelColor(minutespixel, pixels.Color(40, 0, 0)); // this is the minutes pixel.

whatamidoing
 
Posts: 26
Joined: Wed Jan 30, 2013 4:49 pm

Re: "Adding" neopixel colors

by jim_lee on Sat Mar 21, 2020 8:57 pm

Just write a function that does exactly what you did on your first post. Its easy. Just.. Wait a second -

You know, I don't actually see where one could, using just the Adafruit stuff, access the RGB values of a color. There are methods for stuffing RGB values into an unsigned 32 bit int. But nothing I see for separating them back out. This user would kinda' need something like that to grab out the RGB values, do math on them, then stuff the result back in.

Or, as always.. Am I missing something?

-jim lee

jim_lee
 
Posts: 648
Joined: Thu May 24, 2012 8:24 pm

Re: "Adding" neopixel colors

by whatamidoing on Sun Mar 22, 2020 10:09 am

Yea, that is the issue. I can put them into the setpixelcolor, but how do I get the individual pixel data out to then add my new color in?

whatamidoing
 
Posts: 26
Joined: Wed Jan 30, 2013 4:49 pm

Re: "Adding" neopixel colors

by adafruit_support_bill on Sun Mar 22, 2020 10:23 am

Use getPixelColor(). It returns a 32 bit (4 byte) value. The first 3 bytes are red, green and blue. When using RGBW pixels, the 4th byte is white.

Code: Select all | TOGGLE FULL SIZE
uint32_t          getPixelColor(uint16_t n) const;

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Re: "Adding" neopixel colors

by whatamidoing on Sun Mar 22, 2020 6:53 pm

Ah ha! Thanks Bill. I missed that.

For anyone who finds this thread, the information is in the uberguide here: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use

whatamidoing
 
Posts: 26
Joined: Wed Jan 30, 2013 4:49 pm

Re: "Adding" neopixel colors

by jim_lee on Sun Mar 22, 2020 10:09 pm

You know I tried and tried to get Adafruit to look at my colorObj class for dealing with colors. I use it for everything, neoPixles, OLEDs, TFTs, RGB LEDS.. Such a handy thing. And you can do blends & fades etc. with it. Never could get any traction.

Sad.

-jim lee

jim_lee
 
Posts: 648
Joined: Thu May 24, 2012 8:24 pm

Re: "Adding" neopixel colors

by adafruit_support_bill on Mon Mar 23, 2020 5:56 am

You know I tried and tried to get Adafruit to look at my colorObj class for dealing with colors.

If you would like to contribute to a library, you can make a pull request on Github.

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.