summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-12-26 22:12:15 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-12-26 22:12:15 +0100
commit095e405c93ccdb6f8a358697f68a394ce1654999 (patch)
tree70e5726e8865e242f1215eee331ddc33002c9dde
parentaa51f780fb72969006f96bbd18e9260b8452913e (diff)
MAX44006: Adjust for AMBTIM setting
-rw-r--r--src/driver/max44006.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/driver/max44006.cc b/src/driver/max44006.cc
index 50eaf0f..b0df238 100644
--- a/src/driver/max44006.cc
+++ b/src/driver/max44006.cc
@@ -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;