36 #ifndef ADAFRUIT_LIS331_H 37 #define ADAFRUIT_LIS331_H 44 #include <Adafruit_BusIO_Register.h> 45 #include <Adafruit_I2CDevice.h> 46 #include <Adafruit_SPIDevice.h> 47 #include <Adafruit_Sensor.h> 49 #define LIS331_DEFAULT_ADDRESS (0x18) 50 #define LIS331_CHIP_ID \ 53 #define LIS331_REG_WHOAMI \ 55 #define LIS331_REG_CTRL1 0x20 56 #define LIS331_REG_CTRL2 0x21 57 #define LIS331_REG_CTRL3 \ 59 #define LIS331_REG_CTRL4 0x23 60 #define LIS331_REG_CTRL5 0x24 61 #define LIS331_REG_HP_FILTER_RESET 0x25 62 #define LIS331_REG_REFERENCE 0x26 63 #define LIS331_REG_STATUS 0x27 64 #define LIS331_REG_OUT_X_L 0x28 65 #define LIS331_REG_OUT_X_H 0x29 66 #define LIS331_REG_OUT_Y_L 0x2A 67 #define LIS331_REG_OUT_Y_H 0x2B 68 #define LIS331_REG_OUT_Z_L 0x2C 69 #define LIS331_REG_OUT_Z_H 0x2D 70 #define LIS331_REG_INT1CFG 0x30 71 #define LIS331_REG_INT1SRC 0x31 72 #define LIS331_REG_INT1THS 0x32 73 #define LIS331_REG_INT1DUR 0x33 74 #define LIS331_REG_INT2CFG 0x34 75 #define LIS331_REG_INT2SRC 0x35 76 #define LIS331_REG_INT2THS 0x36 77 #define LIS331_REG_INT2DUR 0x37 98 LIS331_DATARATE_POWERDOWN = 0,
99 LIS331_DATARATE_50_HZ = 0x4,
100 LIS331_DATARATE_100_HZ = 0x5,
101 LIS331_DATARATE_400_HZ = 0x6,
102 LIS331_DATARATE_1000_HZ = 0x7,
103 LIS331_DATARATE_LOWPOWER_0_5_HZ = 0x8,
104 LIS331_DATARATE_LOWPOWER_1_HZ = 0xC,
105 LIS331_DATARATE_LOWPOWER_2_HZ = 0x10,
106 LIS331_DATARATE_LOWPOWER_5_HZ = 0x14,
107 LIS331_DATARATE_LOWPOWER_10_HZ = 0x18,
122 LIS331_MODE_SHUTDOWN,
124 LIS331_MODE_LOW_POWER
135 Adafruit_LIS331(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin);
139 bool opendrain =
true);
143 bool getEvent(sensors_event_t *event);
147 bool use_reference =
false);
lis331_mode_t
Mode Options.
Definition: Adafruit_LIS331.h:121
Adafruit_SPIDevice * spi_dev
Pointer to I2C bus interface.
Definition: Adafruit_LIS331.h:169
hpf_cutoff
Definition: Adafruit_LIS331.h:80
void setDataRate(lis331_data_rate_t dataRate)
Sets the data rate for the LIS331 (affects power consumption)
Definition: Adafruit_LIS331.cpp:240
enum hpf_cutoff lis331_hpf_cutoff_t
ODR/50.
Definition: Adafruit_LIS331.h:81
int16_t x
Definition: Adafruit_LIS331.h:158
void read(void)
Reads x y z values at once.
Definition: Adafruit_LIS331.cpp:62
bool setLPFCutoff(lis331_lpf_cutoff_t cutoff)
Set the Low Pass Filter cutoff frequency. Useful for removing high frequency noise while sensing orie...
Definition: Adafruit_LIS331.cpp:317
ODR/200.
Definition: Adafruit_LIS331.h:83
lis331_data_rate_t
Definition: Adafruit_LIS331.h:97
bool getEvent(sensors_event_t *event)
Gets the most recent sensor event.
Definition: Adafruit_LIS331.cpp:339
int16_t z
Definition: Adafruit_LIS331.h:160
Adafruit_LIS331(TwoWire *Wi=&Wire)
Instantiates a new LIS331 class in I2C.
Definition: Adafruit_LIS331.cpp:15
ODR/400.
Definition: Adafruit_LIS331.h:84
lis331_data_rate_t getDataRate(void)
Gets the data rate for the LIS331 (affects power consumption)
Definition: Adafruit_LIS331.cpp:276
void setHPFReference(int8_t reference)
Set the reference value to offset measurements when using the High-pass filter.
Definition: Adafruit_LIS331.cpp:169
bool configIntDataReady(uint8_t irqnum=1, bool activelow=true, bool opendrain=true)
Setup the INT1 or INT2 pin to trigger when new data is ready.
Definition: Adafruit_LIS331.cpp:99
lis331_lpf_cutoff_t
Definition: Adafruit_LIS331.h:88
lis331_axis_t
Definition: Adafruit_LIS331.h:111
Class that stores state and functions for interacting with Adafruit_LIS331.
Definition: Adafruit_LIS331.h:131
void HPFReset(void)
Zero the measurement offsets while the high-pass filter is enabled when not using a reference...
Definition: Adafruit_LIS331.cpp:191
Adafruit_I2CDevice * i2c_dev
Pointer to I2C bus interface.
Definition: Adafruit_LIS331.h:168
int8_t getHPFReference(void)
Gets the current high-pass filter reference/offset.
Definition: Adafruit_LIS331.cpp:179
uint8_t readRange(void)
Get the measurement range.
Definition: Adafruit_LIS331.cpp:225
void getSensor(sensor_t *sensor)
Gets the sensor_t data.
Definition: Adafruit_LIS331.cpp:362
float z_g
Definition: Adafruit_LIS331.h:165
int16_t y
Definition: Adafruit_LIS331.h:159
void enableHighPassFilter(bool filter_enabled, lis331_hpf_cutoff_t cutoff=LIS331_HPF_0_0025_ODR, bool use_reference=false)
Enables the high pass filter and/or slope filter.
Definition: Adafruit_LIS331.cpp:135
lis331_mode_t getMode(void)
Return the current power mode from the current data rate.
Definition: Adafruit_LIS331.cpp:288
void writeRange(uint8_t range)
Set the measurement range for the sensor.
Definition: Adafruit_LIS331.cpp:209
virtual void _scaleValues(void)
Scale the acceleration measuremets from their raw value to milli-g depending on the current measureme...
Definition: Adafruit_LIS331.cpp:202
float x_g
Definition: Adafruit_LIS331.h:163
ODR/100.
Definition: Adafruit_LIS331.h:82
uint8_t getDeviceID(void)
Get Device ID from LIS331_REG_WHOAMI.
Definition: Adafruit_LIS331.cpp:52
float y_g
Definition: Adafruit_LIS331.h:164