|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Class that stores state and functions for interacting with Adafruit_LIS3DH. More...
#include <Adafruit_LIS3DH.h>
Public Member Functions | |
| Adafruit_LIS3DH (TwoWire *Wi=&Wire) | |
| Instantiates a new LIS3DH class in I2C. | |
| Adafruit_LIS3DH (int8_t cspin, SPIClass *theSPI=&SPI, uint32_t frequency=LIS3DH_DEFAULT_SPIFREQ) | |
| Instantiates a new LIS3DH class using hardware SPI. | |
| Adafruit_LIS3DH (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin, uint32_t frequency=LIS3DH_DEFAULT_SPIFREQ) | |
| Instantiates a new LIS3DH class using software SPI. | |
| bool | begin (uint8_t addr=LIS3DH_DEFAULT_ADDRESS, uint8_t nWAI=0x33) |
| Setups the HW (reads coefficients values, etc.). | |
| uint8_t | getDeviceID (void) |
| Get Device ID from LIS3DH_REG_WHOAMI. | |
| bool | haveNewData (void) |
| Check to see if new data available. | |
| bool | enableDRDY (bool enable_drdy=true, uint8_t int_pin=1) |
| Enable or disable the Data Ready interupt. | |
| void | read (void) |
| Reads x y z values at once. | |
| int16_t | readADC (uint8_t a) |
| Read the auxilary ADC. | |
| lis3dh_mode_t | getPerformanceMode (void) |
| Gets the performance mode for the LIS3DH. | |
| void | setPerformanceMode (lis3dh_mode_t mode) |
| Sets the performance mode for the LIS3DH. | |
| void | setRange (lis3dh_range_t range) |
| Sets the g range for the accelerometer. | |
| lis3dh_range_t | getRange (void) |
| Gets the g range for the accelerometer. | |
| void | setDataRate (lis3dh_dataRate_t dataRate) |
| Sets the data rate for the LIS3DH (controls power consumption). | |
| lis3dh_dataRate_t | getDataRate (void) |
| Gets the data rate for the LIS3DH (controls power consumption). | |
| bool | getEvent (sensors_event_t *event) |
| Gets the most recent sensor event. | |
| void | getSensor (sensor_t *sensor) |
| Gets the sensor_t data. | |
| void | setClick (uint8_t c, uint8_t clickthresh, uint8_t timelimit=10, uint8_t timelatency=20, uint8_t timewindow=255) |
| Set INT to output for single or double click. | |
| uint8_t | getClick (void) |
| Get uint8_t for single or double click. | |
| uint8_t | readAndClearInterrupt (void) |
| Get uint8_t for INT1 source and clear interrupt. | |
| void | configureHighGInterrupt (uint8_t ths, uint8_t dur) |
| Configure INT1 for high-G threshold interrupt with high-pass filter. | |
Public Attributes | |
| int16_t | x |
| x axis value | |
| int16_t | y |
| y axis value | |
| int16_t | z |
| z axis value | |
| float | x_g |
| x_g axis value (calculated by selected range) | |
| float | y_g |
| y_g axis value (calculated by selected range) | |
| float | z_g |
| z_g axis value (calculated by selected range) | |
Private Attributes | |
| TwoWire * | I2Cinterface |
| SPIClass * | SPIinterface |
| Adafruit_I2CDevice * | i2c_dev = NULL |
| Pointer to I2C bus interface. | |
| Adafruit_SPIDevice * | spi_dev = NULL |
| Pointer to SPI bus interface. | |
| uint8_t | _wai |
| int8_t | _cs |
| int8_t | _mosi |
| int8_t | _miso |
| int8_t | _sck |
| int8_t | _i2caddr |
| int32_t | _sensorID |
| uint32_t | _frequency = LIS3DH_DEFAULT_SPIFREQ |
Class that stores state and functions for interacting with Adafruit_LIS3DH.
Definition at line 368 of file Adafruit_LIS3DH.h.
| Adafruit_LIS3DH::Adafruit_LIS3DH | ( | TwoWire * | Wi = &Wire | ) |
Instantiates a new LIS3DH class in I2C.
| Wi | optional wire object |
Definition at line 41 of file Adafruit_LIS3DH.cpp.
References _cs, _miso, _mosi, _sck, _sensorID, and I2Cinterface.
| Adafruit_LIS3DH::Adafruit_LIS3DH | ( | int8_t | cspin, |
| SPIClass * | theSPI = &SPI, | ||
| uint32_t | frequency = LIS3DH_DEFAULT_SPIFREQ ) |
Instantiates a new LIS3DH class using hardware SPI.
| cspin | number of CSPIN (Chip Select) |
| *theSPI | optional parameter contains spi object |
| frequency | frequency of the SPI interface |
Definition at line 55 of file Adafruit_LIS3DH.cpp.
References _cs, _frequency, _miso, _mosi, _sck, _sensorID, and SPIinterface.
| Adafruit_LIS3DH::Adafruit_LIS3DH | ( | int8_t | cspin, |
| int8_t | mosipin, | ||
| int8_t | misopin, | ||
| int8_t | sckpin, | ||
| uint32_t | frequency = LIS3DH_DEFAULT_SPIFREQ ) |
Instantiates a new LIS3DH class using software SPI.
| cspin | number of CSPIN (Chip Select) |
| mosipin | number of pin used for MOSI (Master Out Slave In)) |
| misopin | number of pin used for MISO (Master In Slave Out) |
| sckpin | number of pin used for CLK (clock pin) |
| frequency | frequency of the SPI interface |
Definition at line 79 of file Adafruit_LIS3DH.cpp.
References _cs, _frequency, _miso, _mosi, _sck, and _sensorID.
| bool Adafruit_LIS3DH::begin | ( | uint8_t | i2caddr = LIS3DH_DEFAULT_ADDRESS, |
| uint8_t | nWAI = 0x33 ) |
Setups the HW (reads coefficients values, etc.).
| i2caddr | i2c address (optional, fallback to default) |
| nWAI | Who Am I register value - defaults to 0x33 (LIS3DH) |
Definition at line 97 of file Adafruit_LIS3DH.cpp.
References _cs, _frequency, _i2caddr, _miso, _mosi, _sck, _wai, enableDRDY(), getDeviceID(), i2c_dev, I2Cinterface, LIS3DH_DATARATE_400_HZ, LIS3DH_REG_CTRL1, LIS3DH_REG_CTRL4, LIS3DH_REG_TEMPCFG, setDataRate(), spi_dev, and SPIinterface.
| void Adafruit_LIS3DH::configureHighGInterrupt | ( | uint8_t | ths, |
| uint8_t | dur ) |
Configure INT1 for high-G threshold interrupt with high-pass filter.
Sets up CTRL_REG2 (HPF for INT1), performs the mandatory REFERENCE dummy read to zero the HPF baseline (prevents spurious interrupt at startup), programs INT1_CFG for high-event detection on all three axes (OR mode), writes threshold and duration registers, routes IA1 to the INT1 pin via CTRL_REG3, and latches the interrupt in CTRL_REG5 until INT1_SRC is read.
| ths | INT1_THS value (7-bit). LSB size depends on full-scale range: ±2g=16mg, ±4g=32mg, ±8g=62mg, ±16g=186mg per datasheet. |
| dur | INT1_DUR value (7-bit). Each count = 1/ODR. |
Definition at line 365 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CTRL2, LIS3DH_REG_CTRL3, LIS3DH_REG_CTRL5, LIS3DH_REG_INT1CFG, LIS3DH_REG_INT1DUR, LIS3DH_REG_INT1THS, LIS3DH_REG_REFERENCE, and spi_dev.
| bool Adafruit_LIS3DH::enableDRDY | ( | bool | enable_drdy = true, |
| uint8_t | int_pin = 1 ) |
Enable or disable the Data Ready interupt.
| enable_drdy | true to enable the given Data Ready interrupt on INT1, false to disable it |
| int_pin | which DRDY interrupt to enable; 1 for DRDY1, 2 for DRDY2 |
Definition at line 423 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CTRL3, and spi_dev.
Referenced by begin().
| uint8_t Adafruit_LIS3DH::getClick | ( | void | ) |
Get uint8_t for single or double click.
Definition at line 345 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CLICKSRC, and spi_dev.
| lis3dh_dataRate_t Adafruit_LIS3DH::getDataRate | ( | void | ) |
Gets the data rate for the LIS3DH (controls power consumption).
Definition at line 555 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CTRL1, and spi_dev.
| uint8_t Adafruit_LIS3DH::getDeviceID | ( | void | ) |
Get Device ID from LIS3DH_REG_WHOAMI.
Definition at line 159 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_WHOAMI, and spi_dev.
Referenced by begin().
| bool Adafruit_LIS3DH::getEvent | ( | sensors_event_t * | event | ) |
| lis3dh_mode_t Adafruit_LIS3DH::getPerformanceMode | ( | void | ) |
Gets the performance mode for the LIS3DH.
Definition at line 486 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_MODE_HIGH_RESOLUTION, LIS3DH_MODE_LOW_POWER, LIS3DH_MODE_NORMAL, LIS3DH_REG_CTRL1, LIS3DH_REG_CTRL4, and spi_dev.
Referenced by read().
| lis3dh_range_t Adafruit_LIS3DH::getRange | ( | void | ) |
Gets the g range for the accelerometer.
Definition at line 528 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CTRL4, and spi_dev.
Referenced by read().
| void Adafruit_LIS3DH::getSensor | ( | sensor_t * | sensor | ) |
Gets the sensor_t data.
| *sensor | sensor that we want to write data into |
Definition at line 593 of file Adafruit_LIS3DH.cpp.
References _sensorID.
| bool Adafruit_LIS3DH::haveNewData | ( | void | ) |
Check to see if new data available.
Definition at line 169 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_STATUS2, and spi_dev.
| void Adafruit_LIS3DH::read | ( | void | ) |
Reads x y z values at once.
Definition at line 180 of file Adafruit_LIS3DH.cpp.
References getPerformanceMode(), getRange(), i2c_dev, LIS3DH_LSB16_TO_KILO_LSB10, LIS3DH_LSB16_TO_KILO_LSB12, LIS3DH_LSB16_TO_KILO_LSB8, LIS3DH_MODE_HIGH_RESOLUTION, LIS3DH_MODE_LOW_POWER, LIS3DH_MODE_NORMAL, LIS3DH_RANGE_16_G, LIS3DH_RANGE_2_G, LIS3DH_RANGE_4_G, LIS3DH_RANGE_8_G, LIS3DH_REG_OUT_X_L, spi_dev, x, x_g, y, y_g, z, and z_g.
Referenced by getEvent().
| int16_t Adafruit_LIS3DH::readADC | ( | uint8_t | adc | ) |
Read the auxilary ADC.
| adc | adc index. possible values (1, 2, 3). |
Definition at line 247 of file Adafruit_LIS3DH.cpp.
References adc(), i2c_dev, LIS3DH_REG_OUTADC1_L, reg, and spi_dev.
| uint8_t Adafruit_LIS3DH::readAndClearInterrupt | ( | void | ) |
Get uint8_t for INT1 source and clear interrupt.
Definition at line 408 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_INT1SRC, and spi_dev.
| void Adafruit_LIS3DH::setClick | ( | uint8_t | c, |
| uint8_t | clickthresh, | ||
| uint8_t | timelimit = 10, | ||
| uint8_t | timelatency = 20, | ||
| uint8_t | timewindow = 255 ) |
Set INT to output for single or double click.
| c | 0 = turn off I1_CLICK 1 = turn on all axes & singletap 2 = turn on all axes & doubletap |
| clickthresh | CLICK threshold value |
| timelimit | sets time limit (default 10) |
| timelatency | sets time latency (default 20) |
| timewindow | sets time window (default 255) |
Definition at line 290 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CLICKCFG, LIS3DH_REG_CLICKTHS, LIS3DH_REG_CTRL3, LIS3DH_REG_CTRL5, LIS3DH_REG_TIMELATENCY, LIS3DH_REG_TIMELIMIT, LIS3DH_REG_TIMEWINDOW, and spi_dev.
| void Adafruit_LIS3DH::setDataRate | ( | lis3dh_dataRate_t | dataRate | ) |
Sets the data rate for the LIS3DH (controls power consumption).
| dataRate | data rate value |
Definition at line 542 of file Adafruit_LIS3DH.cpp.
References i2c_dev, LIS3DH_REG_CTRL1, and spi_dev.
Referenced by begin().
| void Adafruit_LIS3DH::setPerformanceMode | ( | lis3dh_mode_t | mode | ) |
Sets the performance mode for the LIS3DH.
The turn-on time to transition to 12-bit mode (high resolution) is set at 7ms, or swtch to 10-bit mode (normal) or to 8-bit mode (low power) is 1ms
| mode | mode - low power, normal, high resolution e.g. LIS3DH_MODE_LOW_POWER |
Definition at line 449 of file Adafruit_LIS3DH.cpp.
References delay(), i2c_dev, LIS3DH_MODE_HIGH_RESOLUTION, LIS3DH_MODE_LOW_POWER, LIS3DH_MODE_NORMAL, LIS3DH_REG_CTRL1, LIS3DH_REG_CTRL4, and spi_dev.
| void Adafruit_LIS3DH::setRange | ( | lis3dh_range_t | range | ) |
Sets the g range for the accelerometer.
| range | range value |
Definition at line 513 of file Adafruit_LIS3DH.cpp.
References delay(), i2c_dev, LIS3DH_REG_CTRL4, and spi_dev.
|
private |
Definition at line 422 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), Adafruit_LIS3DH(), and begin().
|
private |
Definition at line 427 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), and begin().
|
private |
Definition at line 424 of file Adafruit_LIS3DH.h.
Referenced by begin().
|
private |
Definition at line 422 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), Adafruit_LIS3DH(), and begin().
|
private |
Definition at line 422 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), Adafruit_LIS3DH(), and begin().
|
private |
Definition at line 422 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), Adafruit_LIS3DH(), and begin().
|
private |
Definition at line 426 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), Adafruit_LIS3DH(), Adafruit_LIS3DH(), getEvent(), and getSensor().
|
private |
Definition at line 420 of file Adafruit_LIS3DH.h.
Referenced by begin().
|
private |
Pointer to I2C bus interface.
Definition at line 417 of file Adafruit_LIS3DH.h.
Referenced by begin(), configureHighGInterrupt(), enableDRDY(), getClick(), getDataRate(), getDeviceID(), getPerformanceMode(), getRange(), haveNewData(), read(), readADC(), readAndClearInterrupt(), setClick(), setDataRate(), setPerformanceMode(), and setRange().
|
private |
Definition at line 414 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), and begin().
|
private |
Pointer to SPI bus interface.
Definition at line 418 of file Adafruit_LIS3DH.h.
Referenced by begin(), configureHighGInterrupt(), enableDRDY(), getClick(), getDataRate(), getDeviceID(), getPerformanceMode(), getRange(), haveNewData(), read(), readADC(), readAndClearInterrupt(), setClick(), setDataRate(), setPerformanceMode(), and setRange().
|
private |
Definition at line 415 of file Adafruit_LIS3DH.h.
Referenced by Adafruit_LIS3DH(), and begin().
| int16_t Adafruit_LIS3DH::x |
x axis value
Definition at line 405 of file Adafruit_LIS3DH.h.
Referenced by feedtwin.model.curve.Curve::__post_init__(), engine.pipeline.thermal.gas_side.WallContour::area_elements(), read(), feedtwin.model.curve.Curve::to_dict(), and feedtwin.model.curve.Curve::x_si().
| float Adafruit_LIS3DH::x_g |
x_g axis value (calculated by selected range)
Definition at line 409 of file Adafruit_LIS3DH.h.
Referenced by getEvent(), and read().
| int16_t Adafruit_LIS3DH::y |
y axis value
Definition at line 406 of file Adafruit_LIS3DH.h.
Referenced by engine.pipeline.thermal.wall_conduction.WallModel::__post_init__(), feedtwin.model.curve.Curve::__post_init__(), engine.pipeline.thermal.wall_conduction.WallModel::_build_grid(), engine.pipeline.thermal.wall_conduction.WallModel::_remap(), engine.pipeline.thermal.wall_conduction.WallModel::_set_capacity(), engine.pipeline.thermal.wall_conduction.WallModel::depth_of_isotherm(), engine.pipeline.thermal.wall_conduction.WallModel::interface_temperature(), read(), feedtwin.model.curve.Curve::to_dict(), and feedtwin.model.curve.Curve::y_si().
| float Adafruit_LIS3DH::y_g |
y_g axis value (calculated by selected range)
Definition at line 410 of file Adafruit_LIS3DH.h.
Referenced by getEvent(), and read().
| int16_t Adafruit_LIS3DH::z |
z axis value
Definition at line 407 of file Adafruit_LIS3DH.h.
Referenced by engine.layerx.flight.InlineAscent::_integrate(), engine.layerx.flight.InlineAscent::held(), read(), and engine.layerx.flight.InlineAscent::specific_force().
| float Adafruit_LIS3DH::z_g |
z_g axis value (calculated by selected range)
Definition at line 411 of file Adafruit_LIS3DH.h.
Referenced by getEvent(), and read().