|
DUDS
|
Distributed Update of Data from Something
|
Initial support of the magnetometer of the LSM9DS1. More...
#include <LSM9DS1.hpp>
Classes | |
| union | RawSample |
| Stores the sample data as reported by the device. More... | |
| struct | Settings |
| The various settings for the device packed into an integer to avoid passing a lot of parameters. More... | |
Public Types | |
| typedef duds::data::QuantityXyz | ConvertedQuantity |
| The sample data converted to Tesla. More... | |
| enum | MagAxesMode { AxesLowPower, AxesLowPerformance, AxesMediumPerformance, AxesHighPerformance } |
| Selects an operation mode for the axes. More... | |
| enum | MagRange { MagRange400uT, MagRange800uT, MagRange1200uT, MagRange1600uT } |
| The maximum magnitude options for the magnetometer. More... | |
Public Member Functions | |
| LSM9DS1Mag (std::unique_ptr< duds::hardware::interface::I2c > &i2c) | |
| Attempts to identify the device, then suspends the device's operation. More... | |
| ~LSM9DS1Mag () | |
| Calls suspend(). More... | |
| void | configure (float freq, Settings settings) |
| Configures the device. More... | |
| void | quantity (ConvertedQuantity &ps) const |
| const RawSample & | rawSample () const |
| Returns the magnetometer data as read from the device. More... | |
| void | resume () |
| Resumes operation after a call to suspend(). More... | |
| bool | sample () |
| Reads sampled data from the device. More... | |
| float | sampleRate () const |
| Returns the confiured sampling rate. More... | |
| void | start () |
| Tells the device to start sampling. More... | |
| void | suspend () |
| Suspends operation by putting the device into a low-power mode that discontinues sampling. More... | |
Private Attributes | |
| Settings | cfg |
| The current various configuration options. More... | |
| duds::hardware::interface::Conversation | initialize |
| The conversation used to initialize the device. More... | |
| std::unique_ptr< duds::hardware::interface::I2c > | magcom |
| The I2C communication interface. More... | |
| RawSample | magn |
| The values supplied by the device. More... | |
| duds::hardware::interface::Conversation | magsample |
| The conversation used to read in samples from the device. More... | |
| float | mdatarate |
| The currently configured sample rate. More... | |
| std::int8_t | mdrval |
| The data rate value given to the device. More... | |
| duds::hardware::interface::Conversation | statq |
Initial support of the magnetometer of the LSM9DS1.
The accelerometer and gyroscope are supported by LSM9DS1AccelGyro because it acts like an independent device. The documentation makes it seem as though the LSM9DS1 is really two devices stuck together.
The axes for the magnetometer are not the same as the accelerometer and gyroscope. The magnetometer's axes are the accelerometer's axes rotated about the Z-axis 90 degrees such that the +X axis is rotated to the accelerometer's -Y axis. This class will modify the magnetometer's data to have the same axes because having different axes is bizarre.
The Sparkfun board I've got uses I2C address 0x1E for the magnetometer.
Definition at line 282 of file LSM9DS1.hpp.
The sample data converted to Tesla.
Definition at line 299 of file LSM9DS1.hpp.
Selects an operation mode for the axes.
The documentation isn't clear on anything here, so take a guess as to what these options do.
Definition at line 313 of file LSM9DS1.hpp.
The maximum magnitude options for the magnetometer.
| Enumerator | |
|---|---|
| MagRange400uT | 400 microtesla |
| MagRange800uT | 800 microtesla |
| MagRange1200uT | 1200 microtesla |
| MagRange1600uT | 1600 microtesla |
Definition at line 303 of file LSM9DS1.hpp.
| duds::hardware::devices::instruments::LSM9DS1Mag::LSM9DS1Mag | ( | std::unique_ptr< duds::hardware::interface::I2c > & | i2c | ) |
Attempts to identify the device, then suspends the device's operation.
This resets the device, which requires 2ms to complete.
Sparkfun's board uses device address 0x1E.
| i2c | The I2C object to use to communicate with the magnetometer part of the device. This LSM9DS1 object will take ownership over the communicator. |
| DeviceMisidentified | The reported device ID is incorrect. |
Definition at line 368 of file LSM9DS1.cpp.
| duds::hardware::devices::instruments::LSM9DS1Mag::~LSM9DS1Mag | ( | ) |
Calls suspend().
Definition at line 414 of file LSM9DS1.cpp.
| void duds::hardware::devices::instruments::LSM9DS1Mag::configure | ( | float | freq, |
| Settings | settings | ||
| ) |
Configures the device.
| freq | The minimum sample frequency. If the rate is too high, LSM9DS1BadDataRate will be thrown. |
| settings | The requested device configuration. |
| LSM9DS1NoInsturment | The configuration does not select either the accelerometer or magnetometer for use. |
| LSM9DS1BadMagnitude | The requested maximum magnetude for the accelerometer is either not supported or an invalid value. |
| LSM9DS1BadDataRate |
Definition at line 418 of file LSM9DS1.cpp.
| void duds::hardware::devices::instruments::LSM9DS1Mag::quantity | ( | ConvertedQuantity & | ps | ) | const |
Definition at line 501 of file LSM9DS1.cpp.
|
inline |
Returns the magnetometer data as read from the device.
Definition at line 475 of file LSM9DS1.hpp.
|
inline |
Resumes operation after a call to suspend().
Seems to be a nice name that I used with other device drivers, so I put it here until I do more to figure out a consistent interface that I like.
| DeviceUninitalized | init() hasn't been called. |
Definition at line 455 of file LSM9DS1.hpp.
| bool duds::hardware::devices::instruments::LSM9DS1Mag::sample | ( | ) |
Reads sampled data from the device.
Definition at line 481 of file LSM9DS1.cpp.
|
inline |
Returns the confiured sampling rate.
The value will be zero if configure() has not yet been called, or if it failed.
Definition at line 467 of file LSM9DS1.hpp.
|
inline |
Tells the device to start sampling.
Definition at line 439 of file LSM9DS1.hpp.
| void duds::hardware::devices::instruments::LSM9DS1Mag::suspend | ( | ) |
Suspends operation by putting the device into a low-power mode that discontinues sampling.
This may require as much as 300ms to complete if the magnetometer is in use.
Definition at line 474 of file LSM9DS1.cpp.
Referenced by configure(), and ~LSM9DS1Mag().
|
private |
The current various configuration options.
Definition at line 392 of file LSM9DS1.hpp.
Referenced by configure(), quantity(), and sample().
|
private |
The conversation used to initialize the device.
It is created in init() and held for later use by resume().
Definition at line 376 of file LSM9DS1.hpp.
|
private |
The I2C communication interface.
Definition at line 371 of file LSM9DS1.hpp.
Referenced by configure(), LSM9DS1Mag(), sample(), and suspend().
|
private |
The values supplied by the device.
Definition at line 384 of file LSM9DS1.hpp.
Referenced by quantity(), and sample().
|
private |
The conversation used to read in samples from the device.
Definition at line 380 of file LSM9DS1.hpp.
Referenced by configure(), and sample().
|
private |
The currently configured sample rate.
Definition at line 388 of file LSM9DS1.hpp.
Referenced by configure().
|
private |
The data rate value given to the device.
Definition at line 396 of file LSM9DS1.hpp.
Referenced by configure().
|
private |
Definition at line 380 of file LSM9DS1.hpp.
Referenced by configure(), and sample().