Skip to content

Commit cb74461

Browse files
committed
doxyd
1 parent 1d5bac8 commit cb74461

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

Adafruit_Sensor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "Adafruit_Sensor.h"
22

3+
/**************************************************************************/
4+
/*!
5+
@brief Prints sensor information to serial console
6+
*/
7+
/**************************************************************************/
38
void Adafruit_Sensor::printSensorDetails(void) {
49
sensor_t sensor;
510
getSensor(&sensor);

Adafruit_Sensor.h

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
#include "WProgram.h"
3030
#endif
3131

32-
/* Intentionally modeled after sensors.h in the Android API:
33-
* https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h
34-
*/
35-
3632
/* Constants */
3733
#define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */
3834
#define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */
@@ -74,40 +70,41 @@ typedef enum {
7470
/** struct sensors_vec_s is used to return a vector in a common format. */
7571
typedef struct {
7672
union {
77-
float v[3];
73+
float v[3]; ///< 3D vector elements
7874
struct {
79-
float x;
80-
float y;
81-
float z;
82-
};
75+
float x; ///< X component of vector
76+
float y; ///< Y component of vector
77+
float z; ///< Z component of vector
78+
}; ///< Struct for holding XYZ component
8379
/* Orientation sensors */
8480
struct {
8581
float roll; /**< Rotation around the longitudinal axis (the plane body, 'X
8682
axis'). Roll is positive and increasing when moving
87-
downward. -90°<=roll<=90° */
83+
downward. -90°<=roll<=90° */
8884
float pitch; /**< Rotation around the lateral axis (the wing span, 'Y
8985
axis'). Pitch is positive and increasing when moving
90-
upwards. -180°<=pitch<=180°) */
86+
upwards. -180°<=pitch<=180°) */
9187
float heading; /**< Angle between the longitudinal axis (the plane body)
9288
and magnetic north, measured clockwise when viewing from
93-
the top of the device. 0-359° */
94-
};
95-
};
96-
int8_t status;
97-
uint8_t reserved[3];
89+
the top of the device. 0-359° */
90+
}; ///< Struct for holding roll/pitch/heading
91+
}; ///< Union that can hold 3D vector array, XYZ components or
92+
///< roll/pitch/heading
93+
int8_t status; ///< Status byte
94+
uint8_t reserved[3]; ///< Reserved
9895
} sensors_vec_t;
9996

10097
/** struct sensors_color_s is used to return color data in a common format. */
10198
typedef struct {
10299
union {
103-
float c[3];
100+
float c[3]; ///< Raw 3-element data
104101
/* RGB color space */
105102
struct {
106-
float r; /**< Red component */
107-
float g; /**< Green component */
108-
float b; /**< Blue component */
109-
};
110-
};
103+
float r; /**< Red component */
104+
float g; /**< Green component */
105+
float b; /**< Blue component */
106+
}; ///< RGB data in floating point notation
107+
}; ///< Union of various ways to describe RGB colorspace
111108
uint32_t rgba; /**< 24-bit RGBA value */
112109
} sensors_color_t;
113110

@@ -121,7 +118,7 @@ typedef struct {
121118
int32_t reserved0; /**< reserved */
122119
int32_t timestamp; /**< time is in milliseconds */
123120
union {
124-
float data[4];
121+
float data[4]; ///< Raw data
125122
sensors_vec_t acceleration; /**< acceleration values are in meter per second
126123
per second (m/s^2) */
127124
sensors_vec_t
@@ -136,7 +133,7 @@ typedef struct {
136133
float current; /**< current in milliamps (mA) */
137134
float voltage; /**< voltage in volts (V) */
138135
sensors_color_t color; /**< color in RGB component values */
139-
};
136+
}; ///< Union for the wide ranges of data we can carry
140137
} sensors_event_t;
141138

142139
/* Sensor details (40 bytes) */
@@ -155,17 +152,29 @@ typedef struct {
155152
constant rate */
156153
} sensor_t;
157154

155+
/** @brief Common sensor interface to unify various sensors.
156+
* Intentionally modeled after sensors.h in the Android API:
157+
* https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h
158+
*/
158159
class Adafruit_Sensor {
159160
public:
160161
// Constructor(s)
161162
Adafruit_Sensor() {}
162163
virtual ~Adafruit_Sensor() {}
163164

164165
// These must be defined by the subclass
166+
167+
/*! @brief Whether we should automatically change the range (if possible) for
168+
higher precision
169+
@param enabled True if we will try to autorange */
165170
virtual void enableAutoRange(bool enabled) {
166171
(void)enabled; /* suppress unused warning */
167172
};
173+
174+
/*! @brief Get the latest sensor event
175+
@returns True if able to fetch an event */
168176
virtual bool getEvent(sensors_event_t *) = 0;
177+
/*! @brief Get info about the sensor itself */
169178
virtual void getSensor(sensor_t *) = 0;
170179

171180
void printSensorDetails(void);

0 commit comments

Comments
 (0)