diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-12-26 11:39:12 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-12-26 11:39:12 +0100 |
commit | ba778ead40ddf8f1282e78cc8b5dd42e6c4fe1c5 (patch) | |
tree | d68a9d003ed09ede30b653ac374e05ac67e45a58 /src/driver | |
parent | 05644dec7f2ecffa26dc04b9be8d6ad03a2e79ea (diff) |
max44009: handle overrange condition
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/max44009.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/driver/max44009.cc b/src/driver/max44009.cc index bab4da5..8a8ff3e 100644 --- a/src/driver/max44009.cc +++ b/src/driver/max44009.cc @@ -2,6 +2,9 @@ * Copyright 2020 Daniel Friesel * * SPDX-License-Identifier: BSD-2-Clause + * + * Driver for MAX44009 Ambient Light Sensor. + * Does not support interrupts. */ #include "driver/max44009.h" #if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c) @@ -37,6 +40,11 @@ float MAX44009::getLux() */ exponent = (luxHigh & 0xF0) >> 4; + if (exponent == 0x0f) { + // overrange condition + return -1; + } + /* * Cast base and mantissa to float to avoid calculation errors * because of 16bit integer overflows. |