|
I2C LSM9DS1 RaspberryPI C++ Library
|
Main class for the LSM9DS1 acceleromter which manages the data acquisition via pigpio and calls the main program via a callback handler. More...
#include <LSM9DS1.h>
Public Member Functions | |
| LSM9DS1 (DeviceSettings deviceSettings=DeviceSettings()) | |
| LSM9DS1 class constructor. More... | |
| void | begin (GyroSettings gyroSettings=GyroSettings(), AccelSettings accelSettings=AccelSettings(), MagSettings magSettings=MagSettings(), TemperatureSettings temperatureSettings=TemperatureSettings()) |
| Initializes the gyro, accelerometer, magnetometer and starts the acquistion. More... | |
| void | end () |
| Ends the data acquisition and closes all IO. | |
| void | setCallback (LSM9DS1callback *cb) |
| Sets the callback which receives the samples at the sampling rate. More... | |
| bool | accelAvailable () |
| Polls the accelerometer status register to check if new data is available. More... | |
| bool | gyroAvailable () |
| Polls the gyroscope status register to check if new data is available. More... | |
| bool | tempAvailable () |
| Polls the temperature status register to check if new data is available. More... | |
| bool | magAvailable (lsm9ds1_axis axis=ALL_AXIS) |
| Polls the magnetometer status register to check if new data is available. More... | |
| int16_t | readGyro (lsm9ds1_axis axis) |
| Read a specific axis of the gyroscope. More... | |
| int16_t | readAccel (lsm9ds1_axis axis) |
| Read a specific axis of the accelerometer. More... | |
| int16_t | readMag (lsm9ds1_axis axis) |
| Read a specific axis of the magnetometer. More... | |
| void | magOffset (uint8_t axis, int16_t offset) |
| Sets the magnetometer offset. More... | |
| float | calcGyro (int16_t gyro) |
| Convert from RAW signed 16-bit value to degrees per second This function reads in a signed 16-bit value and returns the scaled DPS. More... | |
| float | calcAccel (int16_t accel) |
| Convert from RAW signed 16-bit value to gravity (g's). More... | |
| float | calcMag (int16_t mag) |
| Convert from RAW signed 16-bit value to Gauss (Gs) This function reads in a signed 16-bit value and returns the scaled Gs. More... | |
| void | setGyroScale (GyroSettings::Scale gScl) |
| Set the full-scale range of the gyroscope. More... | |
| void | setAccelScale (AccelSettings::Scale aScl) |
| Set the full-scale range of the accelerometer. More... | |
| void | setMagScale (MagSettings::Scale mScl) |
| Set the full-scale range of the magnetometer. More... | |
| uint8_t | getGyroIntSrc () |
| Get contents of Gyroscope interrupt source register. | |
| uint8_t | getAccelIntSrc () |
| Get contents of accelerometer interrupt source register. | |
| uint8_t | getMagIntSrc () |
| Get contents of magnetometer interrupt source register. | |
| uint8_t | getInactivity () |
| Get status of inactivity interrupt. | |
| uint8_t | getFIFOSamples () |
| Get number of FIFO samples. | |
Main class for the LSM9DS1 acceleromter which manages the data acquisition via pigpio and calls the main program via a callback handler.
The constructor and the begin() function have default settings so that in the simplest case just a callback needs to be registered and then begin be called. To stop the data acquistion call end().
| LSM9DS1::LSM9DS1 | ( | DeviceSettings | deviceSettings = DeviceSettings() | ) |
LSM9DS1 class constructor.
| deviceSettings | is defined in DeviceSettings The deviceSettings has default values for standard wiring. |
| bool LSM9DS1::accelAvailable | ( | ) |
Polls the accelerometer status register to check if new data is available.
| void LSM9DS1::begin | ( | GyroSettings | gyroSettings = GyroSettings(), |
| AccelSettings | accelSettings = AccelSettings(), |
||
| MagSettings | magSettings = MagSettings(), |
||
| TemperatureSettings | temperatureSettings = TemperatureSettings() |
||
| ) |
Initializes the gyro, accelerometer, magnetometer and starts the acquistion.
This will set up the scale and output rate of each sensor.
| accelSettings | Accelerometer settings with default settings. |
| gyroSettings | Gyroscope settings with default settings. |
| magSettings | Magnetometer settings with default settings. |
| temperatureSettings | Temperature sensor settings with default settings. |
| float LSM9DS1::calcAccel | ( | int16_t | accel | ) |
Convert from RAW signed 16-bit value to gravity (g's).
This function reads in a signed 16-bit value and returns the scaled g's. This function relies on aScale and aRes being correct.
| accel | A signed 16-bit raw reading from the accelerometer. |
| float LSM9DS1::calcGyro | ( | int16_t | gyro | ) |
Convert from RAW signed 16-bit value to degrees per second This function reads in a signed 16-bit value and returns the scaled DPS.
This function relies on gScale and gRes being correct.
| gyro | A signed 16-bit raw reading from the gyroscope. |
| float LSM9DS1::calcMag | ( | int16_t | mag | ) |
Convert from RAW signed 16-bit value to Gauss (Gs) This function reads in a signed 16-bit value and returns the scaled Gs.
This function relies on mScale and mRes being correct.
| mag | A signed 16-bit raw reading from the magnetometer. |
| bool LSM9DS1::gyroAvailable | ( | ) |
Polls the gyroscope status register to check if new data is available.
| bool LSM9DS1::magAvailable | ( | lsm9ds1_axis | axis = ALL_AXIS | ) |
Polls the magnetometer status register to check if new data is available.
| axis | can be either X_AXIS, Y_AXIS, Z_AXIS, to check for new data on one specific axis. Or ALL_AXIS (default) to check for new data on all axes. |
| void LSM9DS1::magOffset | ( | uint8_t | axis, |
| int16_t | offset | ||
| ) |
Sets the magnetometer offset.
| axis | can be any of X_AXIS, Y_AXIS, or Z_AXIS. |
| offset | in raw units |
| int16_t LSM9DS1::readAccel | ( | lsm9ds1_axis | axis | ) |
Read a specific axis of the accelerometer.
| axis | can be any of X_AXIS, Y_AXIS, or Z_AXIS. |
| int16_t LSM9DS1::readGyro | ( | lsm9ds1_axis | axis | ) |
Read a specific axis of the gyroscope.
| axis | can be any of X_AXIS, Y_AXIS, or Z_AXIS. |
| int16_t LSM9DS1::readMag | ( | lsm9ds1_axis | axis | ) |
Read a specific axis of the magnetometer.
| axis | can be any of X_AXIS, Y_AXIS, or Z_AXIS. |
| void LSM9DS1::setAccelScale | ( | AccelSettings::Scale | aScl | ) |
Set the full-scale range of the accelerometer.
| The | desired accelerometer scale. |
|
inline |
Sets the callback which receives the samples at the sampling rate.
| cb | Callback interface. |
| void LSM9DS1::setGyroScale | ( | GyroSettings::Scale | gScl | ) |
Set the full-scale range of the gyroscope.
This function can be called to set the scale of the gyroscope to 245, 500, or 200 degrees per second.
| gScl | The desired gyroscope scale. |
| void LSM9DS1::setMagScale | ( | MagSettings::Scale | mScl | ) |
Set the full-scale range of the magnetometer.
The desired magnetometer scale.
| bool LSM9DS1::tempAvailable | ( | ) |
Polls the temperature status register to check if new data is available.