From 580f18a0b2b1dbb94199e9084934b00c0d0b8cd0 Mon Sep 17 00:00:00 2001 From: Patrick Porlan Date: Tue, 14 Apr 2015 14:21:58 +0200 Subject: [PATCH] GMINL-7944: Ignore ALS intensity if illuminance is available ALS drivers are increasing in sophistication and are now exposing a variety of values, that we don't want to expose as different sensors. Add arbitration code that will prioritize illuminance over intensity. Change-Id: I52fc3fb3e11be08ec62488a86bab7c04d06946f6 Signed-off-by: Patrick Porlan --- control.c | 2 +- enumeration.c | 34 ++++++++++++++++++++++++++++++++++ transform.c | 3 +++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/control.c b/control.c index e260b94..189d499 100644 --- a/control.c +++ b/control.c @@ -536,7 +536,7 @@ static void* acquisition_routine (void* param) /* Initialize data fields that will be shared by all sensor reports */ data.version = sizeof(sensors_event_t); data.sensor = s; - data.type = sensor[s].type; + data.type = sensor_desc[s].type; num_fields = get_field_count(s, &field_size); diff --git a/enumeration.c b/enumeration.c index fa02c28..f0fa564 100644 --- a/enumeration.c +++ b/enumeration.c @@ -882,6 +882,37 @@ static void setup_trigger_names (void) } } + +static int catalog_index_from_sensor_type (int type) +{ + /* Return first matching catalog entry index for selected type */ + unsigned int i; + + for (i=0; idata, sensor[s].order); sensor[s].event_count++; + switch (sensor[s].type) { case SENSOR_TYPE_ACCELEROMETER: /* Always consider the accelerometer accurate */ @@ -342,6 +343,8 @@ static int finalize_sample_default (int s, sensors_event_t* data) case SENSOR_TYPE_LIGHT: case SENSOR_TYPE_AMBIENT_TEMPERATURE: case SENSOR_TYPE_TEMPERATURE: + case SENSOR_TYPE_INTERNAL_ILLUMINANCE: + case SENSOR_TYPE_INTERNAL_INTENSITY: /* Only keep two decimals for these readings */ data->data[0] = 0.01 * ((int) (data->data[0] * 100)); -- 2.11.0