Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: device/generic_sensor/iio/sensor_data_iio.cc

Issue 2370343002: [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: add comments to unittest Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/generic_sensor/iio/sensor_data_iio.h"
6 #include "device/sensors/public/cpp/device_sensors_consts.h"
7
8 namespace device {
9
10 namespace {
11
12 using mojom::SensorType;
13
14 const base::FilePath::CharType* kSensorsBasePath =
15 FILE_PATH_LITERAL("/sys/bus/iio/devices");
16
17 const char* kAmbientLightFileNames[][5] = {
18 {"in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw",
19 "in_illuminance_raw", "illuminance0_input"}};
20
21 // An exampleaw_content_browser_client.cc of other sensor:
22 //
23 // const char* kAccelerometerFileNames[3][3] = {
24 // { "x1", "x2", "x3", },
25 // { "y1", "y2", "y3", },
26 // { "z1", "z2", "z3", },
27 // };
28
29 } // namespace
30
31 bool InitSensorData(SensorType type, SensorDataIio* data) {
32 DCHECK(data);
33
34 switch (type) {
35 case SensorType::AMBIENT_LIGHT:
36 data->sensor_file_names[0] = &kAmbientLightFileNames[0][0];
37 data->sensor_file_names_cols = arraysize(*kAmbientLightFileNames);
38 data->sensor_file_names_rows = arraysize(kAmbientLightFileNames);
39 data->reporting_mode = mojom::ReportingMode::ON_CHANGE;
40 data->default_configuration =
41 PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz);
42 break;
43 default:
44 NOTIMPLEMENTED();
45 return false;
46 }
47 data->base_path_sensor_iio = kSensorsBasePath;
48 return true;
49 }
50
51 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698