|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <SensorQMC5883L.hpp>
Public Member Functions | |
| SensorQMC5883L ()=default | |
| Default constructor. | |
| ~SensorQMC5883L ()=default | |
| Destructor. | |
| bool | readData (MagnetometerData &data) override |
| Reads the magnetic field data from the sensor. | |
| bool | isDataReady () override |
| Checks if new data is available from the sensor. | |
| bool | isDataOverflow () |
| Checks if data overflow has occurred. | |
| bool | isDataSkipped () |
| Checks if data has been skipped. | |
| bool | reset () override |
| Resets the sensor to its default state. | |
| bool | selfTest () override |
| QMC5883L does not support self-test checks. | |
| bool | setFullScaleRange (MagFullScaleRange range) override |
| Sets the full-scale range of the magnetometer. | |
| bool | setOutputDataRate (float data_rate_hz) override |
| Sets the bandwidth of the magnetometer. | |
| bool | setOperationMode (OperationMode mode) override |
| Sets the operation mode of the magnetometer. | |
| bool | setOversamplingRate (MagOverSampleRatio osr) override |
| Sets the oversampling rate of the magnetometer. | |
| bool | setDownsamplingRate (MagDownSampleRatio dsr) override |
| QM5883L does not support downsampling. | |
| bool | getTemperature (float &temperature, int16_t &raw_temp) |
| Gets the temperature reading from the sensor. | |
| uint8_t | getChipID () const |
| Gets the chip ID of the magnetometer. | |
| bool | configMagnetometer (OperationMode mode, MagFullScaleRange range, float data_rate_hz, MagOverSampleRatio osr, MagDownSampleRatio dsr=MagDownSampleRatio::DSR_1) override |
| Configures the magnetometer with multiple parameters. | |
Public Member Functions inherited from MagnetometerBase | |
| MagnetometerBase () | |
| Constructor for the MagnetometerBase class. | |
| virtual | ~MagnetometerBase ()=default |
| Destructor for the MagnetometerBase class. | |
| virtual float | getFullScaleRange () const |
| Gets the full-scale range for the magnetometer. | |
| virtual OperationMode | getOperationMode () const |
| Gets the operation mode for the magnetometer. | |
| virtual uint16_t | getOversamplingRate () const |
| Gets the oversampling rate for the magnetometer. | |
| virtual void | setDeclination (float declination_deg) |
| Set the magnetic declination correction value. | |
| virtual float | getDeclinationDeg () const |
| Get the currently set magnetic declination in degrees. | |
| virtual float | getDeclinationRad () const |
| Get the currently set magnetic declination in radians. | |
Public Member Functions inherited from SensorBase< MagnetometerData > | |
| SensorBase (const SensorBase &)=delete | |
| SensorBase & | operator= (const SensorBase &)=delete |
| void | setOffset (int16_t x, int16_t y, int16_t z) |
| Set sensor calibration offsets. | |
| float | getSensitivity () const |
| Get sensor sensitivity. | |
| SensorInfo | getSensorInfo () const |
| Get sensor information. | |
| virtual SensorConfig | getConfig () const |
| Get current sensor configuration. | |
Public Member Functions inherited from I2CDeviceWithHal | |
| bool | begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr) |
| Initialize the sensor using custom callback interface. | |
Public Member Functions inherited from DeviceBeginCommon | |
| virtual | ~DeviceBeginCommon () |
| uint8_t | getAddress () const |
| uint8_t | getInterface () const |
Public Member Functions inherited from SensorCommWrapper | |
| SensorCommWrapper ()=default | |
| int | readReg (uint8_t reg) const |
| int | readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const |
| int | readBuff (uint8_t *buf, size_t len) const |
| int | writeReg (uint8_t reg, uint8_t val) |
| int | writeRegBuff (uint8_t reg, uint8_t *buf, size_t len) |
| int | writeBuff (uint8_t *buf, size_t len) |
| int | writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len) |
| bool | setRegBit (uint8_t reg, uint8_t bit) |
| bool | clrRegBit (uint8_t reg, uint8_t bit) |
| bool | getRegBit (uint8_t reg, uint8_t bit) |
| int | updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted) |
| void | setAddress (uint8_t address) |
| void | setAck (bool enable) |
Public Member Functions inherited from SensorCommInterface | |
| virtual | ~SensorCommInterface ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from SensorBase< MagnetometerData > | |
| SensorBase (SensorType sensor_type=SensorType::UNKNOWN) | |
| Construct a new SensorBase object. | |
| virtual | ~SensorBase ()=default |
| Virtual destructor for proper polymorphic cleanup. | |
Protected Member Functions inherited from I2CDeviceWithHal | |
| bool | ensureValid () const override |
| Ensure the communication interface is valid. | |
Protected Member Functions inherited from DeviceBeginCommon | |
| DeviceBeginCommon ()=default | |
| virtual SensorCommBase * | getComm () const override |
| virtual void | beforeBegin () |
| virtual void | afterCommReady () |
| virtual void | afterInitSuccess (uint8_t param) |
| virtual void | onBeginFail () |
| bool | fail () |
| void | clearCommState () |
| template<typename CreateComm > | |
| bool | beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm) |
Protected Attributes inherited from MagnetometerBase | |
| uint16_t | _oversampling_rate |
| float | _declination_rad |
Protected Attributes inherited from SensorBase< MagnetometerData > | |
| SensorConfig | _config |
| Current configuration. | |
| SensorInfo | _info |
| Sensor information. | |
| int16_t | _x_offset |
| int16_t | _y_offset |
| int16_t | _z_offset |
| float | _sensitivity |
Protected Attributes inherited from DeviceBeginCommon | |
| std::unique_ptr< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
Definition at line 39 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
|
default |
Default constructor.
Initializes communication and hardware abstraction pointers to nullptr.
Creates a SensorQMC5883L object with no active communication or hardware abstraction instances.
|
default |
Destructor.
Deinitializes the communication object if it exists.
Ensures proper cleanup by deinitializing the communication interface when the sensor object is destroyed.
|
inlineoverridevirtual |
Configures the magnetometer with multiple parameters.
| mode | SUSPEND, NORMAL, CONTINUOUS_MEASUREMENT |
| range | FS_2G, FS_8G |
| data_rate_hz | The desired output data rate in Hz. Allowed values are 10.0, 50.0, 100.0 and 200.0HZ. |
| osr | OSR_8, OSR_4, OSR_2, OSR_1 |
| dsr | Placeholder parameters, meaningless |
| True | if the configuration was successful, false otherwise. |
Implements MagnetometerBase.
Definition at line 382 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SENSORLIB_LOG_E, setFullScaleRange(), setOperationMode(), setOutputDataRate(), and setOversamplingRate().
Referenced by setup().
|
inline |
Gets the chip ID of the magnetometer.
| The | chip ID. |
Definition at line 366 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorBase< MagnetometerData >::_info, and SensorInfo::uid.
|
inline |
Gets the temperature reading from the sensor.
| &temperature | The temperature value in degrees Celsius. |
| &raw_temp | The raw temperature value from the sensor. |
| True | if the temperature was read successfully, false otherwise. |
Definition at line 346 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorCommWrapper::readRegBuff(), SENSORLIB_LOG_E, and temperature().
|
inline |
Checks if data overflow has occurred.
| True | if data overflow has occurred, false otherwise. |
Definition at line 144 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorCommWrapper::getRegBit().
|
inlineoverridevirtual |
Checks if new data is available from the sensor.
| True | if new data is available, false otherwise. |
Implements MagnetometerBase.
Definition at line 133 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorCommWrapper::getRegBit().
|
inline |
Checks if data has been skipped.
| True | if data has been skipped, false otherwise. |
Definition at line 155 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorCommWrapper::getRegBit().
|
inlineoverridevirtual |
Reads the magnetic field data from the sensor.
| data | A reference to a MagnetometerData structure to store the retrieved magnetic field data. |
| True | if the data was read successfully, false otherwise. |
Implements MagnetometerBase.
Definition at line 67 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References MagnetometerBase::_declination_rad, sensorlib::_isBitSet(), SensorBase< MagnetometerData >::_sensitivity, SensorBase< MagnetometerData >::_x_offset, SensorBase< MagnetometerData >::_y_offset, SensorBase< MagnetometerData >::_z_offset, MagnetometerUtils::calculateHeading(), MagnetometerData::heading, MagnetometerData::heading_degrees, M_PI, MagnetometerData::magnetic_field, MagnetometerData::overflow, MagnetometerData::raw, SensorCommWrapper::readReg(), SensorCommWrapper::readRegBuff(), SENSORLIB_LOG_E, MagnetometerData::skip_data, x, SensorVector::x, RawVector::x, y, SensorVector::y, RawVector::y, SensorVector::z, and RawVector::z.
Referenced by loop().
|
inlineoverridevirtual |
Resets the sensor to its default state.
| True | if the reset command was successful, false otherwise. |
Implements MagnetometerBase.
Definition at line 166 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References DeviceBeginCommon::hal, and SensorCommWrapper::writeReg().
|
inlineoverridevirtual |
QMC5883L does not support self-test checks.
| Always | return True. |
Implements MagnetometerBase.
Definition at line 179 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SENSORLIB_LOG_E.
|
inlineoverridevirtual |
QM5883L does not support downsampling.
| always | false. |
Implements MagnetometerBase.
Definition at line 332 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SENSORLIB_LOG_E.
|
inlineoverridevirtual |
Sets the full-scale range of the magnetometer.
| range | FS_2G, FS_8G |
| True | if the range was set successfully, false otherwise. |
Implements MagnetometerBase.
Definition at line 193 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorBase< MagnetometerData >::_config, SensorBase< MagnetometerData >::_sensitivity, FS_2G, FS_8G, SensorConfig::range, SENSORLIB_LOG_E, and SensorCommWrapper::updateBits().
Referenced by configMagnetometer().
|
inlineoverridevirtual |
Sets the operation mode of the magnetometer.
| mode | SUSPEND, NORMAL, CONTINUOUS_MEASUREMENT |
| True | if the mode was set successfully, false otherwise. |
Implements MagnetometerBase.
Definition at line 266 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorBase< MagnetometerData >::_config, CONTINUOUS_MEASUREMENT, SensorConfig::mode, NORMAL, SENSORLIB_LOG_E, SUSPEND, and SensorCommWrapper::updateBits().
Referenced by configMagnetometer().
|
inlineoverridevirtual |
Sets the bandwidth of the magnetometer.
| data_rate_hz | The desired output data rate in Hz. Allowed values are 10.0, 50.0, 100.0 and 200.0HZ. |
| True | if the bandwidth was set successfully, false otherwise. |
Implements MagnetometerBase.
Definition at line 229 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References SensorBase< MagnetometerData >::_config, SensorConfig::sample_rate, SENSORLIB_LOG_D, SENSORLIB_LOG_E, and SensorCommWrapper::updateBits().
Referenced by configMagnetometer().
|
inlineoverridevirtual |
Sets the oversampling rate of the magnetometer.
| osr | OSR_8, OSR_4, OSR_2, OSR_1 |
| True | if the oversampling rate was set successfully, false otherwise. |
Implements MagnetometerBase.
Definition at line 296 of file sensor/magnetometer/qmc/SensorQMC5883L.hpp.
References MagnetometerBase::_oversampling_rate, OSR_1, OSR_2, OSR_4, OSR_8, SENSORLIB_LOG_E, and SensorCommWrapper::updateBits().
Referenced by configMagnetometer().