Adafruit LIS2MDL Magnetometer Library
Public Member Functions | Public Attributes | List of all members
Adafruit_LIS2MDL Class Reference

Unified sensor driver for the magnetometer. More...

#include <Adafruit_LIS2MDL.h>

Inheritance diagram for Adafruit_LIS2MDL:

Public Member Functions

 Adafruit_LIS2MDL (int32_t sensorID=-1)
 Instantiates a new Adafruit_LIS2MDL class. More...
 
bool begin (uint8_t i2c_addr=_ADDRESS_MAG, TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
bool begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI)
 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)
 Sets up the hardware and initializes software SPI. More...
 
lis2mdl_rate_t getDataRate ()
 Gets the magnetometer's update rate. More...
 
void setDataRate (lis2mdl_rate_t rate)
 Sets the magnetometer's update rate. More...
 
bool getEvent (sensors_event_t *)
 Gets the most recent sensor event. More...
 
void getSensor (sensor_t *)
 Gets the sensor_t data.
 
void reset (void)
 Resets the sensor to an initial state.
 
void enableInterrupts (bool)
 Enable interrupts. More...
 
void interruptsActiveHigh (bool)
 Sets the polarity of the interrupt pin. More...
 

Public Attributes

lis2mdl_data_t raw
 struct instance to hold raw data
 

Detailed Description

Unified sensor driver for the magnetometer.

Constructor & Destructor Documentation

◆ Adafruit_LIS2MDL()

Adafruit_LIS2MDL::Adafruit_LIS2MDL ( int32_t  sensorID = -1)

Instantiates a new Adafruit_LIS2MDL class.

Parameters
sensorIDan option ID to differentiate the sensor from others

Member Function Documentation

◆ begin()

bool Adafruit_LIS2MDL::begin ( uint8_t  i2c_address = _ADDRESS_MAG,
TwoWire *  wire = &Wire 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [1/2]

boolean Adafruit_LIS2MDL::begin_SPI ( uint8_t  cs_pin,
SPIClass *  theSPI = &SPI 
)

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.
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [2/2]

bool Adafruit_LIS2MDL::begin_SPI ( int8_t  cs_pin,
int8_t  sck_pin,
int8_t  miso_pin,
int8_t  mosi_pin 
)

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
Returns
True if initialization was successful, otherwise false.

◆ getDataRate()

lis2mdl_rate_t Adafruit_LIS2MDL::getDataRate ( void  )

Gets the magnetometer's update rate.

Returns
The current data rate as a lis2mdl_rate_t

◆ setDataRate()

void Adafruit_LIS2MDL::setDataRate ( lis2mdl_rate_t  rate)

Sets the magnetometer's update rate.

Parameters
rateThe new lis2mdl_rate_t to set

◆ getEvent()

bool Adafruit_LIS2MDL::getEvent ( sensors_event_t *  event)

Gets the most recent sensor event.

Parameters
eventThe sensors_event_t to fill with event data
Returns
true, always

◆ enableInterrupts()

void Adafruit_LIS2MDL::enableInterrupts ( bool  enable)

Enable interrupts.

Parameters
enableSet to True to enable interrupts, set to False to disable

◆ interruptsActiveHigh()

void Adafruit_LIS2MDL::interruptsActiveHigh ( bool  active_high)

Sets the polarity of the interrupt pin.

Parameters
active_highSet to true to make the int pin active high, false to set as active low

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