summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2011-11-02 20:52:21 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2011-11-02 20:52:21 +0000
commit38d42a11b04daf5a209e6b52c867b811c274430c (patch)
treebee9b62eb152a6c896c3f904df6edb3c6515cd32
parenta0f26eed9e225d9bf02ce4528584b836dcfbdbe6 (diff)
parent63bb261af2ae4213fc8cb0ce81367af63616a773 (diff)
downloaddevice_samsung_tuna-38d42a11b04daf5a209e6b52c867b811c274430c.zip
device_samsung_tuna-38d42a11b04daf5a209e6b52c867b811c274430c.tar.gz
device_samsung_tuna-38d42a11b04daf5a209e6b52c867b811c274430c.tar.bz2
am 63bb261a: Merge "sensors: Return a calculated lux value instead using the current 8 entry table" into ics-mr1
* commit '63bb261af2ae4213fc8cb0ce81367af63616a773': sensors: Return a calculated lux value instead using the current 8 entry table
-rw-r--r--libsensors/LightSensor.cpp43
-rw-r--r--libsensors/LightSensor.h3
-rw-r--r--libsensors/sensors.cpp2
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml10
4 files changed, 13 insertions, 45 deletions
diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp
index 15ae4e2..29b222b 100644
--- a/libsensors/LightSensor.cpp
+++ b/libsensors/LightSensor.cpp
@@ -31,46 +31,17 @@ LightSensor::LightSensor()
{
mPendingEvent.sensor = ID_L;
mPendingEvent.type = SENSOR_TYPE_LIGHT;
- mPreviousLight = -1;
-}
-
-int LightSensor::handleEnable(int en) {
- mPreviousLight = -1;
- return 0;
}
bool LightSensor::handleEvent(input_event const *event) {
if (event->value == -1) {
return false;
}
- mPendingEvent.light = indexToValue(event->value);
- if (mPendingEvent.light != mPreviousLight) {
- mPreviousLight = mPendingEvent.light;
- return true;
- }
- return false;
-}
-
-float LightSensor::indexToValue(size_t index) const {
- /* Driver gives a rolling average adc value. We convert it lux levels. */
- static const struct adcToLux {
- size_t adc_value;
- float lux_value;
- } adcToLux[] = {
- { 50, 10.0 }, /* from 0 - 50 adc, we map to 10.0 lux */
- { 280, 160.0 }, /* from 51 - 280 adc, we map to 160.0 lux */
- { 320, 225.0 }, /* from 281 - 320 adc, we map to 225.0 lux */
- { 350, 320.0 }, /* from 321 - 350 adc, we map to 320.0 lux */
- { 400, 640.0 }, /* from 351 - 400 adc, we map to 640.0 lux */
- { 520, 1280.0 }, /* from 401 - 520 adc, we map to 1280.0 lux */
- { 590, 2600.0 }, /* from 521 - 590 adc, we map to 2600.0 lux */
- { 1024, 10240.0 }, /* from 591 - 1024 adc, we map to 10240.0 lux */
- };
- size_t i;
- for (i = 0; i < ARRAY_SIZE(adcToLux); i++) {
- if (index <= adcToLux[i].adc_value) {
- return adcToLux[i].lux_value;
- }
- }
- return adcToLux[ARRAY_SIZE(adcToLux)-1].lux_value;
+ // Convert adc value to lux assuming:
+ // I = 10 * log(Ev) uA
+ // R = 24kOhm
+ // Max adc value 1023 = 1.25V
+ // 1/4 of light reaches sensor
+ mPendingEvent.light = powf(10, event->value * (125.0f / 1023.0f / 24.0f)) * 4;
+ return true;
}
diff --git a/libsensors/LightSensor.h b/libsensors/LightSensor.h
index ed3b435..f5f8af0 100644
--- a/libsensors/LightSensor.h
+++ b/libsensors/LightSensor.h
@@ -32,10 +32,7 @@ struct input_event;
class LightSensor:public SamsungSensorBase {
- float mPreviousLight;
- virtual int handleEnable(int en);
virtual bool handleEvent(input_event const * event);
- float indexToValue(size_t index) const;
public:
LightSensor();
};
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp
index 96f128d..fb159d9 100644
--- a/libsensors/sensors.cpp
+++ b/libsensors/sensors.cpp
@@ -80,7 +80,7 @@ static struct sensor_t sSensorList[LOCAL_SENSORS + MPLSensor::numSensors] = {
{ "GP2A Light sensor",
"Sharp",
1, SENSORS_LIGHT_HANDLE,
- SENSOR_TYPE_LIGHT, 3000.0f, 1.0f, 0.75f, 0, { } },
+ SENSOR_TYPE_LIGHT, powf(10, 125.0f/ 24.0f) * 4, 1.0f, 0.75f, 0, { } },
{ "GP2A Proximity sensor",
"Sharp",
1, SENSORS_PROXIMITY_HANDLE,
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 55c3d45..5110ae8 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -64,11 +64,11 @@
Must be overridden in platform specific overlays -->
<integer-array name="config_autoBrightnessLevels">
- <item>100</item>
- <item>200</item>
- <item>400</item>
- <item>1000</item>
- <item>3000</item>
+ <item>7</item>
+ <item>107</item>
+ <item>244</item>
+ <item>440</item>
+ <item>4080</item>
</integer-array>
<!-- Array of output values for LCD backlight corresponding to the LUX values