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_PUBLIC_CPP_SENSOR_READING_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_PUBLIC_CPP_SENSOR_READING_H_ |
6 #define DEVICE_GENERIC_SENSOR_PUBLIC_CPP_SENSOR_READING_H_ | 6 #define DEVICE_GENERIC_SENSOR_PUBLIC_CPP_SENSOR_READING_H_ |
7 | 7 |
8 #include "device/base/synchronization/one_writer_seqlock.h" | 8 #include "device/base/synchronization/one_writer_seqlock.h" |
9 #include "device/generic_sensor/public/cpp/generic_sensor_public_export.h" | 9 #include "device/generic_sensor/public/cpp/generic_sensor_public_export.h" |
10 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" | 10 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 Storage storage_; | 39 Storage storage_; |
40 }; | 40 }; |
41 | 41 |
42 // This structure represents sensor reading data: timestamp and 4 values. | 42 // This structure represents sensor reading data: timestamp and 4 values. |
43 struct DEVICE_GENERIC_SENSOR_PUBLIC_EXPORT SensorReading { | 43 struct DEVICE_GENERIC_SENSOR_PUBLIC_EXPORT SensorReading { |
44 SensorReading(); | 44 SensorReading(); |
45 ~SensorReading(); | 45 ~SensorReading(); |
46 SensorReading(const SensorReading& other); | 46 SensorReading(const SensorReading& other); |
47 SensorReadingField<double> timestamp; | 47 SensorReadingField<double> timestamp; |
48 constexpr static int kValuesCount = 4; | 48 constexpr static int kValuesCount = 4; |
| 49 // AMBIENT_LIGHT: |
| 50 // values[0]: ambient light level in SI lux units. |
| 51 // |
| 52 // PROXIMITY: |
| 53 // values[0]: proximity sensor distance measured in centimeters. |
| 54 // |
| 55 // ACCELEROMETER: |
| 56 // values[0]: acceleration minus Gx on the x-axis. |
| 57 // values[1]: acceleration minus Gy on the y-axis. |
| 58 // values[2]: acceleration minus Gz on the z-axis. |
| 59 // |
| 60 // LINEAR_ACCELERATION: |
| 61 // values[0]: acceleration on the x-axis. |
| 62 // values[1]: acceleration on the y-axis. |
| 63 // values[2]: acceleration on the z-axis. |
| 64 // |
| 65 // GYROSCOPE: |
| 66 // values[0]: angular speed around the x-axis. |
| 67 // values[1]: angular speed around the y-axis. |
| 68 // values[2]: angular speed around the z-axis. |
| 69 // |
| 70 // MAGNETOMETER: |
| 71 // values[0]: ambient magnetic field in the x-axis in micro-Tesla (uT). |
| 72 // values[1]: ambient magnetic field in the y-axis in micro-Tesla (uT). |
| 73 // values[2]: ambient magnetic field in the z-axis in micro-Tesla (uT). |
| 74 // |
| 75 // PRESSURE: |
| 76 // values[0]: atmospheric pressure in hPa (millibar). |
| 77 // |
| 78 // ABSOLUTE_ORIENTATION: |
| 79 // values[0]: x value of a quaternion representing the orientation of the |
| 80 // device in 3D space. |
| 81 // values[1]: y value of a quaternion representing the orientation of the |
| 82 // device in 3D space. |
| 83 // values[2]: z value of a quaternion representing the orientation of the |
| 84 // device in 3D space. |
| 85 // values[3]: w value of a quaternion representing the orientation of the |
| 86 // device in 3D space. |
| 87 // |
| 88 // RELATIVE_ORIENTATION: |
| 89 // (Identical to ABSOLUTE_ORIENTATION except that it doesn't use the |
| 90 // geomagnetic field.) |
| 91 // values[0]: x value of a quaternion representing the orientation of the |
| 92 // device in 3D space. |
| 93 // values[1]: y value of a quaternion representing the orientation of the |
| 94 // device in 3D space. |
| 95 // values[2]: z value of a quaternion representing the orientation of the |
| 96 // device in 3D space. |
| 97 // values[3]: w value of a quaternion representing the orientation of the |
| 98 // device in 3D space. |
49 SensorReadingField<double> values[kValuesCount]; | 99 SensorReadingField<double> values[kValuesCount]; |
50 }; | 100 }; |
51 | 101 |
52 // This structure represents sensor reading buffer: sensor reading and seqlock | 102 // This structure represents sensor reading buffer: sensor reading and seqlock |
53 // for synchronization. | 103 // for synchronization. |
54 struct DEVICE_GENERIC_SENSOR_PUBLIC_EXPORT SensorReadingSharedBuffer { | 104 struct DEVICE_GENERIC_SENSOR_PUBLIC_EXPORT SensorReadingSharedBuffer { |
55 SensorReadingSharedBuffer(); | 105 SensorReadingSharedBuffer(); |
56 ~SensorReadingSharedBuffer(); | 106 ~SensorReadingSharedBuffer(); |
57 SensorReadingField<OneWriterSeqLock> seqlock; | 107 SensorReadingField<OneWriterSeqLock> seqlock; |
58 SensorReading reading; | 108 SensorReading reading; |
59 | 109 |
60 // Gets the shared reading buffer offset for the given sensor type. | 110 // Gets the shared reading buffer offset for the given sensor type. |
61 static uint64_t GetOffset(mojom::SensorType type); | 111 static uint64_t GetOffset(mojom::SensorType type); |
62 }; | 112 }; |
63 | 113 |
64 } // namespace device | 114 } // namespace device |
65 | 115 |
66 #endif // DEVICE_GENERIC_SENSOR_PUBLIC_CPP_SENSOR_READING_H_ | 116 #endif // DEVICE_GENERIC_SENSOR_PUBLIC_CPP_SENSOR_READING_H_ |
OLD | NEW |