PCA9685 for LED strips - Gamma correction?

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
User avatar
timfield
 
Posts: 8
Joined: Fri Mar 29, 2013 3:21 pm

PCA9685 for LED strips - Gamma correction?

Post by timfield »

So I've got Adafruit's PCA9685 12-bit PWM driving multiple LED strips quite nicely. But I'm wondering how to apply the 8-bit Adafruit Gamma Correction Table (https://learn.adafruit.com/led-tricks-g ... -quick-fix) to this 12-bit controller?

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

Re: PCA9685 for LED strips - Gamma correction?

Post by adafruit_support_mike »

You could make a 4096-entry table, but it's probably easier to do something like:

Code: Select all

int pwmLevel;	// original 12-bit value for the PCA9685
int output = ( pwmLevel * gamma[ pwmLevel >> 4 ] ) / 256;
The gamma table is basically a list of scaling factors, and dividing each entry by 256 gives you a fraction you can apply to any value.

Shift your 12-bit PWM value right four bits to get an index into the table, then use that value as your scaling factor.

User avatar
timfield
 
Posts: 8
Joined: Fri Mar 29, 2013 3:21 pm

Re: PCA9685 for LED strips - Gamma correction?

Post by timfield »

Okay, thanks... will give that a try!

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

Return to “Other Arduino products from Adafruit”