SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
SensorDefs.hpp
Go to the documentation of this file.
1
31#pragma once
32
33#include <stdint.h>
34#include <math.h>
35
36#ifndef M_PI
37#define M_PI 3.14159265358979323846f
38#endif
68enum class SensorRemap {
69 // Chip top view, upper left corner
70 // -------------
71 // | * |
72 // | |
73 // | |
74 // | |
75 // | |
76 // -------------
78 // Chip top view, upper right corner
79 // -------------
80 // | * |
81 // | |
82 // | |
83 // | |
84 // | |
85 // -------------
87 // Chip top view, bottom right corner of the top
88 // -------------
89 // | |
90 // | |
91 // | |
92 // | |
93 // | * |
94 // -------------
96 // The top view of the chip, the lower left corner of the front bottom
97 // -------------
98 // | |
99 // | |
100 // | |
101 // | |
102 // | * |
103 // -------------
105 // The bottom view of the chip, the upper left corner of the top
106 // -------------
107 // | * |
108 // | |
109 // | |
110 // | |
111 // | |
112 // -------------
114 // The bottom view of the chip, the upper right corner of the top
115 // -------------
116 // | * |
117 // | |
118 // | |
119 // | |
120 // | |
121 // -------------
123 // The bottom view of the chip, the lower right corner of the bottom
124 // -------------
125 // | |
126 // | |
127 // | |
128 // | |
129 // | * |
130 // -------------
132 // Chip bottom view, bottom left corner
133 // -------------
134 // | |
135 // | |
136 // | |
137 // | |
138 // | * |
139 // -------------
141};
142
143
145 // ________________
146 // | |
147 // | * |
148 // | |
149 // | |
150 // | |
151 // | |
152 // |________________|
154
155 // ________________
156 // | |
157 // | * |
158 // | |
159 // | |
160 // | |
161 // | |
162 // |________________|
164
165 // ________________
166 // | |
167 // | |
168 // | |
169 // | |
170 // | |
171 // | * |
172 // |________________|
174
175 // ________________
176 // | |
177 // | |
178 // | |
179 // | |
180 // | |
181 // | * |
182 // |________________|
184
185 // ________________
186 // |________________|
187 // *
189
190 // __*_____________
191 // |________________|
193
194 // Unknown direction
197
201enum class SensorType {
202 UNKNOWN = 0,
204 GYROSCOPE,
206 PRESSURE,
208 HUMIDITY,
210};
211
216 float x;
217 float y;
218 float z;
219};
220
224struct RawVector {
225 int16_t x;
226 int16_t y;
227 int16_t z;
228};
229
233enum class OperationMode {
234 SUSPEND = 0,
235 NORMAL,
238};
239
244 FS_2G = 0,
245 FS_4G,
246 FS_8G,
247 FS_16G,
248 FS_32G,
249 FS_64G,
250 FS_128G
251};
252
256enum class InterruptPinMap {
257 DISABLE = 0,
258 PIN1 = 1,
259 PIN2
260};
261
265enum class TapEvent : uint8_t {
266 INVALID = 0,
267 SINGLE = 1,
268 DOUBLE = 2,
269};
270
271
276 FS_2G = 0, // ±2 Gauss
277 FS_4G, // ±4 Gauss
278 FS_8G, // ±8 Gauss
279 FS_12G, // ±12 Gauss
280 FS_16G, // ±16 Gauss
281 FS_20G, // ±20 Gauss
282 FS_25G, // ±25 Gauss
283 FS_30G, // ±30 Gauss
284 FS_32G // ±32 Gauss
285};
286
291 OSR_8,
292 OSR_4,
293 OSR_2,
294 OSR_1
295};
296
301 DSR_1,
302 DSR_2,
303 DSR_4,
304 DSR_8,
305};
306
308 LPF_1,
309 LPF_2,
310 LPF_4,
311 LPF_8,
312 LPF_16
313};
314
319 FS_125_DPS = 0,
320 FS_250_DPS,
321 FS_500_DPS,
325};
326
340
358
366
367 GyroscopeData() : dps{0, 0, 0}, raw{0, 0, 0}, temperature{0} {}
368};
369
385
390 const char *manufacturer;
391 const char *model;
392 uint8_t i2c_address;
393 uint8_t version;
394 uint32_t uid;
396
397 SensorInfo() : manufacturer("Unknown"), model("Unknown"), i2c_address(0), version(0), uid(0), type(SensorType::UNKNOWN) {}
398};
SensorType
Enumeration of sensor types.
@ MULTI_AXIS
Multi-axis sensor.
@ HUMIDITY
Humidity sensor.
@ GYROSCOPE
Gyroscope sensor.
@ PRESSURE
Pressure sensor.
@ UNKNOWN
Unknown sensor type.
@ ACCELEROMETER
Accelerometer sensor.
@ TEMPERATURE
Temperature sensor.
@ MAGNETOMETER
Magnetometer sensor.
OperationMode
Enumeration of sensor operation modes.
SensorDirection
@ DIRECTION_TOP_RIGHT
@ DIRECTION_TOP
@ DIRECTION_UNKNOWN
@ DIRECTION_BOTTOM
@ DIRECTION_TOP_LEFT
@ DIRECTION_BOTTOM_LEFT
@ DIRECTION_BOTTOM_RIGHT
MagLowPassFilter
@ LPF_2
2 Hz low-pass filter
@ LPF_4
4 Hz low-pass filter
@ LPF_16
16 Hz low-pass filter
@ LPF_8
8 Hz low-pass filter
@ LPF_1
1 Hz low-pass filter
SensorRemap
Enumeration representing different remapping options for the sensor's orientation.
@ BOTTOM_LAYER_BOTTOM_RIGHT_CORNER
@ BOTTOM_LAYER_TOP_RIGHT_CORNER
@ TOP_LAYER_BOTTOM_LEFT_CORNER
@ BOTTOM_LAYER_TOP_LEFT_CORNER
@ BOTTOM_LAYER_BOTTOM_LEFT_CORNER
@ TOP_LAYER_BOTTOM_RIGHT_CORNER
@ TOP_LAYER_RIGHT_CORNER
@ TOP_LAYER_LEFT_CORNER
GyroFullScaleRange
Enumeration of gyroscope full-scale range settings.
@ FS_2000_DPS
±2000 °/s
@ FS_1000_DPS
±1000 °/s
@ FS_4000_DPS
±4000 °/s (if supported)
@ FS_250_DPS
±250 °/s
@ FS_500_DPS
±500 °/s
@ FS_125_DPS
±125 °/s
AccelFullScaleRange
Enumeration of accelerometer full-scale range settings.
@ FS_128G
±128g range
@ FS_16G
±16g range
@ FS_32G
±32g range
@ FS_64G
±64g range
InterruptPinMap
Enumeration of interrupt pin mapping options.
@ PIN1
Interrupt pin 1.
@ PIN2
Interrupt pin 2.
@ DISABLE
Disable interrupt output.
TapEvent
Generic tap event type.
MagFullScaleRange
Enumeration defining full-scale range settings for the sensor.
MagDownSampleRatio
Enumeration defining down-sample ratios for the sensor.
@ DSR_8
8x down-sample ratio
@ DSR_2
2x down-sample ratio
@ DSR_4
4x down-sample ratio
@ DSR_1
1x down-sample ratio
MagOverSampleRatio
Enumeration defining over-sample ratios for the sensor.
@ OSR_8
8x over-sample ratio
@ OSR_4
4x over-sample ratio
@ OSR_2
2x over-sample ratio
@ OSR_1
1x over-sample ratio
Structure representing accelerometer data.
SensorVector mps2
Acceleration in meters per second squared (m/s²)
float temperature
Temperature in degrees Celsius (if available)
RawVector raw
Raw sensor values in LSB (least significant bits)
Structure representing gyroscope data.
float temperature
Temperature in °C (if available)
SensorVector dps
Angular velocity in degrees per second (°/s)
RawVector raw
Raw sensor values in LSB.
Structure representing magnetometer data.
RawVector raw
raw data
float heading_degrees
heading angle (degrees)
float heading
heading angle (radians)
bool skip_data
skip data flag
SensorVector magnetic_field
magnetic field strength (Gauss)
float temperature
temperature (°C)
bool overflow
data overflow flag
Structure representing a raw 3D vector with 16-bit integer components.
int16_t x
X-axis raw value.
int16_t y
Y-axis raw value.
int16_t z
Z-axis raw value.
Structure representing sensor configuration parameters.
SensorConfig(SensorType type, float range, float sample_rate, uint32_t latency, OperationMode mode)
uint32_t latency
Reporting latency in milliseconds.
float sample_rate
Sample rate in Hz.
float range
Measurement range.
SensorType type
Type of the sensor.
OperationMode mode
Operation mode.
Structure containing sensor identification information.
uint8_t version
Hardware/firmware version.
uint8_t i2c_address
Default I2C address.
uint32_t uid
Unique identifier.
SensorType type
Sensor type.
const char * manufacturer
Manufacturer name.
const char * model
Model name/identifier.
Structure representing a 3D vector with floating-point components.
float x
X-axis component.
float y
Y-axis component.
float z
Z-axis component.