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 99#include < Adafruit_QMC5883P.h>
1010#include < math.h>
1111
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+ */
1220WipperSnapper_I2C_Driver_QMC5883P::WipperSnapper_I2C_Driver_QMC5883P (
1321 TwoWire *i2c, uint16_t sensorAddress)
1422 : WipperSnapper_I2C_Driver(i2c, sensorAddress) {}
1523
24+ /* !
25+ * @brief Destructor for a QMC5883P sensor.
26+ */
1627WipperSnapper_I2C_Driver_QMC5883P::~WipperSnapper_I2C_Driver_QMC5883P () {
1728 if (_qmc) {
1829 delete _qmc;
1930 }
2031}
2132
33+ /* !
34+ * @brief Initializes the QMC5883P sensor and begins I2C.
35+ * @return True if initialized successfully, False otherwise.
36+ */
2237bool WipperSnapper_I2C_Driver_QMC5883P::begin () {
2338 _qmc = new Adafruit_QMC5883P ();
2439 if (!_qmc->begin (_sensorAddress, _i2c)) {
@@ -41,6 +56,12 @@ bool WipperSnapper_I2C_Driver_QMC5883P::begin() {
4156 return true ;
4257}
4358
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+ */
4465bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw (sensors_event_t *magEvent) {
4566 if (!_qmc->isDataReady ()) {
4667 return false ;
Original file line number Diff line number Diff line change 1313
1414class Adafruit_QMC5883P ; // forward
1515
16+ /* *************************************************************************/
17+ /* !
18+ @brief Class that provides a driver interface for a QMC5883P sensor.
19+ */
20+ /* *************************************************************************/
1621class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver {
1722public:
1823 WipperSnapper_I2C_Driver_QMC5883P (TwoWire *i2c, uint16_t sensorAddress);
@@ -22,7 +27,7 @@ class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver {
2227 bool getEventRaw (sensors_event_t *magEvent);
2328
2429private:
25- Adafruit_QMC5883P *_qmc = nullptr ;
30+ Adafruit_QMC5883P *_qmc = nullptr ; // /< Pointer to the QMC5883P sensor object
2631};
2732
2833#endif // WipperSnapper_I2C_Driver_QMC5883P_H
You can’t perform that action at this time.
0 commit comments