Chromium Code Reviews| Index: device/generic_sensor/iio/sensor_data_iio.cc |
| diff --git a/device/generic_sensor/iio/sensor_data_iio.cc b/device/generic_sensor/iio/sensor_data_iio.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ee3d50eb8a37abf569fd284430c008a587c8d0eb |
| --- /dev/null |
| +++ b/device/generic_sensor/iio/sensor_data_iio.cc |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/generic_sensor/iio/sensor_data_iio.h" |
| +#include "device/sensors/public/cpp/device_sensors_consts.h" |
| + |
| +namespace device { |
| + |
| +namespace { |
| + |
| +using mojom::SensorType; |
| + |
| +const size_t kAlsCols = 5; |
|
Mikhail
2016/10/14 13:59:04
can omit it
maksims (do not use this acc)
2016/10/17 06:06:59
Done.
|
| + |
| +const char* kAmbientLightFileNames[][kAlsCols] = { |
| + {"in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw", |
| + "in_illuminance_raw", "illuminance0_input"}}; |
| + |
| +// An example of other sensor: |
| +// |
| +// const char* kAccelerometerFileNames[3][3] = { |
| +// { "x1", "x2", "x3", }, |
| +// { "y1", "y2", "y3", }, |
| +// { "z1", "z2", "z3", }, |
| +// }; |
| + |
| +} // namespace |
| + |
| +bool CreateSensorData(mojom::SensorType type, SensorDataIio* data) { |
|
Mikhail
2016/10/14 13:59:04
DCHECK(data) or pass it as SensorDataIio&
maksims (do not use this acc)
2016/10/17 06:06:59
Done.
|
| + switch (type) { |
| + case SensorType::AMBIENT_LIGHT: |
| + data->sensor_file_names[0] = &kAmbientLightFileNames[0][0]; |
| + data->sensor_file_names_cols = arraysize(*kAmbientLightFileNames); |
| + data->sensor_file_names_rows = arraysize(kAmbientLightFileNames); |
| + data->reporting_mode = mojom::ReportingMode::ON_CHANGE; |
| + data->default_configuration = |
| + PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz); |
| + break; |
| + default: |
| + NOTIMPLEMENTED(); |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace device |