/* 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);
}
}
+
+static int catalog_index_from_sensor_type (int type)
+{
+ /* Return first matching catalog entry index for selected type */
+ unsigned int i;
+
+ for (i=0; i<catalog_size; i++)
+ if (sensor_catalog[i].type == type)
+ return i;
+
+ return -1;
+}
+
+
+static void post_process_sensor_list (char poll_map[catalog_size], char trig_map[catalog_size], char event_map[catalog_size])
+{
+ int illuminance_cat_index = catalog_index_from_sensor_type(SENSOR_TYPE_INTERNAL_ILLUMINANCE);
+ int intensity_cat_index = catalog_index_from_sensor_type(SENSOR_TYPE_INTERNAL_INTENSITY);
+ int illuminance_found = poll_map[illuminance_cat_index] || trig_map[illuminance_cat_index] || event_map[illuminance_cat_index];
+
+ /* If an illumimance sensor has been reported */
+ if (illuminance_found) {
+ /* Hide any intensity sensors we can have for the same iio device */
+ poll_map [intensity_cat_index ] = 0;
+ trig_map [intensity_cat_index ] = 0;
+ event_map[intensity_cat_index ] = 0;
+ return;
+ }
+}
+
+
void enumerate_sensors (void)
{
/*
discover_sensors(dev_num, CHANNEL_PATH, trig_sensors, check_trig_sensors);
discover_sensors(dev_num, EVENTS_PATH, event_sensors, check_event_sensors);
+ /* Hide specific sensor types if appropriate */
+ post_process_sensor_list(poll_sensors, trig_sensors, event_sensors);
+
for (i=0; i<catalog_size; i++) {
/* Try using events interface */
if (event_sensors[i] && !add_sensor(dev_num, i, MODE_EVENT))
reorder_fields(data->data, sensor[s].order);
sensor[s].event_count++;
+
switch (sensor[s].type) {
case SENSOR_TYPE_ACCELEROMETER:
/* Always consider the accelerometer accurate */
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));