summaryrefslogtreecommitdiffstats
path: root/libsensors
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2010-10-17 18:53:11 -0700
committerSimon Wilson <simonwilson@google.com>2010-10-17 18:53:11 -0700
commitc282639e63b733a181a27128cf761e08d515c92a (patch)
treef40e9ef31eda20fe1c64e477418847755973bf3f /libsensors
parent04cdb18b02e0275b4c369b254224afdcbef7920d (diff)
downloaddevice_samsung_crespo-c282639e63b733a181a27128cf761e08d515c92a.tar.gz
device_samsung_crespo-c282639e63b733a181a27128cf761e08d515c92a.tar.bz2
device_samsung_crespo-c282639e63b733a181a27128cf761e08d515c92a.zip
libsensor: suppress light levels that don't change
Change-Id: I75f3d0baeae13ff6f10947252b173a062a66d74a
Diffstat (limited to 'libsensors')
-rw-r--r--libsensors/LightSensor.cpp4
-rw-r--r--libsensors/LightSensor.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp
index fa08685..750d8cd 100644
--- a/libsensors/LightSensor.cpp
+++ b/libsensors/LightSensor.cpp
@@ -99,6 +99,7 @@ int LightSensor::setInitialState() {
struct input_absinfo absinfo;
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_LIGHT), &absinfo)) {
mPendingEvent.light = indexToValue(absinfo.value);
+ mPreviousLight = mPendingEvent.light;
mHasPendingEvent = true;
}
return 0;
@@ -135,10 +136,11 @@ int LightSensor::readEvents(sensors_event_t* data, int count)
}
} else if (type == EV_SYN) {
mPendingEvent.timestamp = timevalToNano(event->time);
- if (mEnabled) {
+ if (mEnabled && (mPendingEvent.light != mPreviousLight)) {
*data++ = mPendingEvent;
count--;
numEventReceived++;
+ mPreviousLight = mPendingEvent.light;
}
} else {
LOGE("LightSensor: unknown event (type=%d, code=%d)",
diff --git a/libsensors/LightSensor.h b/libsensors/LightSensor.h
index 42158e4..78e781a 100644
--- a/libsensors/LightSensor.h
+++ b/libsensors/LightSensor.h
@@ -39,6 +39,7 @@ class LightSensor : public SensorBase {
int input_sysfs_path_len;
int setInitialState();
+ float mPreviousLight;
float indexToValue(size_t index) const;
public: