diff --git a/html/_adafruit___sensor_8h_source.html b/html/_adafruit___sensor_8h_source.html index f2475c2..de0eb69 100644 --- a/html/_adafruit___sensor_8h_source.html +++ b/html/_adafruit___sensor_8h_source.html @@ -62,15 +62,15 @@ $(function() {
Adafruit_Sensor.h
-
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software< /span>
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and
18  * extended sensor support to include color, voltage and current */
19 
20 #ifndef _ADAFRUIT_SENSOR_H
21 #define _ADAFRUIT_SENSOR_H
22 
23 #ifndef ARDUINO
24 #include <stdint.h>
25 #elif ARDUINO >= 100
26 #include "Arduino.h"
27 #include "Print.h"
28 #else
29 #include "WProgram.h"
30 #endif
31 
32 /* Constants */
33 #define SENSORS_GRAVITY_EARTH (9.80665F)
34 #define SENSORS_GRAVITY_MOON (1.6F)
35 #define SENSORS_GRAVITY_SUN (275.0F)
36 #define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH)
37 #define SENSORS_MAGFIELD_EARTH_MAX \
38  (60.0F)
39 #define SENSORS_MAGFIELD_EARTH_MIN \
40  (30.0F)
41 #define SENSORS_PRESSURE_SEALEVELHPA \
42  (1013.25F)
43 #define SENSORS_DPS_TO_RADS \
44  (0.017453293F)
46 #define SENSORS_RADS_TO_DPS \
47  (57.29577793F)
48 #define SENSORS_GAUSS_TO_MICROTESLA \
49  (100)
52 typedef enum {
53  SENSOR_TYPE_ACCELEROMETER = (1),
54  SENSOR_TYPE_MAGNETIC_FIELD = (2),
55  SENSOR_TYPE_ORIENTATION = (3),
56  SENSOR_TYPE_GYROSCOPE = (4),
57  SENSOR_TYPE_LIGHT = (5),
58  SENSOR_TYPE_PRESSURE = (6),
59  SENSOR_TYPE_PROXIMITY = (8),
60  SENSOR_TYPE_GRAVITY = (9),
61  SENSOR_TYPE_LINEAR_ACCELERATION =
62  (10),
63  SENSOR_TYPE_ROTATION_VECTOR = (11),
64  SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
65  SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
66  SENSOR_TYPE_OBJECT_TEMPERATURE = (14),
67  SENSOR_TYPE_VOLTAGE = (15),
68  SENSOR_TYPE_CURRENT = (16),
69  SENSOR_TYPE_COLOR = (17),
70  SENSOR_TYPE_TVOC = (18),
71  SENSOR_TYPE_VOC_INDEX = (19),
72  SENSOR_TYPE_NOX_INDEX = (20),
73  SENSOR_TYPE_CO2 = (21),
74  SENSOR_TYPE_ECO2 = (22),
75  SENSOR_TYPE_PM10_STD = (23),
76  SENSOR_TYPE_PM25_STD = (24),
77  SENSOR_TYPE_PM100_STD = (25),
78  SENSOR_TYPE_PM10_ENV = (26),
79  SENSOR_TYPE_PM25_ENV = (27),
80  SENSOR_TYPE_PM100_ENV = (28),
81  SENSOR_TYPE_GAS_RESISTANCE = (29),
82  SENSOR_TYPE_UNITLESS_PERCENT = (30)
83 } sensors_type_t;
84 
86 typedef struct {
87  union {
88  float v[3];
89  struct {
90  float x;
91  float y;
92  float z;
93  };
94  /* Orientation sensors */
95  struct {
96  float roll;
99  float pitch;
102  float heading;
105  };
106  };
107  int8_t status;
109  uint8_t reserved[3];
111 
113 typedef struct {
114  union {
115  float c[3];
116  /* RGB color space */
117  struct {
118  float r;
119  float g;
120  float b;
121  };
122  };
123  uint32_t rgba;
125 
126 /* Sensor event (36 bytes) */
129 typedef struct {
130  int32_t version;
131  int32_t sensor_id;
132  int32_t type;
133  int32_t reserved0;
134  int32_t timestamp;
135  union {
136  float data[4];
137  sensors_vec_t acceleration;
140  magnetic;
141  sensors_vec_t orientation;
143  float temperature;
144  float distance;
145  float light;
146  float pressure;
147  float relative_humidity;
148  float current;
149  float voltage;
150  float tvoc;
151  float voc_index;
153  float nox_index;
155  float CO2;
156  float eCO2;
158  float pm10_std;
160  float pm25_std;
162  float pm100_std;
164  float pm10_env;
166  float pm25_env;
168  float pm100_env;
170  float gas_resistance;
172  float unitless_percent;
174  };
176 
177 /* Sensor details (40 bytes) */
180 typedef struct {
181  char name[12];
182  int32_t version;
183  int32_t sensor_id;
184  int32_t type;
185  float max_value;
186  float min_value;
187  float resolution;
189  int32_t min_delay;
191 } sensor_t;
192 
197 class Adafruit_Sensor {
198 public:
199  // Constructor(s)
200  Adafruit_Sensor() {}
201  virtual ~Adafruit_Sensor() {}
202 
203  // These must be defined by the subclass
204 
208  virtual void enableAutoRange(bool enabled) {
209  (void)enabled; /* suppress unused warning */
210  };
211 
214  virtual bool getEvent(sensors_event_t *) = 0;
216  virtual void getSensor(sensor_t *) = 0;
217 
218  void printSensorDetails(void);
219 };
220 
221 #endif
Definition: Adafruit_Sensor.h:87
-
Common sensor interface to unify various sensors. Intentionally modeled after sensors.h in the Android API: https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h.
Definition: Adafruit_Sensor.h:198
+
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software< /span>
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and
18  * extended sensor support to include color, voltage and current */
19 
20 #ifndef _ADAFRUIT_SENSOR_H
21 #define _ADAFRUIT_SENSOR_H
22 
23 #ifndef ARDUINO
24 #include <stdint.h>
25 #elif ARDUINO >= 100
26 #include "Arduino.h"
27 #include "Print.h"
28 #else
29 #include "WProgram.h"
30 #endif
31 
32 /* Constants */
33 #define SENSORS_GRAVITY_EARTH (9.80665F)
34 #define SENSORS_GRAVITY_MOON (1.6F)
35 #define SENSORS_GRAVITY_SUN (275.0F)
36 #define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH)
37 #define SENSORS_MAGFIELD_EARTH_MAX \
38  (60.0F)
39 #define SENSORS_MAGFIELD_EARTH_MIN \
40  (30.0F)
41 #define SENSORS_PRESSURE_SEALEVELHPA \
42  (1013.25F)
43 #define SENSORS_DPS_TO_RADS \
44  (0.017453293F)
46 #define SENSORS_RADS_TO_DPS \
47  (57.29577793F)
48 #define SENSORS_GAUSS_TO_MICROTESLA \
49  (100)
52 typedef enum {
53  SENSOR_TYPE_ACCELEROMETER = (1),
54  SENSOR_TYPE_MAGNETIC_FIELD = (2),
55  SENSOR_TYPE_ORIENTATION = (3),
56  SENSOR_TYPE_GYROSCOPE = (4),
57  SENSOR_TYPE_LIGHT = (5),
58  SENSOR_TYPE_PRESSURE = (6),
59  SENSOR_TYPE_PROXIMITY = (8),
60  SENSOR_TYPE_GRAVITY = (9),
61  SENSOR_TYPE_LINEAR_ACCELERATION =
62  (10),
63  SENSOR_TYPE_ROTATION_VECTOR = (11),
64  SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
65  SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
66  SENSOR_TYPE_OBJECT_TEMPERATURE = (14),
67  SENSOR_TYPE_VOLTAGE = (15),
68  SENSOR_TYPE_CURRENT = (16),
69  SENSOR_TYPE_COLOR = (17),
70  SENSOR_TYPE_TVOC = (18),
71  SENSOR_TYPE_VOC_INDEX = (19),
72  SENSOR_TYPE_NOX_INDEX = (20),
73  SENSOR_TYPE_CO2 = (21),
74  SENSOR_TYPE_ECO2 = (22),
75  SENSOR_TYPE_PM10_STD = (23),
76  SENSOR_TYPE_PM25_STD = (24),
77  SENSOR_TYPE_PM100_STD = (25),
78  SENSOR_TYPE_PM10_ENV = (26),
79  SENSOR_TYPE_PM25_ENV = (27),
80  SENSOR_TYPE_PM100_ENV = (28),
81  SENSOR_TYPE_GAS_RESISTANCE = (29),
82  SENSOR_TYPE_UNITLESS_PERCENT = (30),
83  SENSOR_TYPE_ALTITUDE = (31)
84 } sensors_type_t;
85 
87 typedef struct {
88  union {
89  float v[3];
90  struct {
91  float x;
92  float y;
93  float z;
94  };
95  /* Orientation sensors */
96  struct {
97  float roll;
100  float pitch;
103  float heading;
106  };
107  };
108  int8_t status;
110  uint8_t reserved[3];
112 
114 typedef struct {
115  union {
116  float c[3];
117  /* RGB color space */
118  struct {
119  float r;
120  float g;
121  float b;
122  };
123  };
124  uint32_t rgba;
126 
127 /* Sensor event (36 bytes) */
130 typedef struct {
131  int32_t version;
132  int32_t sensor_id;
133  int32_t type;
134  int32_t reserved0;
135  int32_t timestamp;
136  union {
137  float data[4];
138  sensors_vec_t acceleration;
141  magnetic;
142  sensors_vec_t orientation;
144  float temperature;
145  float distance;
146  float light;
147  float pressure;
148  float relative_humidity;
149  float current;
150  float voltage;
151  float tvoc;
152  float voc_index;
154  float nox_index;
156  float CO2;
157  float eCO2;
159  float pm10_std;
161  float pm25_std;
163  float pm100_std;
165  float pm10_env;
167  float pm25_env;
169  float pm100_env;
171  float gas_resistance;
173  float unitless_percent;
175  float altitude;
177  };
179 
180 /* Sensor details (40 bytes) */
183 typedef struct {
184  char name[12];
185  int32_t version;
186  int32_t sensor_id;
187  int32_t type;
188  float max_value;
189  float min_value;
190  float resolution;
192  int32_t min_delay;
194 } sensor_t;
195 
200 class Adafruit_Sensor {
201 public:
202  // Constructor(s)
203  Adafruit_Sensor() {}
204  virtual ~Adafruit_Sensor() {}
205 
206  // These must be defined by the subclass
207 
211  virtual void enableAutoRange(bool enabled) {
212  (void)enabled; /* suppress unused warning */
213  };
214 
217  virtual bool getEvent(sensors_event_t *) = 0;
219  virtual void getSensor(sensor_t *) = 0;
220 
221  void printSensorDetails(void);
222 };
223 
224 #endif
Definition: Adafruit_Sensor.h:88
+
Common sensor interface to unify various sensors. Intentionally modeled after sensors.h in the Android API: https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h.
Definition: Adafruit_Sensor.h:201
virtual bool getEvent(sensors_event_t *)=0
Get the latest sensor event.
void printSensorDetails(void)
Prints sensor information to serial console.
Definition: Adafruit_Sensor.cpp:8
-
Definition: Adafruit_Sensor.h:181
-
Definition: Adafruit_Sensor.h:130
+
Definition: Adafruit_Sensor.h:184
+
Definition: Adafruit_Sensor.h:131
virtual void getSensor(sensor_t *)=0
Get info about the sensor itself.
-
Definition: Adafruit_Sensor.h:114
-
virtual void enableAutoRange(bool enabled)
Whether we should automatically change the range (if possible) for higher precision.
Definition: Adafruit_Sensor.h:209
+
Definition: Adafruit_Sensor.h:115
+
virtual void enableAutoRange(bool enabled)
Whether we should automatically change the range (if possible) for higher precision.
Definition: Adafruit_Sensor.h:212