Adafruit LIS331 Arduino Driver
Public Member Functions | List of all members
Adafruit_LIS331HH Class Reference

Class that stores state and functions for interacting with Adafruit_LIS331HH. More...

#include <Adafruit_LIS331HH.h>

Inheritance diagram for Adafruit_LIS331HH:
Adafruit_LIS331

Public Member Functions

 Adafruit_LIS331HH ()
 Instantiates a new H3LIS331 class in I2C.
 
bool begin_I2C (uint8_t i2c_addr=LIS331_DEFAULT_ADDRESS, 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 sensor_id=0)
 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 sensor_id=0)
 Sets up the hardware and initializes software SPI. More...
 
void setRange (lis331hh_range_t range)
 Sets the measurement range for the H3LIS331. More...
 
lis331hh_range_t getRange (void)
 Gets the measurement range for the H3LIS331. More...
 
- Public Member Functions inherited from Adafruit_LIS331
 Adafruit_LIS331 (TwoWire *Wi=&Wire)
 Instantiates a new LIS331 class in I2C. More...
 
 Adafruit_LIS331 (int8_t cspin, SPIClass *theSPI=&SPI)
 Instantiates a new LIS331 class using hardware SPI. More...
 
 Adafruit_LIS331 (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 Instantiates a new LIS331 class using software SPI. More...
 
uint8_t getDeviceID (void)
 Get Device ID from LIS331_REG_WHOAMI. More...
 
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. More...
 
void read (void)
 Reads x y z values at once.
 
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 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. More...
 
void setHPFReference (int8_t reference)
 Set the reference value to offset measurements when using the High-pass filter. More...
 
int8_t getHPFReference (void)
 Gets the current high-pass filter reference/offset. More...
 
void HPFReset (void)
 Zero the measurement offsets while the high-pass filter is enabled when not using a reference. More...
 
bool setLPFCutoff (lis331_lpf_cutoff_t cutoff)
 Set the Low Pass Filter cutoff frequency. Useful for removing high frequency noise while sensing orientation using the acceleration from gravity. More...
 
void setDataRate (lis331_data_rate_t dataRate)
 Sets the data rate for the LIS331 (affects power consumption) More...
 
lis331_data_rate_t getDataRate (void)
 Gets the data rate for the LIS331 (affects power consumption) More...
 
lis331_mode_t getMode (void)
 Return the current power mode from the current data rate. More...
 
lis331_mode_t getMode (lis331_data_rate_t rate)
 Return the current power mode from a given data rate value. More...
 

Additional Inherited Members

- Public Attributes inherited from Adafruit_LIS331
int16_t x
 
int16_t y
 
int16_t z
 
- Protected Member Functions inherited from Adafruit_LIS331
void writeRange (uint8_t range)
 Set the measurement range for the sensor. More...
 
uint8_t readRange (void)
 Get the measurement range. More...
 
- Protected Attributes inherited from Adafruit_LIS331
float x_g
 
float y_g
 
float z_g
 
Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 
Adafruit_SPIDevice * spi_dev = NULL
 Pointer to I2C bus interface.
 

Detailed Description

Class that stores state and functions for interacting with Adafruit_LIS331HH.

Member Function Documentation

◆ begin_I2C()

bool Adafruit_LIS331HH::begin_I2C ( uint8_t  i2c_address = LIS331_DEFAULT_ADDRESS,
TwoWire *  wire = &Wire,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [1/2]

bool Adafruit_LIS331HH::begin_SPI ( uint8_t  cs_pin,
SPIClass *  theSPI = &SPI,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes hardware SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
theSPIThe SPI object to be used for SPI connections.
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [2/2]

bool Adafruit_LIS331HH::begin_SPI ( int8_t  cs_pin,
int8_t  sck_pin,
int8_t  miso_pin,
int8_t  mosi_pin,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes software SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
sck_pinThe arduino pin # connected to SPI clock
miso_pinThe arduino pin # connected to SPI MISO
mosi_pinThe arduino pin # connected to SPI MOSI
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ setRange()

void Adafruit_LIS331HH::setRange ( lis331hh_range_t  range)

Sets the measurement range for the H3LIS331.

Parameters
rangeThe range to set

◆ getRange()

lis331hh_range_t Adafruit_LIS331HH::getRange ( void  )

Gets the measurement range for the H3LIS331.

Returns
The range value

The documentation for this class was generated from the following files: