diff options
author | Aseda Aboagye <aaboagye@google.com> | 2018-03-06 23:14:43 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-03-07 08:17:50 +0000 |
commit | e700bfc2edeb3e431277c6c87c2c3a9992145fd4 (patch) | |
tree | 9676129f50455ba076d14ed1650aa0c622ad9472 | |
parent | 3627c64ccc26a8793d79e96eb2243f6807a632ec (diff) | |
download | chrome-ec-e700bfc2edeb3e431277c6c87c2c3a9992145fd4.tar.gz |
driver: OPT3001: Add attenuation factor.
This commit adds the ability for a board to define an attenuation factor
that will be multiplied against the intermediate value prior to
converting to lux. This helps for cases where lux readout may be very
low and higher precision is desired.
BUG=b:72985601
BRANCH=stabilize-meowth-10444.B
TEST=Flash meowth; verify reported readings are significantly higher
than before in low lux environments.
Change-Id: Ibf46e574fccdde50ceb5f8174f9b4a29e60bfbfe
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/952500
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/nami/board.c | 1 | ||||
-rw-r--r-- | board/poppy/board.c | 1 | ||||
-rw-r--r-- | board/reef/board.c | 1 | ||||
-rw-r--r-- | board/zoombini/board.c | 2 | ||||
-rw-r--r-- | driver/als_opt3001.c | 3 | ||||
-rw-r--r-- | driver/als_opt3001.h | 1 |
6 files changed, 8 insertions, 1 deletions
diff --git a/board/nami/board.c b/board/nami/board.c index d3479d59db..e74cd33a61 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -502,6 +502,7 @@ static struct opt3001_drv_data_t g_opt3001_data = { .scale = 1, .uscale = 0, .offset = 0, + .attenuation_factor = 1, }; /* Matrix to rotate accelrator into standard reference frame */ const matrix_3x3_t base_standard_ref = { diff --git a/board/poppy/board.c b/board/poppy/board.c index 201561dd0f..7e2138c674 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -680,6 +680,7 @@ static struct opt3001_drv_data_t g_opt3001_data = { .scale = 1, .uscale = 0, .offset = 0, + .attenuation_factor = 1, }; /* Matrix to rotate accelrator into standard reference frame */ diff --git a/board/reef/board.c b/board/reef/board.c index fa16408e21..603df62347 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -786,6 +786,7 @@ static struct opt3001_drv_data_t g_opt3001_data = { .scale = 1, .uscale = 0, .offset = 0, + .attenuation_factor = 1, }; /* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Reef */ diff --git a/board/zoombini/board.c b/board/zoombini/board.c index 6ce0198e4a..8d4ecc795a 100644 --- a/board/zoombini/board.c +++ b/board/zoombini/board.c @@ -208,6 +208,8 @@ static struct opt3001_drv_data_t g_opt3001_data = { .scale = 1, .uscale = 0, .offset = 0, + /* Meowth has a dark cover glass. */ + .attenuation_factor = 100, }; /* Base Sensor mutex */ diff --git a/driver/als_opt3001.c b/driver/als_opt3001.c index b3ab198496..344636580d 100644 --- a/driver/als_opt3001.c +++ b/driver/als_opt3001.c @@ -147,7 +147,8 @@ int opt3001_read_lux(const struct motion_sensor_t *s, vector_3_t v) /* * lux = 2EXP[3:0] × R[11:0] / 100 */ - data = (1 << (data >> 12)) * (data & 0x0FFF) / 100; + data = (1 << (data >> 12)) * (data & 0x0FFF) * + drv_data->attenuation_factor / 100; data += drv_data->offset; if (data < 0) data = 1; diff --git a/driver/als_opt3001.h b/driver/als_opt3001.h index eeb05f3a10..60cf115172 100644 --- a/driver/als_opt3001.h +++ b/driver/als_opt3001.h @@ -53,6 +53,7 @@ struct opt3001_drv_data_t { int16_t scale; uint16_t uscale; int16_t offset; + int attenuation_factor; }; extern const struct accelgyro_drv opt3001_drv; |