diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-12-26 22:12:15 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-12-26 22:12:15 +0100 |
commit | 095e405c93ccdb6f8a358697f68a394ce1654999 (patch) | |
tree | 70e5726e8865e242f1215eee331ddc33002c9dde | |
parent | aa51f780fb72969006f96bbd18e9260b8452913e (diff) |
MAX44006: Adjust for AMBTIM setting
-rw-r--r-- | src/driver/max44006.cc | 14 |
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; |