Adafruit LSM303DLH Magnetometer Library
Public Member Functions | Public Attributes | List of all members
Adafruit_LSM303DLH_Mag_Unified Class Reference

Unified sensor driver for the magnetometer. More...

#include <Adafruit_LSM303DLH_Mag.h>

Inheritance diagram for Adafruit_LSM303DLH_Mag_Unified:

Public Member Functions

 Adafruit_LSM303DLH_Mag_Unified (int32_t sensorID=-1)
 Instantiates a new Adafruit_LSM303DLH_Mag_Unified class. More...
 
bool begin (uint8_t i2c_addr=_ADDRESS_MAG, TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
void enableAutoRange (bool enable)
 Enables or disables auto-ranging. More...
 
void setMagGain (lsm303MagGain gain)
 Sets the magnetometer's gain. More...
 
void setMagRate (lsm303MagRate 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.
 

Public Attributes

lsm303MagData raw
 Last read magnetometer data will be available here.
 
lsm303MagGain magGain
 The current magnetometer gain.
 
bool autoRangeEnabled
 True if auto ranging is enabled.
 

Detailed Description

Unified sensor driver for the magnetometer.

Constructor & Destructor Documentation

◆ Adafruit_LSM303DLH_Mag_Unified()

Adafruit_LSM303DLH_Mag_Unified::Adafruit_LSM303DLH_Mag_Unified ( int32_t  sensorID = -1)

Instantiates a new Adafruit_LSM303DLH_Mag_Unified class.

Parameters
sensorIDan optional identifier for the sensor instance

Member Function Documentation

◆ begin()

bool Adafruit_LSM303DLH_Mag_Unified::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.

◆ enableAutoRange()

void Adafruit_LSM303DLH_Mag_Unified::enableAutoRange ( bool  enabled)

Enables or disables auto-ranging.

Parameters
enabledTrue to enable auto-ranging, false to disable

◆ setMagGain()

void Adafruit_LSM303DLH_Mag_Unified::setMagGain ( lsm303MagGain  gain)

Sets the magnetometer's gain.

Parameters
gaina lsm303MagGain specifying the new gain

◆ setMagRate()

void Adafruit_LSM303DLH_Mag_Unified::setMagRate ( lsm303MagRate  rate)

Sets the magnetometer's update rate.

Parameters
rateA lsm303MagRate specifying the new rate

◆ getEvent()

bool Adafruit_LSM303DLH_Mag_Unified::getEvent ( sensors_event_t *  event)

Gets the most recent sensor event.

Parameters
eventA sensors_event_t to store the event data
Returns
True on successful read

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