Hi everyone,
I am trying to minimize power requirements for about 1 meter (30 leds/m) length of Led strip (WS2812). I am planning to use 3 AAA batteries to power ATTiny85 and the strip (5v).
I came across this article (https://learn.adafruit.com/sipping-power-with-neopixels/insights#strategy-tone-down-the-brightness-2378053-9)that advises on toning down the brightness through PWM. Now I am totally lost with this, tried to look around but could only find some turorials/help for single LEDs or RGB leds (not addressable ones).
Then there is this demo code where the comments say 50% duty cycle, but I am pulling my hair now trying to understand how was that 50% cycle achieved?
Can someone please explain how in the code below, in the function mode_white_half_duty() , 50% duty cycle was achieved just by passing a color value which is different than mode_white_max(), and then the mode_white_half_perceptual() function claims to be even less than 50% of duty cycle, but how?
I guess what I really want to know is, how to calculate those color values for a specific color that will result in different duty cycles? For example, if I have and RGB color value, how can I convert that into a 50% duty cycle value, if it makes any sense?
// All NeoPixels on at max: white (R+G+B) at 100% duty cycle
void mode_white_max() {
for(uint8_t i=0; i<10; i++) {
CircuitPlayground.strip.setPixelColor(i, 0xFFFFFF);
}
}
// All NeoPixels on at 50% duty cycle white. Numerically speaking,
// this is half power, but perceptually it appears brighter than 50%.
void mode_white_half_duty() {
for(uint8_t i=0; i<10; i++) {
CircuitPlayground.strip.setPixelColor(i, 0x7F7F7F);
}
}
// All NeoPixels on at 50% perceptial brightness, using gamma table lookup.
// Though it visually appears to be about half brightness, numerically the
// duty cycle is much less, a bit under 20% -- meaning "half brightness"
// can actually be using 1/5 the power!
void mode_white_half_perceptual() {
uint32_t c = pgm_read_byte(&gammaTable[127]) * 0x010101;
for(uint8_t i=0; i<10; i++) {
CircuitPlayground.strip.setPixelColor(i, c);
}
}
I understand the gamma correction and the function used to do this, but I fail to understand is that if just doing that will result in different duty cycle? can I control the percentage? Any help will be appreciated. Thanks.