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

Side by Side Diff: device/generic_sensor/linux/sensor_data_linux.cc

Issue 2480773002: Reland of [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: fix for reland Created 4 years, 1 month 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/linux/sensor_data_linux.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 void InitAmbientLightSensorData(SensorDataLinux* data) {
18 std::vector<std::string> file_names(
19 {"in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw",
20 "in_illuminance_raw"});
Reilly Grant (use Gerrit) 2016/11/04 17:00:12 The parenthesis here are unnecessary.
21
22 data->sensor_file_names.push_back(std::move(file_names));
23 data->reporting_mode = mojom::ReportingMode::ON_CHANGE;
24 data->default_configuration =
25 PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz);
26 }
27
28 } // namespace
29
30 SensorDataLinux::SensorDataLinux() : base_path_sensor_linux(kSensorsBasePath) {}
31
32 SensorDataLinux::~SensorDataLinux() = default;
33
34 SensorDataLinux::SensorDataLinux(const SensorDataLinux& other) = default;
35
36 bool InitSensorData(SensorType type, SensorDataLinux* data) {
37 DCHECK(data);
38
39 switch (type) {
40 case SensorType::AMBIENT_LIGHT: {
41 InitAmbientLightSensorData(data);
42 break;
43 }
44 default: {
45 NOTIMPLEMENTED();
46 return false;
47 }
48 }
49 return true;
50 }
51
52 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/linux/sensor_data_linux.h ('k') | device/generic_sensor/linux/sensor_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698