Adafruit LIS3DH
|
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. More... | |
Adafruit_LIS3DH (int8_t cspin, SPIClass *theSPI=&SPI, uint32_t frequency=LIS3DH_DEFAULT_SPIFREQ) | |
Instantiates a new LIS3DH class using hardware SPI. More... | |
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. More... | |
bool | begin (uint8_t addr=LIS3DH_DEFAULT_ADDRESS, uint8_t nWAI=0x33) |
Setups the HW (reads coefficients values, etc.) More... | |
uint8_t | getDeviceID (void) |
Get Device ID from LIS3DH_REG_WHOAMI. More... | |
bool | haveNewData (void) |
Check to see if new data available. More... | |
bool | enableDRDY (bool enable_drdy=true, uint8_t int_pin=1) |
Enable or disable the Data Ready interupt. More... | |
void | read (void) |
Reads x y z values at once. | |
int16_t | readADC (uint8_t a) |
Read the auxilary ADC. More... | |
lis3dh_mode_t | getPerformanceMode (void) |
Gets the performance mode for the LIS3DH. More... | |
void | setPerformanceMode (lis3dh_mode_t mode) |
Sets the performance mode for the LIS3DH. More... | |
void | setRange (lis3dh_range_t range) |
Sets the g range for the accelerometer. More... | |
lis3dh_range_t | getRange (void) |
Gets the g range for the accelerometer. More... | |
void | setDataRate (lis3dh_dataRate_t dataRate) |
Sets the data rate for the LIS3DH (controls power consumption) More... | |
lis3dh_dataRate_t | getDataRate (void) |
Gets the data rate for the LIS3DH (controls power consumption) More... | |
bool | getEvent (sensors_event_t *event) |
Gets the most recent sensor event. More... | |
void | getSensor (sensor_t *sensor) |
Gets the sensor_t data. More... | |
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. More... | |
uint8_t | getClick (void) |
Get uint8_t for single or double click. More... | |
uint8_t | readAndClearInterrupt (void) |
Get uint8_t for INT1 source and clear interrupt. More... | |
Public Attributes | |
int16_t | x |
int16_t | y |
int16_t | z |
float | x_g |
float | y_g |
float | z_g |
Class that stores state and functions for interacting with Adafruit_LIS3DH.
Adafruit_LIS3DH::Adafruit_LIS3DH | ( | TwoWire * | Wi = &Wire | ) |
Instantiates a new LIS3DH class in I2C.
Wi | optional wire object |
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 |
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 |
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) |
uint8_t Adafruit_LIS3DH::getDeviceID | ( | void | ) |
Get Device ID from LIS3DH_REG_WHOAMI.
bool Adafruit_LIS3DH::haveNewData | ( | void | ) |
Check to see if new data available.
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 |
int16_t Adafruit_LIS3DH::readADC | ( | uint8_t | adc | ) |
Read the auxilary ADC.
adc | adc index. possible values (1, 2, 3). |
lis3dh_mode_t Adafruit_LIS3DH::getPerformanceMode | ( | void | ) |
Gets the performance mode for the LIS3DH.
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 |
void Adafruit_LIS3DH::setRange | ( | lis3dh_range_t | range | ) |
Sets the g range for the accelerometer.
range | range value |
lis3dh_range_t Adafruit_LIS3DH::getRange | ( | void | ) |
Gets the g range for the accelerometer.
void Adafruit_LIS3DH::setDataRate | ( | lis3dh_dataRate_t | dataRate | ) |
Sets the data rate for the LIS3DH (controls power consumption)
dataRate | data rate value |
lis3dh_dataRate_t Adafruit_LIS3DH::getDataRate | ( | void | ) |
Gets the data rate for the LIS3DH (controls power consumption)
bool Adafruit_LIS3DH::getEvent | ( | sensors_event_t * | event | ) |
Gets the most recent sensor event.
*event | sensor event that we want to read |
void Adafruit_LIS3DH::getSensor | ( | sensor_t * | sensor | ) |
Gets the sensor_t data.
*sensor | sensor that we want to write data into |
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) |
uint8_t Adafruit_LIS3DH::getClick | ( | void | ) |
Get uint8_t for single or double click.
uint8_t Adafruit_LIS3DH::readAndClearInterrupt | ( | void | ) |
Get uint8_t for INT1 source and clear interrupt.
int16_t Adafruit_LIS3DH::x |
x axis value
int16_t Adafruit_LIS3DH::y |
y axis value
int16_t Adafruit_LIS3DH::z |
z axis value
float Adafruit_LIS3DH::x_g |
x_g axis value (calculated by selected range)
float Adafruit_LIS3DH::y_g |
y_g axis value (calculated by selected range)
float Adafruit_LIS3DH::z_g |
z_g axis value (calculated by selected range)