18 namespace duds {
namespace hardware {
namespace devices {
namespace instruments {
25 namespace LSM9DS1_internal {
141 std::int8_t &destVal,
144 const std::map<float, int> &rateMap
146 std::map<float, int>::const_iterator dri = rateMap.lower_bound(reqRate);
147 if (dri == rateMap.cend()) {
150 destVal = dri->second;
151 actualRate = dri->first;
165 8.75 * 1e-3 * M_PI / 180.0,
166 17.5 * 1e-3 * M_PI / 180.0,
168 70.0 * 1e-3 * M_PI / 180.0
181 using namespace LSM9DS1_internal;
189 std::unique_ptr<duds::hardware::interface::I2c> &i2c
190 ) : agcom(
std::
move(i2c)), agdatarate(0)
197 agcom->converse(firstcon);
215 agcom->converse(firstcon);
216 std::cout <<
"LSM9DS1AccelGyro accel reset; got ack ?!?" << std::endl;
223 std::this_thread::sleep_for(std::chrono::milliseconds(2));
278 std::uint8_t tmpregs[3] = {
287 tmpregs[0] << tmpregs[1] << tmpregs[2];
288 agcom->converse(conv);
293 agcom->converse(conv);
299 agcom->converse(conv);
330 agcom->converse(conv);
369 std::unique_ptr<duds::hardware::interface::I2c> &i2c
370 ) : magcom(
std::
move(i2c)), mdatarate(0)
378 magcom->converse(firstcon);
397 magcom->converse(firstcon);
398 std::cout <<
"LSM9DS1Mag mag reset; got ack ?!?" << std::endl;
405 std::this_thread::sleep_for(std::chrono::milliseconds(2));
445 std::uint8_t tmpregs[4] = {
451 (std::uint8_t)(settings.
magRange << 5),
453 (std::uint8_t)(settings.
zMagMode << 2)
456 tmpregs[1] << tmpregs[2] << tmpregs[3];
void clear()
Makes the conversation empty.
MagAxesMode zMagMode
Operating mode for the Z axis.
MagRange magRange
The maximum magnetude setting.
duds::hardware::interface::Conversation statq
duds::hardware::interface::Conversation magsample
The conversation used to read in samples from the device.
void suspend()
Suspends operation by putting the device into a low-power mode that discontinues sampling.
float mdatarate
The currently configured sample rate.
double & y()
Returns the scalar value for the Y-axis.
The requested data rate is unsupported.
unsigned int accelerometer
Flag to use the accelerometer.
boost::error_info< struct Info_i2cdevaddr, int > I2cDeviceAddr
Provides the device (slave) address along with an error.
Unit unit
The units describing the value.
ConversationVector & addInputVector(std::size_t len)
Creates a new ConversationVector for fixed length input and initializes it with the given length...
void accelerometerQuantity(ConvertedQuantity &ps) const
Provides the accelerometer data in meters per second squared.
float agdatarate
The currently configured sample rate.
double & z()
Returns the scalar value for the Z-axis.
void gyroscopeQuantity(ConvertedQuantity &ps) const
Provides the gyroscope data in radians per second.
GyroRange gyroRange
The maximum magnetude setting for the gyroscope.
~LSM9DS1Mag()
Calls suspend().
unsigned int magTempComp
Enables temperature compensation using a temperature sensor inside the device.
boost::error_info< struct Info_UpdateRate, float > RequestedUpdateRate
bool sample()
Reads sampled data from the device.
A general status register; same data as AgrStatusPreAccel.
unsigned int gyroLowPower
Enable the low-power mode of the gyroscope.
move_impl move(unsigned int c, unsigned int r)
Display stream manipulator that moves the display cursor to the given location.
unsigned int magLowPower
A low-power mode that forces the 0.625Hz sample rate.
AccelGyroRegs
The registers for the accelerometer and gyroscope device.
The device did not respond to its address (NACK).
LSM9DS1AccelGyro(std::unique_ptr< duds::hardware::interface::I2c > &i2c)
Attempts to identify the device, then suspends the device's operation.
void suspend()
Suspends operation by putting the device into a low-power mode that discontinues sampling.
bool sample()
Reads sampled data from the device.
constexpr Unit Tesla(DUDS_UNIT_VALUE(-1, 0, 0, 1, 0, 0, -2, 0, 0))
std::unique_ptr< duds::hardware::interface::I2c > magcom
The I2C communication interface.
unsigned int magnetometer
Flag to use the magnetometer.
void quantity(ConvertedQuantity &ps) const
MagAxesMode xyMagMode
Operating mode for the X and Y axes.
AccelRange accelRange
The maximum magnetude setting for the accelerometer.
double & x()
Returns the scalar value for the X-axis.
static bool matchDataRate(std::int8_t &destVal, float &actualRate, float reqRate, const std::map< float, int > &rateMap)
Finds the lowest data rate that is at least as fast as requested, and the value needed to select this...
duds::hardware::interface::Conversation statq
std::unique_ptr< duds::hardware::interface::I2c > agcom
The I2C communication interface.
static const std::map< float, int > MagDataRateVals
Sample rates for the magnetometer.
MagRegs
The registers for the magnetometer device.
Unit unit
The units of all values in the array.
static const std::map< float, int > AccelGyroDataRateVals
Available sampling rates for the accelerometer and gyroscope when both are in use.
RawSample accl
The values supplied by the device.
static const double MagScaleToUnits[]
duds::hardware::interface::Conversation agsample
The conversation used to read in samples from the device.
void configure(float freq, Settings settings)
Configures the device.
unsigned int gyroHighPass
constexpr Unit Radian(DUDS_UNIT_VALUE(0, 0, 0, 0, 0, 0, 0, 1, 0))
static std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv
String converter; UTF-8 to/from UTF-32.
The various settings for the device packed into an integer to avoid passing a lot of parameters...
static const double GyroScaleToUnits[]
static const std::map< float, int > AccelDataRateVals
Available sampling rates for the accelerometer when the gyroscope is not in use.
std::int8_t mdrval
The data rate value given to the device.
Settings cfg
The current various configuration options.
RawSample magn
The values supplied by the device.
unsigned int gyroscope
Flag to use the gyroscope.
~LSM9DS1AccelGyro()
Calls suspend().
std::int8_t agdrval
The data rate value given to the device.
A QuantityArray for the common usage of a three dimentional coordinate or a triple axis sample...
The configuration requested that neither the accelerometer or magnetometer be used.
Settings cfg
The current various configuration options.
LSM9DS1Mag(std::unique_ptr< duds::hardware::interface::I2c > &i2c)
Attempts to identify the device, then suspends the device's operation.
static const double AccelScaleToUnits[]
constexpr Quantity EarthSurfaceGravity(9.80665,)
A definition for Earth-normal acceleration from gravity that comes from the 1901 General Conference o...
double value
Some value; probably something measured.
An attempt was made to use a device that seems to exist, but the responding device is not the type th...
void configure(float freq, Settings settings)
Configures the device.
ConversationVector & addOutputVector()
Creates a new ConversationVector for output and returns it for modification.
A general status register; same data as AgrStatusPreGyro.
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
The requested maximum magnitude is either unsupported or an invalid value.
constexpr Unit Second(DUDS_UNIT_VALUE(0, 0, 0, 0, 0, 0, 1, 0, 0))
Represents a two-way conversation with a device.
The various settings for the device packed into an integer to avoid passing a lot of parameters...