From f8b2c0625e957726c55d4d21c101c0b4e4d052ba Mon Sep 17 00:00:00 2001 From: Ziyan Date: Thu, 13 Aug 2015 00:57:12 +0200 Subject: espresso-common: libsensors: store previous orientation values Since we only get updates from the sensor, it is needed to save (and return) all axis values. Change-Id: Ibe4448262f17d6a15154d16ecb0acc476b3399f0 --- libsensors/yas_orientation.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libsensors/yas_orientation.c b/libsensors/yas_orientation.c index c14ed72..3d74e31 100644 --- a/libsensors/yas_orientation.c +++ b/libsensors/yas_orientation.c @@ -39,6 +39,8 @@ struct yas_orientation_data { char path_enable[PATH_MAX]; char path_delay[PATH_MAX]; + + sensors_vec_t orientation; }; int yas_orientation_init(struct piranha_sensors_handlers *handlers, @@ -234,15 +236,18 @@ float yas_orientation_convert(int value) int yas_orientation_get_data(struct piranha_sensors_handlers *handlers, struct sensors_event_t *event) { + struct yas_orientation_data *data; struct input_event input_event; int input_fd; int rc; // ALOGD("%s(%p, %p)", __func__, handlers, event); - if (handlers == NULL || event == NULL) + if (handlers == NULL || handlers->data == NULL || event == NULL) return -EINVAL; + data = (struct yas_orientation_data *) handlers->data; + input_fd = handlers->poll_fd; if (input_fd < 0) return -EINVAL; @@ -252,6 +257,10 @@ int yas_orientation_get_data(struct piranha_sensors_handlers *handlers, event->sensor = handlers->handle; event->type = handlers->handle; + event->orientation.azimuth = data->orientation.azimuth; + event->orientation.pitch = data->orientation.pitch; + event->orientation.roll = data->orientation.roll; + do { rc = read(input_fd, &input_event, sizeof(input_event)); if (rc < (int) sizeof(input_event)) @@ -277,6 +286,10 @@ int yas_orientation_get_data(struct piranha_sensors_handlers *handlers, } } while (input_event.type != EV_SYN); + data->orientation.azimuth = event->orientation.azimuth; + data->orientation.pitch = event->orientation.pitch; + data->orientation.roll = event->orientation.roll; + return 0; } -- cgit v1.1