| OLD | NEW |
| (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 #ifndef DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | |
| 6 #define DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | |
| 7 | |
| 8 #include "base/files/file_path.h" | |
| 9 #include "base/memory/ptr_util.h" | |
| 10 #include "device/generic_sensor/generic_sensor_export.h" | |
| 11 #include "device/generic_sensor/linux/sensor_data_linux.h" | |
| 12 | |
| 13 namespace device { | |
| 14 | |
| 15 struct SensorDataLinux; | |
| 16 struct SensorReading; | |
| 17 | |
| 18 // Generic reader class that reads sensors data from | |
| 19 // sensors files located in the base iio folder. | |
| 20 class DEVICE_GENERIC_SENSOR_EXPORT SensorReader { | |
| 21 public: | |
| 22 ~SensorReader(); | |
| 23 | |
| 24 // Creates a new instance of SensorReader if sensor read files | |
| 25 // has been found and |sensor_paths_| are set. | |
| 26 static std::unique_ptr<SensorReader> Create(const SensorDataLinux& data); | |
| 27 | |
| 28 // Reads sensor values into |*reading| from sensor files | |
| 29 // specified in |sensor_paths_|. | |
| 30 bool ReadSensorReading(SensorReading* reading); | |
| 31 | |
| 32 private: | |
| 33 SensorReader(std::vector<base::FilePath> sensor_paths, | |
| 34 double scaling_value, | |
| 35 const SensorDataLinux::ReaderFunctor& apply_scaling_func); | |
| 36 | |
| 37 // Contains paths to sensor files that are set when | |
| 38 // Create() is called. | |
| 39 const std::vector<base::FilePath> sensor_paths_; | |
| 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 | |
| 47 DISALLOW_COPY_AND_ASSIGN(SensorReader); | |
| 48 }; | |
| 49 | |
| 50 } // namespace device | |
| 51 | |
| 52 #endif // DEVICE_GENERIC_SENSOR_LINUX_PLATFORM_SENSOR_UTILS_LINUX_H_ | |
| OLD | NEW |