-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add brightness control #14
Conversation
(channel->leds[i] >> 0) & 0xff, // blue | ||
(((channel->leds[i] >> 8) & 0xff) * scale) >> 8, // green | ||
(((channel->leds[i] >> 16) & 0xff) * scale) >> 8, // red | ||
(((channel->leds[i] >> 0) & 0xff) * scale) >> 8, // blue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - this is an adaptation of the python scaling code which is, in turn, an adaptation of the original Adafruit arduino scaling code. So I'm merely standing on the shoulders of my predecessors.
Looks good. I like the algorithm, it's clever. I'm only really concerned with users that assume full brightness as the default. I think the python examples would do this if not changed. If I understand the changeset correctly, the LEDs will most likely remain dark if they didn't initialize the brightness. |
Correct, the LEDs will be dark unless the brightness is explicitly set to a value other than zero. This is a backwards incompatible change; existing code will need to be updated in order to continue functioning properly. Unfortunately there is not a good work around for this scenario. If the |
Another note. I did not update the python code at all. Let me do that before merging in this PR. |
Looks good. I'll do some testing, and get this merged in. Thanks. |
The arduino library for neo pixels is quite nice in that it has a brightness control. This is a simple scaling that is applied to each pixel to control the overall luminosity of the pixel. This is an implementation of brightness for the raspberry pi library.
The leds array for the channel is unaffected by these changes. The brightness scaling is applied to each led as the colors are rendered to the PWM channel.