Simulate a sub-LSB resolution inside the ADC IRQ handler. We do multiple
measurements of PWMLED resistor anyway, so it makes sense to modify the
PWM value after each reading. And indeed, experiments show less flicker
of PWM LEDs with this patch.
It is probably an overkill, and can be called only when measuring the
PWMLED output (and not ambient light sensor, for example). But it works
and it is simple enough.
ADCSRA |= _BV(ADSC);
adc_sum += adcval;
read_count--;
+ pwm_timer();
return;
}