Commit 498efcd0 authored by Brian Masney's avatar Brian Masney Committed by Jonathan Cameron

staging: iio: tsl2x7x: correct integration time and lux equation

The integration_time sysfs attribute did not report the correct
time. Changing the integration time would cause the reported lux to
change wildly. Once the integration time was corrected, all of the
equations, and lux tables needed to be corrected to match what the
data sheets expected. This patch corrects all of this, and adds some
more comments about how some of the constants were derived. Here are
the results from testing a TSL2772 hooked up to a Raspberry Pi 2:

# cat in_intensity0_integration_time
0.002730
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55
# echo 0.65 > in_intensity0_integration_time
# cat in_intensity0_integration_time
0.649740
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55 with noticeable lag to lux changes in watch
; process.

; Now test the ALS calibration routine.
# cat in_intensity0_calibbias
1000
# cat in_illuminance0_target_input
150
# echo 1 > in_illuminance0_calibrate
# cat in_intensity0_calibbias
2777
# watch -n .1 cat in_illuminance0_input
; Lux now hovers around 150-155

The returned lux values were tested on a TSL2772 in various lighting
conditions and the results are within the lux ranges described at
https://en.wikipedia.org/wiki/Lux.

The driver was primarily tested using a TSL2772, however some quick tests
were also ran against the devices TSL2771, TSL2572, and TMD2772.
Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 11031d7d
This diff is collapsed.
......@@ -10,13 +10,12 @@
#define __TSL2X7X_H
struct tsl2x7x_lux {
unsigned int ratio;
unsigned int ch0;
unsigned int ch1;
};
/* Max number of segments allowable in LUX table */
#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
#define TSL2X7X_MAX_LUX_TABLE_SIZE 6
/* The default LUX tables all have 3 elements. */
#define TSL2X7X_DEF_LUX_TABLE_SZ 3
#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment