summaryrefslogtreecommitdiffstats
path: root/libsensors
diff options
context:
space:
mode:
authortim.sk.lee <tim.sk.lee@samsung.com>2011-03-11 11:43:56 +0900
committerMathias Agopian <mathias@google.com>2011-03-14 15:17:53 -0700
commit63a931258e7e8f5bd64539ec1224420e8b8f3978 (patch)
treeb1a789e414046492823e43c36e81351e8788f9bc /libsensors
parentc6ce82ef1685d89262c3fe60ea815ced1b5a5c7c (diff)
downloaddevice_samsung_crespo-63a931258e7e8f5bd64539ec1224420e8b8f3978.tar.gz
device_samsung_crespo-63a931258e7e8f5bd64539ec1224420e8b8f3978.tar.bz2
device_samsung_crespo-63a931258e7e8f5bd64539ec1224420e8b8f3978.zip
SENSOR: Ignore the first 350ms gyroscope sensor events
Fixes: Gyro data is wrong for the first 300ms Bug: 4027031i Change-Id: I7f29ffbae7fe665184b018f17efd562069ca60a3 Signed-off-by: tim.sk.lee <tim.sk.lee@samsung.com>
Diffstat (limited to 'libsensors')
-rw-r--r--libsensors/GyroSensor.cpp12
-rw-r--r--libsensors/GyroSensor.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/libsensors/GyroSensor.cpp b/libsensors/GyroSensor.cpp
index 7f6b864..ecebb61 100644
--- a/libsensors/GyroSensor.cpp
+++ b/libsensors/GyroSensor.cpp
@@ -26,14 +26,15 @@
#include "GyroSensor.h"
#define FETCH_FULL_EVENT_BEFORE_RETURN 1
-
+#define IGNORE_EVENT_TIME 350000000
/*****************************************************************************/
GyroSensor::GyroSensor()
: SensorBase(NULL, "gyro"),
mEnabled(0),
mInputReader(4),
- mHasPendingEvent(false)
+ mHasPendingEvent(false),
+ mEnabledTime(0)
{
mPendingEvent.version = sizeof(sensors_event_t);
mPendingEvent.sensor = ID_GY;
@@ -86,6 +87,7 @@ int GyroSensor::enable(int32_t, int en) {
buf[1] = 0;
if (flags) {
buf[0] = '1';
+ mEnabledTime = getTimestamp() + IGNORE_EVENT_TIME;
} else {
buf[0] = '0';
}
@@ -155,9 +157,11 @@ again:
} else if (type == EV_SYN) {
mPendingEvent.timestamp = timevalToNano(event->time);
if (mEnabled) {
- *data++ = mPendingEvent;
+ if (mPendingEvent.timestamp >= mEnabledTime) {
+ *data++ = mPendingEvent;
+ numEventReceived++;
+ }
count--;
- numEventReceived++;
}
} else {
LOGE("GyroSensor: unknown event (type=%d, code=%d)",
diff --git a/libsensors/GyroSensor.h b/libsensors/GyroSensor.h
index e5a9241..e8997de 100644
--- a/libsensors/GyroSensor.h
+++ b/libsensors/GyroSensor.h
@@ -37,6 +37,7 @@ class GyroSensor : public SensorBase {
bool mHasPendingEvent;
char input_sysfs_path[PATH_MAX];
int input_sysfs_path_len;
+ int64_t mEnabledTime;
int setInitialState();