Adafruit ADXL343 Library
|
#include <Adafruit_ADXL343.h>
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 software SPI mode. More... | |
Adafruit_ADXL343 (uint8_t cs, SPIClass *theSPI, int32_t sensorID=-1) | |
Instantiates a new ADXL343 class in hardware SPI mode. More... | |
bool | begin (uint8_t i2caddr=ADXL343_ADDRESS) |
Setups the HW (reads coefficients values, etc.) More... | |
void | setRange (adxl34x_range_t range) |
Sets the g range for the accelerometer. More... | |
adxl34x_range_t | getRange (void) |
Sets the g range for the accelerometer. More... | |
void | setDataRate (adxl3xx_dataRate_t dataRate) |
Sets the data rate for the ADXL343 (controls power consumption) More... | |
adxl3xx_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... | |
void | getTrimOffsets (int8_t *x, int8_t *y, int8_t *z) |
Retrieves the X Y Z trim offsets, note that they are 4 bits signed but we use int8_t to store and 'extend' the sign bit! More... | |
void | setTrimOffsets (int8_t x, int8_t y, int8_t z) |
Sets the X Y Z trim offsets, note that they are 4 bits signed but we use int8_t to store and 'extend' the sign bit! 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... | |
bool | getXYZ (int16_t &x, int16_t &y, int16_t &z) |
Reads 3x16-bits from the x, y, and z data register. More... | |
Protected Attributes | |
Adafruit_SPIDevice * | spi_dev = NULL |
BusIO SPI device. | |
Adafruit_I2CDevice * | i2c_dev = NULL |
BusIO I2C device. | |
TwoWire * | _wire = NULL |
I2C hardware interface. | |
SPIClass * | _spi = NULL |
SPI hardware interface. | |
int32_t | _sensorID |
User-set sensor identifier. | |
adxl34x_range_t | _range |
cache of range | |
uint8_t | _clk |
SPI software clock. | |
uint8_t | _do |
SPI software data out. | |
uint8_t | _di |
SPI software data in. | |
uint8_t | _cs |
SPI software chip select. | |
Driver for the Adafruit ADXL343 breakout.
Adafruit_ADXL343::Adafruit_ADXL343 | ( | int32_t | sensorID | ) |
Instantiates a new ADXL343 class.
sensorID | An optional ID # so you can track this sensor, it will tag sensorEvents you create. |
Adafruit_ADXL343::Adafruit_ADXL343 | ( | int32_t | sensorID, |
TwoWire * | wireBus | ||
) |
Instantiates a new ADXL343 class.
sensorID | An optional ID # so you can track this sensor, it will tag sensorEvents you create. |
wireBus | TwoWire instance to use for I2C communication. |
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 software SPI mode.
clock | The SCK pin |
miso | The MISO pin |
mosi | The MOSI pin |
cs | The CS/SSEL pin |
sensorID | An optional ID # so you can track this sensor, it will tag sensorEvents you create. |
Adafruit_ADXL343::Adafruit_ADXL343 | ( | uint8_t | cs, |
SPIClass * | theSPI, | ||
int32_t | sensorID = -1 |
||
) |
Instantiates a new ADXL343 class in hardware SPI mode.
cs | The CS/SSEL pin |
theSPI | SPIClass instance to use for SPI communication. |
sensorID | An optional ID # so you can track this sensor, it will tag sensorEvents you create. |
bool Adafruit_ADXL343::begin | ( | uint8_t | i2caddr = ADXL343_ADDRESS | ) |
Setups the HW (reads coefficients values, etc.)
i2caddr | The 7-bit I2C address to find the ADXL on |
void Adafruit_ADXL343::setRange | ( | adxl34x_range_t | range | ) |
Sets the g range for the accelerometer.
range | The range to set, based on adxl34x_range_t |
adxl34x_range_t Adafruit_ADXL343::getRange | ( | void | ) |
Sets the g range for the accelerometer.
void Adafruit_ADXL343::setDataRate | ( | adxl3xx_dataRate_t | dataRate | ) |
Sets the data rate for the ADXL343 (controls power consumption)
dataRate | The data rate to set, based on adxl3xx_dataRate_t |
adxl3xx_dataRate_t Adafruit_ADXL343::getDataRate | ( | void | ) |
Sets the data rate for the ADXL343 (controls power consumption)
bool Adafruit_ADXL343::getEvent | ( | sensors_event_t * | event | ) |
Gets the most recent sensor event.
event | Pointer to the sensors_event_t placeholder |
void Adafruit_ADXL343::getSensor | ( | sensor_t * | sensor | ) |
Gets the sensor_t data.
sensor | Pointer to the sensor_t placeholder. |
uint8_t Adafruit_ADXL343::getDeviceID | ( | void | ) |
Read the device ID (can be used to check connection)
void Adafruit_ADXL343::writeRegister | ( | uint8_t | reg, |
uint8_t | value | ||
) |
Writes 8-bits to the specified destination register.
reg | The register to write to |
value | The value to write to the register |
uint8_t Adafruit_ADXL343::readRegister | ( | uint8_t | reg | ) |
Reads 8-bits from the specified register.
reg | register to read |
int16_t Adafruit_ADXL343::read16 | ( | uint8_t | reg | ) |
Reads 16-bits from the specified register.
reg | The register to read two bytes from |
bool Adafruit_ADXL343::enableInterrupts | ( | int_config | cfg | ) |
Enables (1) or disables (0) the interrupts on the specified interrupt pin.
cfg | The bitfield of the interrupts to enable or disable. |
bool Adafruit_ADXL343::mapInterrupts | ( | int_config | cfg | ) |
'Maps' the specific interrupt to either pin INT1 (bit=0), of pin INT2 (bit=1).
cfg | The bitfield of the interrupts to enable or disable. |
uint8_t Adafruit_ADXL343::checkInterrupts | ( | void | ) |
Reads the status of the interrupt pins. Reading this register also clears or deasserts any currently active interrupt.
void Adafruit_ADXL343::getTrimOffsets | ( | int8_t * | x, |
int8_t * | y, | ||
int8_t * | z | ||
) |
Retrieves the X Y Z trim offsets, note that they are 4 bits signed but we use int8_t to store and 'extend' the sign bit!
x | Pointer to the x offset, from -5 to 4 (internally multiplied by 8 lsb) |
y | Pointer to the y offset, from -5 to 4 (internally multiplied by 8 lsb) |
z | Pointer to the z offset, from -5 to 4 (internally multiplied by 8 lsb) |
void Adafruit_ADXL343::setTrimOffsets | ( | int8_t | x, |
int8_t | y, | ||
int8_t | z | ||
) |
Sets the X Y Z trim offsets, note that they are 4 bits signed but we use int8_t to store and 'extend' the sign bit!
x | The x offset, from -5 to 4 (internally multiplied by 8 lsb) |
y | The y offset, from -5 to 4 (internally multiplied by 8 lsb) |
z | The z offset, from -5 to 4 (internally multiplied by 8 lsb) |
int16_t Adafruit_ADXL343::getX | ( | void | ) |
Gets the most recent X axis value.
int16_t Adafruit_ADXL343::getY | ( | void | ) |
Gets the most recent Y axis value.
int16_t Adafruit_ADXL343::getZ | ( | void | ) |
Gets the most recent Z axis value.
bool Adafruit_ADXL343::getXYZ | ( | int16_t & | x, |
int16_t & | y, | ||
int16_t & | z | ||
) |
Reads 3x16-bits from the x, y, and z data register.
x | reference to return x acceleration data |
y | reference to return y acceleration data |
z | reference to return z acceleration data |