diff options
author | Christian Balster <christian.balster@gmail.com> | 2015-06-02 14:51:42 +0200 |
---|---|---|
committer | forkbomb <keepcalm444@gmail.com> | 2015-11-25 08:34:30 +1100 |
commit | a0449080d1eedfd4980b28bd6e73b177ffd73728 (patch) | |
tree | 231faabd069a63df9c15e9cf0ee97e93f57ff1c7 /libsensors/lsm330dlc_acceleration.c | |
parent | d7864758c2c931aa082e0623bb3d9d1912a53abf (diff) | |
download | device_samsung_i9300-a0449080d1eedfd4980b28bd6e73b177ffd73728.zip device_samsung_i9300-a0449080d1eedfd4980b28bd6e73b177ffd73728.tar.gz device_samsung_i9300-a0449080d1eedfd4980b28bd6e73b177ffd73728.tar.bz2 |
i9300: libsensors: Fix compass orientation (for real)
Actually this fixes several more problems, but the compass orientation
is the most noticeable symptom of this:
Android expects sensor event timestamps in nanoseconds. Linux timestamps
on the other hand are saved in the timeval struct in seconds and micro-
seconds. Therefore these need to be converted, which is easy enough and
is implemented in input.c of libsensors. Unfortunately, the current
implementation uses type long int for the return value and all further
calculations. Since the nanosecond values easily exceed 2^32 the buffers
overflow and wrap, which results in the reported timestamps moving between
-2^16 and 2^16. The consequences of this are noticeable especially with
fused sensors integrating the gyroscope readings, which use the difference
of two timestamps to calculate the change in orientation by multiplying it
by the rotation rate. When the buffer wraps around this results in a huge
time difference and thus leads to a momentary orientation change every
~4.3 seconds.
This commit fixes this behavior by using long long int.
Change-Id: Ib47bdc36ece16371c82f61b125315074ec048e32
Diffstat (limited to 'libsensors/lsm330dlc_acceleration.c')
-rw-r--r-- | libsensors/lsm330dlc_acceleration.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libsensors/lsm330dlc_acceleration.c b/libsensors/lsm330dlc_acceleration.c index 2483cf8..5782d57 100644 --- a/libsensors/lsm330dlc_acceleration.c +++ b/libsensors/lsm330dlc_acceleration.c @@ -49,7 +49,7 @@ void *lsm330dlc_acceleration_thread(void *thread_data) struct input_event event; struct timeval time; struct lsm330dlc_acc acceleration_data; - long int before, after; + long long int before, after; int diff; int device_fd; int uinput_fd; |