Adafruit LSM6DS Sensors Library
|
Base class for use with LSM6DS series acclerometer gyro sensors from STMicroelectronics. DO NOT USE DIRECTLY. Specific sensor variants should be subclassed as needed. More...
#include <Adafruit_LSM6DS.h>
Public Member Functions | |
Adafruit_LSM6DS () | |
Instantiates a new LSM6DS class. | |
virtual | ~Adafruit_LSM6DS () |
Cleans up the LSM6DS. | |
bool | begin_I2C (uint8_t i2c_addr=LSM6DS_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensorID=0) |
Sets up the hardware and initializes I2C. More... | |
bool | begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI, int32_t sensorID=0, uint32_t frequency=1000000) |
Sets up the hardware and initializes hardware SPI. More... | |
bool | begin_SPI (int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin, int32_t sensorID=0, uint32_t frequency=1000000) |
Sets up the hardware and initializes software SPI. More... | |
bool | getEvent (sensors_event_t *accel, sensors_event_t *gyro, sensors_event_t *temp) |
Gets the most recent sensor event, Adafruit Unified Sensor format. More... | |
lsm6ds_data_rate_t | getAccelDataRate (void) |
Gets the accelerometer data rate. More... | |
void | setAccelDataRate (lsm6ds_data_rate_t data_rate) |
Sets the accelerometer data rate. More... | |
lsm6ds_accel_range_t | getAccelRange (void) |
Gets the accelerometer measurement range. More... | |
void | setAccelRange (lsm6ds_accel_range_t new_range) |
Sets the accelerometer measurement range. More... | |
lsm6ds_data_rate_t | getGyroDataRate (void) |
Gets the gyro data rate. More... | |
void | setGyroDataRate (lsm6ds_data_rate_t data_rate) |
Sets the gyro data rate. More... | |
lsm6ds_gyro_range_t | getGyroRange (void) |
Gets the gyro range. More... | |
void | setGyroRange (lsm6ds_gyro_range_t new_range) |
Sets the gyro range. More... | |
void | reset (void) |
Resets the sensor to its power-on state, clearing all registers and memory. | |
void | configIntOutputs (bool active_low, bool open_drain) |
Sets the INT1 and INT2 pin activation mode. More... | |
void | configInt1 (bool drdy_temp, bool drdy_g, bool drdy_xl, bool step_detect=false, bool wakeup=false) |
Enables and disables the data ready interrupt on INT 1. More... | |
void | configInt2 (bool drdy_temp, bool drdy_g, bool drdy_xl) |
Enables and disables the data ready interrupt on INT 2. More... | |
void | highPassFilter (bool enabled, lsm6ds_hp_filter_t filter) |
Enables the high pass filter and/or slope filter. More... | |
void | enableWakeup (bool enable, uint8_t duration=0, uint8_t thresh=20) |
Enables and disables the wakeup function. More... | |
bool | awake (void) |
Checks interrupt register to see if we have a wake signal. More... | |
bool | shake (void) |
Simple shake detection. Must call enableWakeup() first. More... | |
void | enablePedometer (bool enable) |
Enables and disables the pedometer function. More... | |
void | resetPedometer (void) |
Reset the pedometer count. | |
uint16_t | readPedometer (void) |
Read the 16-bit pedometer count. More... | |
int | readAcceleration (float &x, float &y, float &z) |
Read accelerometer data. More... | |
float | accelerationSampleRate (void) |
Gets the accelerometer data rate. More... | |
int | accelerationAvailable (void) |
Check for available data from accelerometer. More... | |
int | readGyroscope (float &x, float &y, float &z) |
Read gyroscope data. More... | |
float | gyroscopeSampleRate (void) |
Get the gyroscope data rate. More... | |
int | gyroscopeAvailable (void) |
Check for available data from gyroscope. More... | |
Adafruit_Sensor * | getTemperatureSensor (void) |
Gets an Adafruit Unified Sensor object for the temp sensor component. More... | |
Adafruit_Sensor * | getAccelerometerSensor (void) |
Gets an Adafruit Unified Sensor object for the accelerometer sensor component. More... | |
Adafruit_Sensor * | getGyroSensor (void) |
Gets an Adafruit Unified Sensor object for the gyro sensor component. More... | |
Public Attributes | |
int16_t | rawAccX |
Last reading's raw accelerometer X axis. | |
int16_t | rawAccY |
Last reading's raw accelerometer Y axis. | |
int16_t | rawAccZ |
Last reading's raw accelerometer Z axis. | |
int16_t | rawTemp |
Last reading's raw temperature reading. | |
int16_t | rawGyroX |
Last reading's raw gyro X axis. | |
int16_t | rawGyroY |
Last reading's raw gyro Y axis. | |
int16_t | rawGyroZ |
Last reading's raw gyro Z axis. | |
float | temperature |
Last reading's temperature (C) | |
float | accX |
Last reading's accelerometer X axis m/s^2. | |
float | accY |
Last reading's accelerometer Y axis m/s^2. | |
float | accZ |
Last reading's accelerometer Z axis m/s^2. | |
float | gyroX |
Last reading's gyro X axis in rad/s. | |
float | gyroY |
Last reading's gyro Y axis in rad/s. | |
float | gyroZ |
Last reading's gyro Z axis in rad/s. | |
Protected Member Functions | |
uint8_t | chipID (void) |
Read chip identification register. More... | |
uint8_t | status (void) |
Read Status register. More... | |
virtual void | _read (void) |
Updates the measurement data for all sensors simultaneously. | |
virtual bool | _init (int32_t sensor_id) |
Unique subclass initializer post i2c/spi init. More... | |
Protected Attributes | |
uint16_t | _sensorid_accel |
ID number for accelerometer. | |
uint16_t | _sensorid_gyro |
ID number for gyro. | |
uint16_t | _sensorid_temp |
ID number for temperature. | |
Adafruit_I2CDevice * | i2c_dev = NULL |
Pointer to I2C bus interface. | |
Adafruit_SPIDevice * | spi_dev = NULL |
Pointer to SPI bus interface. | |
float | temperature_sensitivity |
Temp sensor sensitivity in LSB/degC. More... | |
Adafruit_LSM6DS_Temp * | temp_sensor = NULL |
Temp sensor data object. | |
Adafruit_LSM6DS_Accelerometer * | accel_sensor |
Accelerometer data object. More... | |
Adafruit_LSM6DS_Gyro * | gyro_sensor = NULL |
Gyro data object. | |
lsm6ds_accel_range_t | accelRangeBuffered = LSM6DS_ACCEL_RANGE_2_G |
buffer for the accelerometer range | |
lsm6ds_gyro_range_t | gyroRangeBuffered = LSM6DS_GYRO_RANGE_250_DPS |
buffer for the gyroscope range | |
Friends | |
class | Adafruit_LSM6DS_Temp |
class | Adafruit_LSM6DS_Accelerometer |
class | Adafruit_LSM6DS_Gyro |
Base class for use with LSM6DS series acclerometer gyro sensors from STMicroelectronics. DO NOT USE DIRECTLY. Specific sensor variants should be subclassed as needed.
boolean Adafruit_LSM6DS::begin_I2C | ( | uint8_t | i2c_address = LSM6DS_I2CADDR_DEFAULT , |
TwoWire * | wire = &Wire , |
||
int32_t | sensor_id = 0 |
||
) |
Sets up the hardware and initializes I2C.
i2c_address | The I2C address to be used. |
wire | The Wire object to be used for I2C connections. |
sensor_id | The user-defined ID to differentiate different sensors |
bool Adafruit_LSM6DS::begin_SPI | ( | uint8_t | cs_pin, |
SPIClass * | theSPI = &SPI , |
||
int32_t | sensor_id = 0 , |
||
uint32_t | frequency = 1000000 |
||
) |
Sets up the hardware and initializes hardware SPI.
cs_pin | The arduino pin # connected to chip select |
theSPI | The SPI object to be used for SPI connections. |
frequency | The SPI bus frequency |
sensor_id | The user-defined ID to differentiate different sensors |
bool Adafruit_LSM6DS::begin_SPI | ( | int8_t | cs_pin, |
int8_t | sck_pin, | ||
int8_t | miso_pin, | ||
int8_t | mosi_pin, | ||
int32_t | sensor_id = 0 , |
||
uint32_t | frequency = 1000000 |
||
) |
Sets up the hardware and initializes software SPI.
cs_pin | The arduino pin # connected to chip select |
sck_pin | The arduino pin # connected to SPI clock |
miso_pin | The arduino pin # connected to SPI MISO |
mosi_pin | The arduino pin # connected to SPI MOSI |
frequency | The SPI bus frequency |
sensor_id | The user-defined ID to differentiate different sensors |
bool Adafruit_LSM6DS::getEvent | ( | sensors_event_t * | accel, |
sensors_event_t * | gyro, | ||
sensors_event_t * | temp | ||
) |
Gets the most recent sensor event, Adafruit Unified Sensor format.
accel | Pointer to an Adafruit Unified sensor_event_t object to be filled with acceleration event data. |
gyro | Pointer to an Adafruit Unified sensor_event_t object to be filled with gyro event data. |
temp | Pointer to an Adafruit Unified sensor_event_t object to be filled with temperature event data. |
lsm6ds_data_rate_t Adafruit_LSM6DS::getAccelDataRate | ( | void | ) |
Gets the accelerometer data rate.
void Adafruit_LSM6DS::setAccelDataRate | ( | lsm6ds_data_rate_t | data_rate | ) |
Sets the accelerometer data rate.
data_rate | The the accelerometer data rate. Must be a lsm6ds_data_rate_t . |
lsm6ds_accel_range_t Adafruit_LSM6DS::getAccelRange | ( | void | ) |
Gets the accelerometer measurement range.
void Adafruit_LSM6DS::setAccelRange | ( | lsm6ds_accel_range_t | new_range | ) |
Sets the accelerometer measurement range.
new_range | The lsm6ds_accel_range_t range to set. |
lsm6ds_data_rate_t Adafruit_LSM6DS::getGyroDataRate | ( | void | ) |
Gets the gyro data rate.
void Adafruit_LSM6DS::setGyroDataRate | ( | lsm6ds_data_rate_t | data_rate | ) |
Sets the gyro data rate.
data_rate | The the gyro data rate. Must be a lsm6ds_data_rate_t . |
lsm6ds_gyro_range_t Adafruit_LSM6DS::getGyroRange | ( | void | ) |
Gets the gyro range.
void Adafruit_LSM6DS::setGyroRange | ( | lsm6ds_gyro_range_t | new_range | ) |
Sets the gyro range.
new_range | The lsm6ds_gyro_range_t to set. |
void Adafruit_LSM6DS::configIntOutputs | ( | bool | active_low, |
bool | open_drain | ||
) |
Sets the INT1 and INT2 pin activation mode.
active_low | true to set the pins as active high, false to set the mode to active low |
open_drain | true to set the pin mode as open-drain, false to set the mode to push-pull |
void Adafruit_LSM6DS::configInt1 | ( | bool | drdy_temp, |
bool | drdy_g, | ||
bool | drdy_xl, | ||
bool | step_detect = false , |
||
bool | wakeup = false |
||
) |
Enables and disables the data ready interrupt on INT 1.
drdy_temp | true to output the data ready temperature interrupt |
drdy_g | true to output the data ready gyro interrupt |
drdy_xl | true to output the data ready accelerometer interrupt |
step_detect | true to output the step detection interrupt (default off) |
wakeup | true to output the wake up interrupt (default off) |
void Adafruit_LSM6DS::configInt2 | ( | bool | drdy_temp, |
bool | drdy_g, | ||
bool | drdy_xl | ||
) |
Enables and disables the data ready interrupt on INT 2.
drdy_temp | true to output the data ready temperature interrupt |
drdy_g | true to output the data ready gyro interrupt |
drdy_xl | true to output the data ready accelerometer interrupt |
void Adafruit_LSM6DS::highPassFilter | ( | bool | filter_enabled, |
lsm6ds_hp_filter_t | filter | ||
) |
Enables the high pass filter and/or slope filter.
filter_enabled | Whether to enable the slope filter (see datasheet) |
filter | The lsm6ds_hp_filter_t that sets the data rate divisor |
void Adafruit_LSM6DS::enableWakeup | ( | bool | enable, |
uint8_t | duration = 0 , |
||
uint8_t | thresh = 20 |
||
) |
Enables and disables the wakeup function.
enable | True to turn on the wakeup function, false to turn off |
duration | How many > threshold readings to generate a wakeup |
thresh | The threshold (sensitivity) |
bool Adafruit_LSM6DS::awake | ( | void | ) |
Checks interrupt register to see if we have a wake signal.
bool Adafruit_LSM6DS::shake | ( | void | ) |
Simple shake detection. Must call enableWakeup() first.
void Adafruit_LSM6DS::enablePedometer | ( | bool | enable | ) |
Enables and disables the pedometer function.
enable | True to turn on the pedometer function, false to turn off |
uint16_t Adafruit_LSM6DS::readPedometer | ( | void | ) |
Read the 16-bit pedometer count.
int Adafruit_LSM6DS::readAcceleration | ( | float & | x, |
float & | y, | ||
float & | z | ||
) |
Read accelerometer data.
x | reference to x axis |
y | reference to y axis |
z | reference to z axis |
float Adafruit_LSM6DS::accelerationSampleRate | ( | void | ) |
Gets the accelerometer data rate.
int Adafruit_LSM6DS::accelerationAvailable | ( | void | ) |
Check for available data from accelerometer.
int Adafruit_LSM6DS::readGyroscope | ( | float & | x, |
float & | y, | ||
float & | z | ||
) |
Read gyroscope data.
x | reference to x axis |
y | reference to y axis |
z | reference to z axis |
float Adafruit_LSM6DS::gyroscopeSampleRate | ( | void | ) |
Get the gyroscope data rate.
int Adafruit_LSM6DS::gyroscopeAvailable | ( | void | ) |
Check for available data from gyroscope.
Adafruit_Sensor * Adafruit_LSM6DS::getTemperatureSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the temp sensor component.
Adafruit_Sensor * Adafruit_LSM6DS::getAccelerometerSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the accelerometer sensor component.
Adafruit_Sensor * Adafruit_LSM6DS::getGyroSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the gyro sensor component.
|
protected |
Read chip identification register.
|
protected |
Read Status register.
|
protectedvirtual |
Unique subclass initializer post i2c/spi init.
sensor_id | Optional unique ID for the sensor set |
|
friend |
Gives access to private members to Temp data object
|
friend |
Gives access to private members to Accelerometer data object
|
friend |
Gives access to private members to Gyro data object
|
protected |
Temp sensor sensitivity in LSB/degC.
|
protected |
Accelerometer data object.