Adafruit MMA8451 Library
Public Member Functions | Protected Member Functions | List of all members
Adafruit_MMA8451 Class Reference

Adafruit MMA8451 compount. More...

#include <Adafruit_MMA8451.h>

Inheritance diagram for Adafruit_MMA8451:

Public Member Functions

 Adafruit_MMA8451 (int32_t id=-1)
 Adafruit MMA8451 object. More...
 
bool begin (uint8_t addr=MMA8451_DEFAULT_ADDRESS, TwoWire *theWire=&Wire)
 Connects with the MMA8451. More...
 
void read ()
 Reads data from the sensor.
 
void setRange (mma8451_range_t range)
 Sets the g range for the accelerometer. More...
 
mma8451_range_t getRange (void)
 Gets the g range for the accelerometer. More...
 
void setDataRate (mma8451_dataRate_t dataRate)
 Sets the data rate for the MMA8451 (controls power consumption) More...
 
mma8451_dataRate_t getDataRate (void)
 Gets the data rate for the MMA8451 (controls power consumption) More...
 
bool getEvent (sensors_event_t *event)
 Gets the most recent sensor event. More...
 
void getSensor (sensor_t *sensor)
 Gets the sensor_t data. More...
 
uint8_t getOrientation (void)
 Read the orientation: Portrait/Landscape + Up/Down/Left/Right + Front/Back. More...
 
void writeRegister8 (uint8_t reg, uint8_t value)
 Writes to 8 bit register. More...
 

Public Attributes

int16_t x
 
int16_t y
 
int16_t z
 
float x_g
 
float y_g
 
float z_g
 

Protected Member Functions

uint8_t readRegister8 (uint8_t reg)
 Reads from 8 bit register. More...
 

Detailed Description

Adafruit MMA8451 compount.

Constructor & Destructor Documentation

◆ Adafruit_MMA8451()

Adafruit_MMA8451::Adafruit_MMA8451 ( int32_t  id = -1)

Adafruit MMA8451 object.

Instantiates a new MMA8451 class in I2C mode.

Parameters
idMMA8451 ID

Member Function Documentation

◆ begin()

bool Adafruit_MMA8451::begin ( uint8_t  addr = MMA8451_DEFAULT_ADDRESS,
TwoWire *  theWire = &Wire 
)

Connects with the MMA8451.

Setups the HW (reads coefficients values, etc.)

Parameters
addrAddress of the MMA8451
theWireTwoWire bus to use
Returns
Returns a boolean

◆ setRange()

void Adafruit_MMA8451::setRange ( mma8451_range_t  range)

Sets the g range for the accelerometer.

Parameters
rangeDesired range of sensor

◆ getRange()

mma8451_range_t Adafruit_MMA8451::getRange ( void  )

Gets the g range for the accelerometer.

Returns
Range of sensor, either 0b10, 0b01, or 0b00, 8G, 4G, and 2G respectively

◆ setDataRate()

void Adafruit_MMA8451::setDataRate ( mma8451_dataRate_t  dataRate)

Sets the data rate for the MMA8451 (controls power consumption)

Parameters
dataRateData rate of the sensor

◆ getDataRate()

mma8451_dataRate_t Adafruit_MMA8451::getDataRate ( void  )

Gets the data rate for the MMA8451 (controls power consumption)

Returns
Data rate, binary value

◆ getEvent()

bool Adafruit_MMA8451::getEvent ( sensors_event_t *  event)

Gets the most recent sensor event.

Parameters
*eventEvent
Returns
Returns a boolean

◆ getSensor()

void Adafruit_MMA8451::getSensor ( sensor_t *  sensor)

Gets the sensor_t data.

Parameters
*sensorSensor

◆ getOrientation()

uint8_t Adafruit_MMA8451::getOrientation ( void  )

Read the orientation: Portrait/Landscape + Up/Down/Left/Right + Front/Back.

Returns
3 axis tuple

◆ writeRegister8()

void Adafruit_MMA8451::writeRegister8 ( uint8_t  reg,
uint8_t  value 
)

Writes to 8 bit register.

Writes 8-bits to the specified destination register.

Parameters
regRegister to write to
valueValue to write

◆ readRegister8()

uint8_t Adafruit_MMA8451::readRegister8 ( uint8_t  reg)
protected

Reads from 8 bit register.

Reads 8-bits from the specified register.

Parameters
regRegister
Returns
Returns the contents of Register8

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