|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <MagnetometerBase.hpp>
Public Member Functions | |
| MagnetometerBase () | |
| Constructor for the MagnetometerBase class. | |
| virtual | ~MagnetometerBase ()=default |
| Destructor for the MagnetometerBase class. | |
| bool | readData (MagnetometerData &data) override=0 |
| Checks if new data is available from the magnetometer. | |
| bool | isDataReady () override=0 |
| Checks if new data is available from the magnetometer. | |
| bool | reset () override=0 |
| Resets the magnetometer to its default settings. | |
| bool | selfTest () override=0 |
| Performs a self-test on the magnetometer. | |
| virtual bool | setFullScaleRange (MagFullScaleRange range)=0 |
| Sets the full-scale range for the magnetometer. | |
| virtual bool | setOutputDataRate (float odr)=0 |
| Sets the output data rate for the magnetometer. | |
| virtual bool | setOperationMode (OperationMode mode)=0 |
| Sets the operation mode for the magnetometer. | |
| virtual bool | setOversamplingRate (MagOverSampleRatio osr)=0 |
| Sets the oversampling rate for the magnetometer. | |
| virtual bool | setDownsamplingRate (MagDownSampleRatio dsr)=0 |
| Sets the downsampling rate for the magnetometer. | |
| virtual bool | configMagnetometer (OperationMode mode, MagFullScaleRange range, float data_rate_hz, MagOverSampleRatio osr, MagDownSampleRatio dsr)=0 |
| Configures the magnetometer with the specified settings. | |
| 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. | |
Protected Attributes | |
| 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 |
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. | |
Definition at line 34 of file MagnetometerBase.hpp.
|
inlineexplicit |
Constructor for the MagnetometerBase class.
| None |
Definition at line 43 of file MagnetometerBase.hpp.
|
virtualdefault |
Destructor for the MagnetometerBase class.
| None |
|
pure virtual |
Configures the magnetometer with the specified settings.
| mode | The desired operation mode. |
| range | The desired full-scale range. |
| data_rate_hz | The desired output data rate in Hz. |
| osr | The desired oversampling rate. |
| dsr | The desired downsampling rate. |
| True | if the configuration was successful, false otherwise. |
Implemented in SensorQMC5883L, SensorQMC6309, SensorQSTMagnetic, and SensorBMM150.
Referenced by setup().
|
inlinevirtual |
Get the currently set magnetic declination in degrees.
Definition at line 181 of file MagnetometerBase.hpp.
References _declination_rad, and M_PI.
|
inlinevirtual |
Get the currently set magnetic declination in radians.
This is the internal representation used for calculations.
Definition at line 192 of file MagnetometerBase.hpp.
References _declination_rad.
|
inlinevirtual |
Gets the full-scale range for the magnetometer.
| The | current full-scale range (e.g., 2.0, 4.0, 8.0, 16.0). |
Definition at line 141 of file MagnetometerBase.hpp.
References SensorBase< MagnetometerData >::_config, and SensorConfig::range.
|
inlinevirtual |
Gets the operation mode for the magnetometer.
| The | current operation mode. |
Definition at line 150 of file MagnetometerBase.hpp.
References SensorBase< MagnetometerData >::_config, and SensorConfig::mode.
|
inlinevirtual |
Gets the oversampling rate for the magnetometer.
| The | current oversampling rate. |
Definition at line 159 of file MagnetometerBase.hpp.
References _oversampling_rate.
|
overridepure virtual |
Checks if new data is available from the magnetometer.
| True | if new data is available, false otherwise. |
Implements SensorBase< MagnetometerData >.
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
Referenced by calibrate().
|
overridepure virtual |
Checks if new data is available from the magnetometer.
| True | if new data is available, false otherwise. |
Implements SensorBase< MagnetometerData >.
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
Referenced by calibrate(), and loop().
|
overridepure virtual |
Resets the magnetometer to its default settings.
| True | if the reset was successful, false otherwise. |
Implements SensorBase< MagnetometerData >.
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
overridepure virtual |
Performs a self-test on the magnetometer.
| True | if the self-test passed, false otherwise. |
Implements SensorBase< MagnetometerData >.
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
inlinevirtual |
Set the magnetic declination correction value.
Magnetic declination is the angle between true north (geographic north) and magnetic north. This correction is essential for accurate compass headings.
| declination_deg | Magnetic declination in degrees |
Definition at line 172 of file MagnetometerBase.hpp.
References _declination_rad, and M_PI.
Referenced by setup().
|
pure virtual |
Sets the downsampling rate for the magnetometer.
| dsr | The desired downsampling rate. |
| True | if the downsampling rate was set successfully, false otherwise. |
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
pure virtual |
Sets the full-scale range for the magnetometer.
| range | The desired full-scale range. |
| True | if the range was set successfully, false otherwise. |
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
pure virtual |
Sets the operation mode for the magnetometer.
| mode | The desired operation mode. |
| True | if the mode was set successfully, false otherwise. |
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
pure virtual |
Sets the output data rate for the magnetometer.
| odr | The desired output data rate in Hz. |
| True | if the output data rate was set successfully, false otherwise. |
Implemented in SensorQMC5883L, SensorQMC6309, SensorBMM150, and SensorQSTMagnetic.
Referenced by calibrate().
|
pure virtual |
Sets the oversampling rate for the magnetometer.
| osr | The desired oversampling rate. |
| True | if the oversampling rate was set successfully, false otherwise. |
Implemented in SensorBMM150, SensorQMC5883L, SensorQMC6309, and SensorQSTMagnetic.
|
protected |
Definition at line 200 of file MagnetometerBase.hpp.
Referenced by getDeclinationDeg(), getDeclinationRad(), SensorBMM150::readData(), SensorQMC5883L::readData(), SensorQMC6309::readData(), SensorQSTMagnetic::readData(), and setDeclination().
|
protected |
Definition at line 199 of file MagnetometerBase.hpp.
Referenced by getOversamplingRate(), SensorBMM150::setOversamplingRate(), SensorQMC5883L::setOversamplingRate(), SensorQMC6309::setOversamplingRate(), and SensorQSTMagnetic::setOversamplingRate().