HSV color with matrixes

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
martian
 
Posts: 112
Joined: Wed Sep 27, 2017 2:17 am

HSV color with matrixes

Post by martian »

Hey there. I have a feather-powered matrix that is doing some unexpected things with color.

When writing to the matrix, treating it as a strip, this works great to create a nice rainbow spectrum:

Code: Select all

for( int i = 0; i < LED_COUNT; i++) {
  uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(i*256));
  strip.setPixelColor(i, rgbcolor); 
  }strip.show(); 
However, when I tried writing to it through the Neomatrix library using

Code: Select all

 matrix.drawPixel(x,y, rgbcolor)
, I'm getting some truly weird and random colors.

I took a closer look at the .drawPixel class in the library file, Adafruit_NeoMatrix.h. It looks like this class accepts a 16 bit color (uint16_t) instead of the 32 bit color (uint32_t). That's weird right? I have to assume that's why I am not getting the right colors.

Am wondering if that HSV and Gamma functionality is limited to use in strips only? Or am I missing something else? It would be a bit of a shame if that nice color wasn't available for a matrix of the same type of pixels.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: HSV color with matrixes

Post by adafruit_support_mike »

As a sanity check, are you using RGB or RGBW pixels? A mismatch there shifts channel values to different colors, and is a common source of weirdness.
martian wrote: Thu Sep 22, 2022 10:39 pm I took a closer look at the .drawPixel class in the library file, Adafruit_NeoMatrix.h. It looks like this class accepts a 16 bit color (uint16_t) instead of the 32 bit color (uint32_t). That's weird right? I have to assume that's why I am not getting the right colors.
Some devices use 5-6-5 color: five bits of red and blue, six bits of green because that's the color humans can see best. The .setPixelColor() routine should automatically translate a 32-bit color to 5-6-5 though.

User avatar
martian
 
Posts: 112
Joined: Wed Sep 27, 2017 2:17 am

Re: HSV color with matrixes

Post by martian »

Yes, these are RGB, not RGBW. .setPixelColor() works fine, like I said, it's .drawPixel() that makes things go wacky.

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”