| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | 6 #define DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "device/generic_sensor/generic_sensor_export.h" | 10 #include "device/generic_sensor/generic_sensor_export.h" |
| 11 #include "device/generic_sensor/linux/sensor_data_linux.h" |
| 11 | 12 |
| 12 namespace device { | 13 namespace device { |
| 13 | 14 |
| 14 struct SensorDataLinux; | 15 struct SensorDataLinux; |
| 15 struct SensorReading; | 16 struct SensorReading; |
| 16 | 17 |
| 17 // Generic reader class that reads sensors data from | 18 // Generic reader class that reads sensors data from |
| 18 // sensors files located in the base iio folder. | 19 // sensors files located in the base iio folder. |
| 19 class DEVICE_GENERIC_SENSOR_EXPORT SensorReader { | 20 class DEVICE_GENERIC_SENSOR_EXPORT SensorReader { |
| 20 public: | 21 public: |
| 21 ~SensorReader(); | 22 ~SensorReader(); |
| 22 | 23 |
| 23 // Creates a new instance of SensorReader if sensor read files | 24 // Creates a new instance of SensorReader if sensor read files |
| 24 // has been found and |sensor_paths_| are set. | 25 // has been found and |sensor_paths_| are set. |
| 25 static std::unique_ptr<SensorReader> Create(const SensorDataLinux& data); | 26 static std::unique_ptr<SensorReader> Create(const SensorDataLinux& data); |
| 26 | 27 |
| 27 // Reads sensor values into |*reading| from sensor files | 28 // Reads sensor values into |*reading| from sensor files |
| 28 // specified in |sensor_paths_|. | 29 // specified in |sensor_paths_|. |
| 29 bool ReadSensorReading(SensorReading* reading); | 30 bool ReadSensorReading(SensorReading* reading); |
| 30 | 31 |
| 31 private: | 32 private: |
| 32 explicit SensorReader(std::vector<base::FilePath> sensor_paths); | 33 SensorReader(std::vector<base::FilePath> sensor_paths, |
| 34 double scaling_value, |
| 35 const SensorDataLinux::ReaderFunctor& apply_scaling_func); |
| 33 | 36 |
| 34 // Contains paths to sensor files that are set when | 37 // Contains paths to sensor files that are set when |
| 35 // Create() is called. | 38 // Create() is called. |
| 36 const std::vector<base::FilePath> sensor_paths_; | 39 const std::vector<base::FilePath> sensor_paths_; |
| 37 | 40 |
| 41 // Scaling values that are applied to raw data from sensors. |
| 42 const double scaling_value_; |
| 43 |
| 44 // Used to apply scalings and invert signs if needed. |
| 45 const SensorDataLinux::ReaderFunctor apply_scaling_func_; |
| 46 |
| 38 DISALLOW_COPY_AND_ASSIGN(SensorReader); | 47 DISALLOW_COPY_AND_ASSIGN(SensorReader); |
| 39 }; | 48 }; |
| 40 | 49 |
| 41 } // namespace device | 50 } // namespace device |
| 42 | 51 |
| 43 #endif // DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | 52 #endif // DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ |
| OLD | NEW |