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 module device.mojom; | 5 module device.mojom; |
6 | 6 |
7 // Types of supported sensors | 7 // Types of supported sensors |
8 enum SensorType { | 8 enum SensorType { |
9 FIRST = 1, | 9 FIRST = 1, |
10 AMBIENT_LIGHT = FIRST, | 10 AMBIENT_LIGHT = FIRST, |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 struct SensorConfiguration { | 32 struct SensorConfiguration { |
33 // Maximum allowed frequency is 60 Hz. | 33 // Maximum allowed frequency is 60 Hz. |
34 const double kMaxAllowedFrequency = 60.0; | 34 const double kMaxAllowedFrequency = 60.0; |
35 | 35 |
36 // Requested frequency in Hz. | 36 // Requested frequency in Hz. |
37 double frequency; | 37 double frequency; |
38 // TODO(shalamov): Add map<string, union> for sensor specific configuration. | 38 // TODO(shalamov): Add map<string, union> for sensor specific configuration. |
39 }; | 39 }; |
40 | 40 |
| 41 // Each sensor uses the following structure to provide reading data. |
| 42 struct SensorReading { |
| 43 // Timestamp in seconds, obtained from system performance counter. |
| 44 double timestamp; |
| 45 // Sensor data fields. |
| 46 double value1; |
| 47 double value2; |
| 48 double value3; |
| 49 }; |
| 50 |
41 // Interface for controlling the Sensor. | 51 // Interface for controlling the Sensor. |
42 interface Sensor { | 52 interface Sensor { |
43 | 53 |
44 // Requests sensor to provide its default configuration. | 54 // Requests sensor to provide its default configuration. |
45 GetDefaultConfiguration() => (SensorConfiguration configuration); | 55 GetDefaultConfiguration() => (SensorConfiguration configuration); |
46 | 56 |
47 // Requests sensor to start reading sensor data with specified | 57 // Requests sensor to start reading sensor data with specified |
48 // SensorConfiguration. | 58 // SensorConfiguration. |
49 // Sensor holds the list of added configurations and it always polls | 59 // Sensor holds the list of added configurations and it always polls |
50 // the platform (and updates the shared buffer) at the maxiumum frequency | 60 // the platform (and updates the shared buffer) at the maxiumum frequency |
(...skipping 27 matching lines...) Expand all Loading... |
78 // Interface that client of the Sensor interface must implement to observe | 88 // Interface that client of the Sensor interface must implement to observe |
79 // sensor reading changes and error conditions. | 89 // sensor reading changes and error conditions. |
80 interface SensorClient { | 90 interface SensorClient { |
81 // Signals SensorClient when there is an error. | 91 // Signals SensorClient when there is an error. |
82 RaiseError(); | 92 RaiseError(); |
83 | 93 |
84 // Signals SensorClient when reading has been changed (only for sensors with | 94 // Signals SensorClient when reading has been changed (only for sensors with |
85 // ReportingMode::ON_CHANGE). | 95 // ReportingMode::ON_CHANGE). |
86 SensorReadingChanged(); | 96 SensorReadingChanged(); |
87 }; | 97 }; |
OLD | NEW |