Adafruit ADXL343 Library
Public Member Functions | List of all members
Adafruit_ADXL343 Class Reference

#include <Adafruit_ADXL343.h>

Inheritance diagram for Adafruit_ADXL343:

Public Member Functions

 Adafruit_ADXL343 (int32_t sensorID)
 Instantiates a new ADXL343 class. More...
 
 Adafruit_ADXL343 (int32_t sensorID, TwoWire *wireBus)
 Instantiates a new ADXL343 class. More...
 
 Adafruit_ADXL343 (uint8_t clock, uint8_t miso, uint8_t mosi, uint8_t cs, int32_t sensorID=-1)
 Instantiates a new ADXL343 class in SPI mode. More...
 
bool begin (uint8_t i2caddr=ADXL343_ADDRESS)
 Setups the HW (reads coefficients values, etc.) More...
 
void setRange (range_t range)
 Sets the g range for the accelerometer. More...
 
range_t getRange (void)
 Sets the g range for the accelerometer. More...
 
void setDataRate (dataRate_t dataRate)
 Sets the data rate for the ADXL343 (controls power consumption) More...
 
dataRate_t getDataRate (void)
 Sets the data rate for the ADXL343 (controls power consumption) More...
 
bool getEvent (sensors_event_t *)
 Gets the most recent sensor event. More...
 
void getSensor (sensor_t *)
 Gets the sensor_t data. More...
 
uint8_t getDeviceID (void)
 Read the device ID (can be used to check connection) More...
 
void writeRegister (uint8_t reg, uint8_t value)
 Writes 8-bits to the specified destination register. More...
 
uint8_t readRegister (uint8_t reg)
 Reads 8-bits from the specified register. More...
 
int16_t read16 (uint8_t reg)
 Reads 16-bits from the specified register. More...
 
bool enableInterrupts (int_config cfg)
 Enables (1) or disables (0) the interrupts on the specified interrupt pin. More...
 
bool mapInterrupts (int_config cfg)
 'Maps' the specific interrupt to either pin INT1 (bit=0), of pin INT2 (bit=1). More...
 
uint8_t checkInterrupts (void)
 Reads the status of the interrupt pins. Reading this register also clears or deasserts any currently active interrupt. More...
 
int16_t getX (void)
 Gets the most recent X axis value. More...
 
int16_t getY (void)
 Gets the most recent Y axis value. More...
 
int16_t getZ (void)
 Gets the most recent Z axis value. More...
 

Detailed Description

Driver for the Adafruit ADXL343 breakout.

Constructor & Destructor Documentation

◆ Adafruit_ADXL343() [1/3]

Adafruit_ADXL343::Adafruit_ADXL343 ( int32_t  sensorID)

Instantiates a new ADXL343 class.

Parameters
sensorIDAn optional ID # so you can track this sensor, it will tag sensorEvents you create.

◆ Adafruit_ADXL343() [2/3]

Adafruit_ADXL343::Adafruit_ADXL343 ( int32_t  sensorID,
TwoWire *  wireBus 
)

Instantiates a new ADXL343 class.

Parameters
sensorIDAn optional ID # so you can track this sensor, it will tag sensorEvents you create.
wireBusTwoWire instance to use for I2C communication.

◆ Adafruit_ADXL343() [3/3]

Adafruit_ADXL343::Adafruit_ADXL343 ( uint8_t  clock,
uint8_t  miso,
uint8_t  mosi,
uint8_t  cs,
int32_t  sensorID = -1 
)

Instantiates a new ADXL343 class in SPI mode.

Parameters
clockThe SCK pin
misoThe MISO pin
mosiThe MOSI pin
csThe CS/SSEL pin
sensorIDAn optional ID # so you can track this sensor, it will tag sensoorEvents you create.

Member Function Documentation

◆ begin()

bool Adafruit_ADXL343::begin ( uint8_t  i2caddr = ADXL343_ADDRESS)

Setups the HW (reads coefficients values, etc.)

Parameters
i2caddrThe 7-bit I2C address to find the ADXL on
Returns
True if the sensor was successfully initialised.

◆ setRange()

void Adafruit_ADXL343::setRange ( range_t  range)

Sets the g range for the accelerometer.

Parameters
rangeThe range to set, based on range_t

◆ getRange()

range_t Adafruit_ADXL343::getRange ( void  )

Sets the g range for the accelerometer.

Returns
The range_t value corresponding to the sensors range

◆ setDataRate()

void Adafruit_ADXL343::setDataRate ( dataRate_t  dataRate)

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

Parameters
dataRateThe data rate to set, based on dataRate_t

◆ getDataRate()

dataRate_t Adafruit_ADXL343::getDataRate ( void  )

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

Returns
The current data rate, based on dataRate_t

◆ getEvent()

bool Adafruit_ADXL343::getEvent ( sensors_event_t *  event)

Gets the most recent sensor event.

Parameters
eventPointer to the sensors_event_t placeholder
Returns
True of the read request was successful.

◆ getSensor()

void Adafruit_ADXL343::getSensor ( sensor_t *  sensor)

Gets the sensor_t data.

Parameters
sensorPointer to the sensor_t placeholder.

◆ getDeviceID()

uint8_t Adafruit_ADXL343::getDeviceID ( void  )

Read the device ID (can be used to check connection)

Returns
The 8-bit device ID

◆ writeRegister()

void Adafruit_ADXL343::writeRegister ( uint8_t  reg,
uint8_t  value 
)

Writes 8-bits to the specified destination register.

Parameters
regThe register to write to
valueThe value to write to the register

◆ readRegister()

uint8_t Adafruit_ADXL343::readRegister ( uint8_t  reg)

Reads 8-bits from the specified register.

Parameters
regregister to read
Returns
The results of the register read request

◆ read16()

int16_t Adafruit_ADXL343::read16 ( uint8_t  reg)

Reads 16-bits from the specified register.

Parameters
regThe register to read two bytes from
Returns
The 16-bit value read from the reg starting address

◆ enableInterrupts()

bool Adafruit_ADXL343::enableInterrupts ( int_config  cfg)

Enables (1) or disables (0) the interrupts on the specified interrupt pin.

Parameters
cfgThe bitfield of the interrupts to enable or disable.
Returns
True if the operation was successful, otherwise false.

◆ mapInterrupts()

bool Adafruit_ADXL343::mapInterrupts ( int_config  cfg)

'Maps' the specific interrupt to either pin INT1 (bit=0), of pin INT2 (bit=1).

Parameters
cfgThe bitfield of the interrupts to enable or disable.
Returns
True if the operation was successful, otherwise false.

◆ checkInterrupts()

uint8_t Adafruit_ADXL343::checkInterrupts ( void  )

Reads the status of the interrupt pins. Reading this register also clears or deasserts any currently active interrupt.

Returns
The 8-bit content of the INT_SOURCE register.

◆ getX()

int16_t Adafruit_ADXL343::getX ( void  )

Gets the most recent X axis value.

Returns
The 16-bit signed value for the X axis

◆ getY()

int16_t Adafruit_ADXL343::getY ( void  )

Gets the most recent Y axis value.

Returns
The 16-bit signed value for the Y axis

◆ getZ()

int16_t Adafruit_ADXL343::getZ ( void  )

Gets the most recent Z axis value.

Returns
The 16-bit signed value for the Z axis

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