break;
case 3: // ambient light: 1.1V, ADC5 (PA6), single-ended
ADMUX = _BV(REFS1) | _BV(MUX2) | _BV(MUX0);
- sum_shift = 0; // 1 measurement
+ sum_shift = 3; // 3 measurements
break;
case 4: // batt voltage: 1.1V, ADC6 (PA7), single-ended
ADMUX = _BV(REFS1) | _BV(MUX2) | _BV(MUX1);
if (current_adc < N_PWMLEDS)
pwmled_adc(current_adc, adc_sum);
if (current_adc == AMBIENT_ADC)
- ambient_adc(adcval);
+ ambient_adc(adc_sum);
if (current_adc == BATTERY_ADC)
battery_adc(adcval);
* and having small overlaps in order to provide a bit of hysteresis.
*/
static ambient_zone_t ambient_zones[] = {
- { 0x0000, 0x3120 }, // dark
- { 0x30f0, 0x5000 },
+ { 0x0000, 0x3400 }, // dark
+ { 0x3300, 0x5000 },
{ 0x4c00, 0x8000 },
{ 0x7800, 0xffff }
};
{
unsigned char old_zone = ambient_zone;
- ambient_val += adcval - (ambient_val >> 6);
+ ambient_val += adcval - (ambient_val >> 3);
while (ambient_zones[ambient_zone].lo > ambient_val)
ambient_zone--;