Adafruit FXOS8700 Accelerometer Magnetometer Library
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Adafruit_FXOS8700 Class Reference

Unified sensor driver for the Adafruit FXOS8700 breakout. More...

#include <Adafruit_FXOS8700.h>

Inheritance diagram for Adafruit_FXOS8700:

Public Member Functions

 Adafruit_FXOS8700 (int32_t accelSensorID=-1, int32_t magSensorID=-1)
 Instantiates a new Adafruit_FXOS8700 class, including assigning a unique ID to the accel and magnetometer for logging purposes. More...
 
bool begin (uint8_t addr=0x1F, TwoWire *wire=&Wire)
 Initializes the hardware. More...
 
bool getEvent (sensors_event_t *accel)
 Reads a single sensor event from the accelerometer. More...
 
void getSensor (sensor_t *singleSensorEvent)
 Gets sensor details about the accelerometer. More...
 
bool getEvent (sensors_event_t *accel, sensors_event_t *mag)
 Gets the most recent sensor events. More...
 
void getSensor (sensor_t *accel, sensor_t *mag)
 Gets sensor_t data for both the accel and mag in one operation. More...
 
void standby (boolean standby)
 Puts device into/out of standby mode. More...
 
Adafruit_Sensor * getMagnetometerSensor (void)
 Gets an Adafruit Unified Sensor object for the mag sensor component. More...
 
Adafruit_Sensor * getAccelerometerSensor (void)
 Gets an Adafruit Unified Sensor object for the accelerometer sensor component. More...
 
void setSensorMode (fxos8700SensorMode_t mode)
 Set the sensor mode to hybrid, or accel/mag-only modes. More...
 
fxos8700SensorMode_t getSensorMode ()
 Get the sensor mode (either hybrid, or accel/mag-only). More...
 
void setAccelRange (fxos8700AccelRange_t range)
 Set the accelerometer full scale range. More...
 
fxos8700AccelRange_t getAccelRange ()
 Get the accelerometer full scale range. More...
 
void setOutputDataRate (fxos8700ODR_t rate)
 Set the FXOS8700's ODR from any sensor mode. More...
 
fxos8700ODR_t getOutputDataRate ()
 Get the FXOS8700's Hybrid ODR. More...
 
void setMagOversamplingRatio (fxos8700MagOSR_t ratio)
 Set the magnetometer oversampling ratio (OSR) More...
 
fxos8700MagOSR_t getMagOversamplingRatio ()
 Get the magnetometer oversampling ratio (OSR). More...
 

Public Attributes

fxos8700RawData_t accel_raw
 
fxos8700RawData_t mag_raw
 
Adafruit_FXOS8700_Accelerometeraccel_sensor
 Accelerometer data object. More...
 
Adafruit_FXOS8700_Magnetometermag_sensor = NULL
 Mag data object.
 

Protected Attributes

Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 

Detailed Description

Unified sensor driver for the Adafruit FXOS8700 breakout.

Constructor & Destructor Documentation

◆ Adafruit_FXOS8700()

Adafruit_FXOS8700::Adafruit_FXOS8700 ( int32_t  accelSensorID = -1,
int32_t  magSensorID = -1 
)

Instantiates a new Adafruit_FXOS8700 class, including assigning a unique ID to the accel and magnetometer for logging purposes.

Parameters
accelSensorIDThe unique ID to associate with the accelerometer.
magSensorIDThe unique ID to associate with the magnetometer.

Member Function Documentation

◆ begin()

bool Adafruit_FXOS8700::begin ( uint8_t  addr = 0x1F,
TwoWire *  wire = &Wire 
)

Initializes the hardware.

Parameters
addrI2C address for the device.
wirePointer to Wire instance
Returns
True if the device was successfully initialized, otherwise false.

◆ getEvent() [1/2]

bool Adafruit_FXOS8700::getEvent ( sensors_event_t *  singleSensorEvent)

Reads a single sensor event from the accelerometer.

Attention

This function exists to keep Adafruit_Sensor happy since we need a single sensor in the canonical .getEvent call. The non-standard .getEvent call with two parameters should generally be used with this sensor.

Parameters
singleSensorEventA reference to the sensors_event_t instances where the accelerometer or magnetometer data should be written.
Returns
True if the event read was successful, otherwise false.

◆ getSensor() [1/2]

void Adafruit_FXOS8700::getSensor ( sensor_t *  accelSensor)

Gets sensor details about the accelerometer.

Attention

This function exists to keep Adafruit_Sensor happy since we need a single sensor in the canonical .getSensor call. The non-standard .getSensor call with two parameters should generally be used with this sensor.

Parameters
accelSensorA reference to the sensor_t instances where the accelerometer sensor info should be written.

◆ getEvent() [2/2]

bool Adafruit_FXOS8700::getEvent ( sensors_event_t *  accelEvent,
sensors_event_t *  magEvent 
)

Gets the most recent sensor events.

This function reads from both the accelerometer and the magnetometer in one call, and is a deviation from the standard Adafruit_Sensor API, but is provided as a convenience since most AHRS algorithms require sensor samples to be as close in time as possible.

Parameters
accelEventA reference to the sensors_event_t instances where the accelerometer data should be written.
magEventA reference to the sensors_event_t instances where the magnetometer data should be written.
Returns
True if the event read was successful, otherwise false.

◆ getSensor() [2/2]

void Adafruit_FXOS8700::getSensor ( sensor_t *  accelSensor,
sensor_t *  magSensor 
)

Gets sensor_t data for both the accel and mag in one operation.

Parameters
accelSensorA reference to the sensor_t instances where the accelerometer sensor info should be written.
magSensorA reference to the sensor_t instances where the magnetometer sensor info should be written.

◆ standby()

void Adafruit_FXOS8700::standby ( boolean  standby)

Puts device into/out of standby mode.

Parameters
standbySet this to a non-zero value to enter standy mode.

◆ getMagnetometerSensor()

Adafruit_Sensor * Adafruit_FXOS8700::getMagnetometerSensor ( void  )

Gets an Adafruit Unified Sensor object for the mag sensor component.

Returns
Adafruit_Sensor pointer to mag sensor

◆ getAccelerometerSensor()

Adafruit_Sensor * Adafruit_FXOS8700::getAccelerometerSensor ( void  )

Gets an Adafruit Unified Sensor object for the accelerometer sensor component.

Returns
Adafruit_Sensor pointer to accelerometer sensor

◆ setSensorMode()

void Adafruit_FXOS8700::setSensorMode ( fxos8700SensorMode_t  mode)

Set the sensor mode to hybrid, or accel/mag-only modes.

Parameters
modeThe sensor mode to set.

◆ getSensorMode()

fxos8700SensorMode_t Adafruit_FXOS8700::getSensorMode ( )

Get the sensor mode (either hybrid, or accel/mag-only).

Returns
The sensor mode.

◆ setAccelRange()

void Adafruit_FXOS8700::setAccelRange ( fxos8700AccelRange_t  range)

Set the accelerometer full scale range.

Attention

This function resets the lnoise bit to low if a 8G accelerometer range is requested. Otherwise, the active lnoise bit won't allow the sensor to measure past 4G.

Parameters
rangeThe accelerometer full scale range to set.

◆ getAccelRange()

fxos8700AccelRange_t Adafruit_FXOS8700::getAccelRange ( )

Get the accelerometer full scale range.

Returns
The accelerometer full scale range.

◆ setOutputDataRate()

void Adafruit_FXOS8700::setOutputDataRate ( fxos8700ODR_t  rate)

Set the FXOS8700's ODR from any sensor mode.

Parameters
rateThe FXOS8700's ODR.

◆ getOutputDataRate()

fxos8700ODR_t Adafruit_FXOS8700::getOutputDataRate ( )

Get the FXOS8700's Hybrid ODR.

Returns
The FXOS8700's Hybrid ODR.

◆ setMagOversamplingRatio()

void Adafruit_FXOS8700::setMagOversamplingRatio ( fxos8700MagOSR_t  ratio)

Set the magnetometer oversampling ratio (OSR)

Parameters
ratioThe magnetometer OSR to set.

◆ getMagOversamplingRatio()

fxos8700MagOSR_t Adafruit_FXOS8700::getMagOversamplingRatio ( )

Get the magnetometer oversampling ratio (OSR).

Returns
The magnetometer OSR.

Member Data Documentation

◆ accel_raw

fxos8700RawData_t Adafruit_FXOS8700::accel_raw

Raw accelerometer values from last sucsessful sensor read

◆ mag_raw

fxos8700RawData_t Adafruit_FXOS8700::mag_raw

Raw magnetometer values from last successful sensor read

◆ accel_sensor

Adafruit_FXOS8700_Accelerometer* Adafruit_FXOS8700::accel_sensor
Initial value:
=
NULL

Accelerometer data object.


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