File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 9
9
#include < Adafruit_QMC5883P.h>
10
10
#include < math.h>
11
11
12
+
13
+ /* !
14
+ * @brief Constructor for a QMC5883P sensor.
15
+ * @param i2c
16
+ * The I2C interface.
17
+ * @param sensorAddress
18
+ * The 7-bit I2C address of the sensor.
19
+ */
12
20
WipperSnapper_I2C_Driver_QMC5883P::WipperSnapper_I2C_Driver_QMC5883P (
13
21
TwoWire *i2c, uint16_t sensorAddress)
14
22
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {}
15
23
24
+ /* !
25
+ * @brief Destructor for a QMC5883P sensor.
26
+ */
16
27
WipperSnapper_I2C_Driver_QMC5883P::~WipperSnapper_I2C_Driver_QMC5883P () {
17
28
if (_qmc) {
18
29
delete _qmc;
19
30
}
20
31
}
21
32
33
+ /* !
34
+ * @brief Initializes the QMC5883P sensor and begins I2C.
35
+ * @return True if initialized successfully, False otherwise.
36
+ */
22
37
bool WipperSnapper_I2C_Driver_QMC5883P::begin () {
23
38
_qmc = new Adafruit_QMC5883P ();
24
39
if (!_qmc->begin (_sensorAddress, _i2c)) {
@@ -41,6 +56,12 @@ bool WipperSnapper_I2C_Driver_QMC5883P::begin() {
41
56
return true ;
42
57
}
43
58
59
+ /* !
60
+ * @brief Get the magnetometer's sensor event.
61
+ * @param magEvent
62
+ * Pointer to the magnetometer sensor event.
63
+ * @return True if the event was obtained successfully, False otherwise.
64
+ */
44
65
bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw (sensors_event_t *magEvent) {
45
66
if (!_qmc->isDataReady ()) {
46
67
return false ;
Original file line number Diff line number Diff line change 13
13
14
14
class Adafruit_QMC5883P ; // forward
15
15
16
+ /* *************************************************************************/
17
+ /* !
18
+ @brief Class that provides a driver interface for a QMC5883P sensor.
19
+ */
20
+ /* *************************************************************************/
16
21
class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver {
17
22
public:
18
23
WipperSnapper_I2C_Driver_QMC5883P (TwoWire *i2c, uint16_t sensorAddress);
@@ -22,7 +27,7 @@ class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver {
22
27
bool getEventRaw (sensors_event_t *magEvent);
23
28
24
29
private:
25
- Adafruit_QMC5883P *_qmc = nullptr ;
30
+ Adafruit_QMC5883P *_qmc = nullptr ; // /< Pointer to the QMC5883P sensor object
26
31
};
27
32
28
33
#endif // WipperSnapper_I2C_Driver_QMC5883P_H
You can’t perform that action at this time.
0 commit comments