Adafruit LSM9DS1 Library
|
#include <Adafruit_LSM9DS1.h>
Classes | |
class | Sensor |
struct | vector_s |
Public Types | |
enum | lsm9ds1AccGyroRegisters_t { LSM9DS1_REGISTER_WHO_AM_I_XG = 0x0F, LSM9DS1_REGISTER_CTRL_REG1_G = 0x10, LSM9DS1_REGISTER_CTRL_REG2_G = 0x11, LSM9DS1_REGISTER_CTRL_REG3_G = 0x12, LSM9DS1_REGISTER_TEMP_OUT_L = 0x15, LSM9DS1_REGISTER_TEMP_OUT_H = 0x16, LSM9DS1_REGISTER_STATUS_REG = 0x17, LSM9DS1_REGISTER_OUT_X_L_G = 0x18, LSM9DS1_REGISTER_OUT_X_H_G = 0x19, LSM9DS1_REGISTER_OUT_Y_L_G = 0x1A, LSM9DS1_REGISTER_OUT_Y_H_G = 0x1B, LSM9DS1_REGISTER_OUT_Z_L_G = 0x1C, LSM9DS1_REGISTER_OUT_Z_H_G = 0x1D, LSM9DS1_REGISTER_CTRL_REG4 = 0x1E, LSM9DS1_REGISTER_CTRL_REG5_XL = 0x1F, LSM9DS1_REGISTER_CTRL_REG6_XL = 0x20, LSM9DS1_REGISTER_CTRL_REG7_XL = 0x21, LSM9DS1_REGISTER_CTRL_REG8 = 0x22, LSM9DS1_REGISTER_CTRL_REG9 = 0x23, LSM9DS1_REGISTER_CTRL_REG10 = 0x24, LSM9DS1_REGISTER_OUT_X_L_XL = 0x28, LSM9DS1_REGISTER_OUT_X_H_XL = 0x29, LSM9DS1_REGISTER_OUT_Y_L_XL = 0x2A, LSM9DS1_REGISTER_OUT_Y_H_XL = 0x2B, LSM9DS1_REGISTER_OUT_Z_L_XL = 0x2C, LSM9DS1_REGISTER_OUT_Z_H_XL = 0x2D } |
enum | lsm9ds1AccelRange_t { LSM9DS1_ACCELRANGE_2G = (0b00 << 3), LSM9DS1_ACCELRANGE_16G = (0b01 << 3), LSM9DS1_ACCELRANGE_4G = (0b10 << 3), LSM9DS1_ACCELRANGE_8G = (0b11 << 3) } |
enum | lsm9ds1AccelDataRate_t { LSM9DS1_ACCELDATARATE_POWERDOWN = (0b0000 << 5), LSM9DS1_ACCELDATARATE_10HZ = (0b001 << 5), LSM9DS1_ACCELDATARATE_50HZ = (0b010 << 5), LSM9DS1_ACCELDATARATE_119HZ = (0b011 << 5), LSM9DS1_ACCELDATARATE_238HZ = (0b100 << 5), LSM9DS1_ACCELDATARATE_476HZ = (0b101 << 5), LSM9DS1_ACCELDATARATE_952HZ = (0b110 << 5) } |
enum | lsm9ds1MagGain_t { LSM9DS1_MAGGAIN_4GAUSS = (0b00 << 5), LSM9DS1_MAGGAIN_8GAUSS = (0b01 << 5), LSM9DS1_MAGGAIN_12GAUSS = (0b10 << 5), LSM9DS1_MAGGAIN_16GAUSS = (0b11 << 5) } |
enum | lsm9ds1GyroScale_t { LSM9DS1_GYROSCALE_245DPS, LSM9DS1_GYROSCALE_500DPS, LSM9DS1_GYROSCALE_2000DPS } |
typedef struct Adafruit_LSM9DS1::vector_s | lsm9ds1Vector_t |
Public Member Functions | |
Adafruit_LSM9DS1 (int32_t sensorID=0) | |
Instantiate with default hardware I2C interface. More... | |
Adafruit_LSM9DS1 (TwoWire *wireBus, int32_t sensorID=0) | |
Instantiate with hardware I2C interface. More... | |
Adafruit_LSM9DS1 (int8_t xmcs, int8_t gcs, int32_t sensorID=0) | |
Instantiate with hardware SPI interface. More... | |
Adafruit_LSM9DS1 (int8_t clk, int8_t miso, int8_t mosi, int8_t xmcs, int8_t gcs, int32_t sensorID=0) | |
Instantiate with software SPI interface. More... | |
bool | begin (void) |
Initialize I2C or SPI and detect/initialize subsensors. More... | |
void | read (void) |
Read all four sensor subcomponents. | |
void | readAccel (void) |
Read the sensor accelerometer sensor component. | |
void | readGyro (void) |
Read the sensor gyroscope sensor component. | |
void | readMag (void) |
Read the sensor magnetometer sensor component. | |
void | readTemp (void) |
Read the sensor temperature sensor component. | |
void | setupAccel (lsm9ds1AccelRange_t range, lsm9ds1AccelDataRate_t rate=LSM9DS1_ACCELDATARATE_10HZ) |
Configure the accelerometer ranging. More... | |
void | setupMag (lsm9ds1MagGain_t gain) |
Configure the magnetometer gain. More... | |
void | setupGyro (lsm9ds1GyroScale_t scale) |
Configure the gyroscope scaling. More... | |
bool | getEvent (sensors_event_t *accel, sensors_event_t *mag, sensors_event_t *gyro, sensors_event_t *temp) |
Gets the most recent accel sensor events for all 4 sensors. More... | |
void | getSensor (sensor_t *accel, sensor_t *mag, sensor_t *gyro, sensor_t *temp) |
Gets the sensor_t data for all 4 sub-sensors at once call. More... | |
Sensor & | getAccel (void) |
Return Adafruit_Sensor compatible interface for accelerometer. More... | |
Sensor & | getGyro (void) |
Return Adafruit_Sensor compatible interface for gyroscope. More... | |
Sensor & | getTemp (void) |
Return Adafruit_Sensor compatible interface for temperature. More... | |
Adafruit_Sensor & | getMag (void) |
Return Adafruit_Sensor compatible interface for magnetometer. More... | |
Public Attributes | |
lsm9ds1Vector_t | accelData |
Last read accelerometer data will be available here. | |
lsm9ds1Vector_t | gyroData |
Last read gyroscope data will be available here. | |
lsm9ds1Vector_t | magData |
Last read magnetometer data will be available here. | |
int16_t | temperature |
Last read temperzture data will be available here. | |
! Interface object for LSM9DS1 9-DoF sensor
typedef struct Adafruit_LSM9DS1::vector_s Adafruit_LSM9DS1::lsm9ds1Vector_t |
! 3D floating point vector with X Y Z components
! Register mapping for accelerometer/gyroscope component
! Enumeration for accelerometer range (2/4/8/16 g)
! Enumeration for accelerometer data rate 10 - 952 Hz
! Enumeration for magnetometer scaling (4/8/12/16 gauss)
! Enumeration for gyroscope scaling (245/500/2000 dps)
Adafruit_LSM9DS1::Adafruit_LSM9DS1 | ( | int32_t | sensorID = 0 | ) |
Instantiate with default hardware I2C interface.
sensorID | Unique identifier you'd like for the sensors |
Adafruit_LSM9DS1::Adafruit_LSM9DS1 | ( | TwoWire * | wireBus, |
int32_t | sensorID = 0 |
||
) |
Instantiate with hardware I2C interface.
wireBus | The I2C wire interface you'd like to use |
sensorID | Unique identifier you'd like for the sensors |
Adafruit_LSM9DS1::Adafruit_LSM9DS1 | ( | int8_t | xgcs, |
int8_t | mcs, | ||
int32_t | sensorID = 0 |
||
) |
Instantiate with hardware SPI interface.
xgcs | SPI CS pin for accelerometer/gyro subchip |
mcs | SPI CS pin for magnetometer subchip |
sensorID | Unique identifier you'd like for the sensors |
Adafruit_LSM9DS1::Adafruit_LSM9DS1 | ( | int8_t | sclk, |
int8_t | smiso, | ||
int8_t | smosi, | ||
int8_t | xgcs, | ||
int8_t | mcs, | ||
int32_t | sensorID = 0 |
||
) |
Instantiate with software SPI interface.
sclk | SPI clock pin |
smiso | SPI MISO pin |
smosi | SPI MOSI pin |
xgcs | SPI CS pin for accelerometer/gyro subchip |
mcs | SPI CS pin for magnetometer subchip |
sensorID | Unique identifier you'd like for the sensors |
bool Adafruit_LSM9DS1::begin | ( | void | ) |
Initialize I2C or SPI and detect/initialize subsensors.
void Adafruit_LSM9DS1::setupAccel | ( | lsm9ds1AccelRange_t | range, |
lsm9ds1AccelDataRate_t | rate = LSM9DS1_ACCELDATARATE_10HZ |
||
) |
Configure the accelerometer ranging.
range | Can be LSM9DS1_ACCELRANGE_2G, LSM9DS1_ACCELRANGE_4G, LSM9DS1_ACCELRANGE_8G, LSM9DS1_ACCELRANGE_16G |
rate | Can be LSM9DS1_ACCELDATARATE_10HZ, LSM9DS1_ACCELDATARATE_50HZ, LSM9DS1_ACCELDATARATE_119HZ, LSM9DS1_ACCELDATARATE_238HZ, LSM9DS1_ACCELDATARATE_476HZ, LSM9DS1_ACCELDATARATE_952HZ |
void Adafruit_LSM9DS1::setupMag | ( | lsm9ds1MagGain_t | gain | ) |
Configure the magnetometer gain.
gain | Can be LSM9DS1_MAGGAIN_4GAUSS, LSM9DS1_MAGGAIN_8GAUSS, LSM9DS1_MAGGAIN_12GAUSS, LSM9DS1_MAGGAIN_16GAUSS |
void Adafruit_LSM9DS1::setupGyro | ( | lsm9ds1GyroScale_t | scale | ) |
Configure the gyroscope scaling.
scale | Can be LSM9DS1_GYROSCALE_245DPS, LSM9DS1_GYROSCALE_500DPS or LSM9DS1_GYROSCALE_2000DPS |
bool Adafruit_LSM9DS1::getEvent | ( | sensors_event_t * | accelEvent, |
sensors_event_t * | magEvent, | ||
sensors_event_t * | gyroEvent, | ||
sensors_event_t * | tempEvent | ||
) |
Gets the most recent accel sensor events for all 4 sensors.
accelEvent | The accelerometer event object we will fill, pass NULL to skip |
magEvent | The magnetometer event object we will fill, pass NULL to skip |
gyroEvent | The gyroscope event object we will fill, pass NULL to skip |
tempEvent | The temperature event object we will fill, pass NULL to skip |
void Adafruit_LSM9DS1::getSensor | ( | sensor_t * | accel, |
sensor_t * | mag, | ||
sensor_t * | gyro, | ||
sensor_t * | temp | ||
) |
Gets the sensor_t data for all 4 sub-sensors at once call.
accel | The accelerometer sensor_t object we will fill, pass NULL to skip |
mag | The magnetometer sensor_t object we will fill, pass NULL to skip |
gyro | The gyroscope sensor_t object we will fill, pass NULL to skip |
temp | The temperature sensor_t object we will fill, pass NULL to skip |
|
inline |
Return Adafruit_Sensor compatible interface for accelerometer.
|
inline |
Return Adafruit_Sensor compatible interface for gyroscope.
|
inline |
Return Adafruit_Sensor compatible interface for temperature.
|
inline |
Return Adafruit_Sensor compatible interface for magnetometer.