Commit 095e405c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

MAX44006: Adjust for AMBTIM setting

parent aa51f780
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ uint16_t MAX44006::getTemperature()
		return 0;
	}

	// independent of AMBPGA setting, depends on AMBTIM
	return (((uint16_t)rxbuf[0] << 8) + rxbuf[1]);
}

@@ -80,6 +81,19 @@ bool MAX44006::getLight(float *red, float *green, float *blue, float *clear, flo
		multiplier = 0.512;
	}

	if ((ambientConfig & AMBTIM_MASK) == AMBTIM_001) {
		multiplier *= 4;
	}
	else if ((ambientConfig & AMBTIM_MASK) == AMBTIM_010) {
		multiplier *= 16;
	}
	else if ((ambientConfig & AMBTIM_MASK) == AMBTIM_011) {
		multiplier *= 64;
	}
	else if ((ambientConfig & AMBTIM_MASK) == AMBTIM_100) {
		multiplier *= 0.25;
	}

	*clear = (float)(((uint16_t)rxbuf[0] << 8) + rxbuf[1]) * multiplier;
	*red   = (float)(((uint16_t)rxbuf[2] << 8) + rxbuf[3]) * multiplier;
	*green = (float)(((uint16_t)rxbuf[4] << 8) + rxbuf[5]) * multiplier;