27#ifndef ADAFRUIT_LIS3DH_H
28#define ADAFRUIT_LIS3DH_H
35#include <Adafruit_BusIO_Register.h>
36#include <Adafruit_I2CDevice.h>
37#include <Adafruit_SPIDevice.h>
38#include <Adafruit_Sensor.h>
41#define LIS3DH_DEFAULT_ADDRESS (0x18)
62#define LIS3DH_REG_STATUS1 0x07
63#define LIS3DH_REG_OUTADC1_L 0x08
64#define LIS3DH_REG_OUTADC1_H 0x09
65#define LIS3DH_REG_OUTADC2_L 0x0A
66#define LIS3DH_REG_OUTADC2_H 0x0B
67#define LIS3DH_REG_OUTADC3_L 0x0C
68#define LIS3DH_REG_OUTADC3_H 0x0D
69#define LIS3DH_REG_INTCOUNT \
71#define LIS3DH_REG_WHOAMI \
81#define LIS3DH_REG_TEMPCFG 0x1F
93#define LIS3DH_REG_CTRL1 0x20
108#define LIS3DH_REG_CTRL2 0x21
127#define LIS3DH_REG_CTRL3 0x22
144#define LIS3DH_REG_CTRL4 0x23
157#define LIS3DH_REG_CTRL5 0x24
163#define LIS3DH_REG_CTRL6 0x25
164#define LIS3DH_REG_REFERENCE 0x26
184#define LIS3DH_REG_STATUS2 0x27
185#define LIS3DH_REG_OUT_X_L 0x28
186#define LIS3DH_REG_OUT_X_H 0x29
187#define LIS3DH_REG_OUT_Y_L 0x2A
188#define LIS3DH_REG_OUT_Y_H 0x2B
189#define LIS3DH_REG_OUT_Z_L 0x2C
190#define LIS3DH_REG_OUT_Z_H 0x2D
200#define LIS3DH_REG_FIFOCTRL 0x2E
201#define LIS3DH_REG_FIFOSRC \
224#define LIS3DH_REG_INT1CFG 0x30
243#define LIS3DH_REG_INT1SRC 0x31
244#define LIS3DH_REG_INT1THS \
246#define LIS3DH_REG_INT1DUR \
268#define LIS3DH_REG_CLICKCFG 0x38
286#define LIS3DH_REG_CLICKSRC 0x39
292#define LIS3DH_REG_CLICKTHS 0x3A
298#define LIS3DH_REG_TIMELIMIT 0x3B
304#define LIS3DH_REG_TIMELATENCY 0x3C
310#define LIS3DH_REG_TIMEWINDOW 0x3D
312#define LIS3DH_LSB16_TO_KILO_LSB10 \
315#define LIS3DH_LSB16_TO_KILO_LSB12 \
318#define LIS3DH_LSB16_TO_KILO_LSB8 \
322#define LIS3DH_DEFAULT_SPIFREQ 500000
373 Adafruit_LIS3DH(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin,
380 bool enableDRDY(
bool enable_drdy =
true, uint8_t int_pin = 1);
394 bool getEvent(sensors_event_t *event);
397 void setClick(uint8_t c, uint8_t clickthresh, uint8_t timelimit = 10,
398 uint8_t timelatency = 20, uint8_t timewindow = 255);
lis3dh_range_t
A structure to represent scales.
lis3dh_dataRate_t
Data rate selection Used with register 0x2A (LIS3DH_REG_CTRL_REG1) to set bandwidth.
@ LIS3DH_DATARATE_LOWPOWER_5KHZ
@ LIS3DH_DATARATE_LOWPOWER_1K6HZ
@ LIS3DH_DATARATE_POWERDOWN
lis3dh_axis_t
A structure to represent axes.
#define LIS3DH_DEFAULT_SPIFREQ
SPI frequency for LIS3DH.
#define LIS3DH_DEFAULT_ADDRESS
I2C ADDRESS/BITS.
lis3dh_mode_t
Operational / performance modes.
@ LIS3DH_MODE_HIGH_RESOLUTION
float z_g
z_g axis value (calculated by selected range)
lis3dh_mode_t getPerformanceMode(void)
Gets the performance mode for the LIS3DH.
Adafruit_LIS3DH(TwoWire *Wi=&Wire)
Instantiates a new LIS3DH class in I2C.
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 setPerformanceMode(lis3dh_mode_t mode)
Sets the performance mode for the LIS3DH.
Adafruit_SPIDevice * spi_dev
Pointer to SPI bus interface.
void read(void)
Reads x y z values at once.
Adafruit_I2CDevice * i2c_dev
Pointer to I2C bus interface.
float x_g
x_g axis value (calculated by selected range)
lis3dh_range_t getRange(void)
Gets the g range for the accelerometer.
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.
uint8_t getDeviceID(void)
Get Device ID from LIS3DH_REG_WHOAMI.
int16_t readADC(uint8_t a)
Read the auxilary ADC.
void setRange(lis3dh_range_t range)
Sets the g range for the accelerometer.
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 setDataRate(lis3dh_dataRate_t dataRate)
Sets the data rate for the LIS3DH (controls power consumption).
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.
float y_g
y_g axis value (calculated by selected range)
*brief append another JSON pointer at the end of this JSON pointer *sa ptr reference_tokens begin()
*brief create JSON pointer *sa reference_tokens const string_t & a