Class to interact with the ADXL345 accelerometer.
More...
#include <Adafruit_ADXL345_U.h>
Class to interact with the ADXL345 accelerometer.
◆ Adafruit_ADXL345_Unified() [1/2]
Adafruit_ADXL345_Unified::Adafruit_ADXL345_Unified |
( |
int32_t |
sensorID = -1 | ) |
|
Instantiates a new ADXL345 class.
- Parameters
-
sensorID | A unique ID to use to differentiate the sensor from others |
◆ Adafruit_ADXL345_Unified() [2/2]
Adafruit_ADXL345_Unified::Adafruit_ADXL345_Unified |
( |
uint8_t |
clock, |
|
|
uint8_t |
miso, |
|
|
uint8_t |
mosi, |
|
|
uint8_t |
cs, |
|
|
int32_t |
sensorID = -1 |
|
) |
| |
Instantiates a new ADXL345 class in SPI mode.
- Parameters
-
clock | The pin number for SCK, the SPI ClocK line |
miso | The pin number for MISO, the SPI Master In Slave Out line |
mosi | The pin number for MOSI, the SPI Master Out Slave In line |
cs | The pin number for CS, the SPI Chip Select line |
sensorID | A unique ID to use to differentiate the sensor from others |
◆ begin()
Setups the HW (reads coefficients values, etc.)
- Parameters
-
i2caddr | The I2C address to begin communication with |
- Returns
- true: success false: a sensor with the correct ID was not found
◆ setRange()
void Adafruit_ADXL345_Unified::setRange |
( |
range_t |
range | ) |
|
Sets the g range for the accelerometer.
- Parameters
-
range | The new range_t to set the accelerometer to |
◆ getRange()
range_t Adafruit_ADXL345_Unified::getRange |
( |
void |
| ) |
|
Gets the g range for the accelerometer.
- Returns
- The current
range_t
value
◆ setDataRate()
void Adafruit_ADXL345_Unified::setDataRate |
( |
dataRate_t |
dataRate | ) |
|
Sets the data rate for the ADXL345 (controls power consumption)
- Parameters
-
dataRate | The dataRate_t to set |
◆ getDataRate()
dataRate_t Adafruit_ADXL345_Unified::getDataRate |
( |
void |
| ) |
|
Gets the data rate for the ADXL345 (controls power consumption)
- Returns
- The current data rate
◆ getEvent()
bool Adafruit_ADXL345_Unified::getEvent |
( |
sensors_event_t * |
event | ) |
|
Gets the most recent sensor event.
- Parameters
-
event | Pointer to the event object to fill |
- Returns
- true: success
◆ getSensor()
void Adafruit_ADXL345_Unified::getSensor |
( |
sensor_t * |
sensor | ) |
|
Fill a sensor_t
struct with information about the sensor.
- Parameters
-
sensor | Pointer to a sensor_t struct to fill |
◆ getDeviceID()
uint8_t Adafruit_ADXL345_Unified::getDeviceID |
( |
void |
| ) |
|
Reads the device ID (can be used to check connection)
- Returns
- The Device ID of the connected sensor
◆ writeRegister()
void Adafruit_ADXL345_Unified::writeRegister |
( |
uint8_t |
reg, |
|
|
uint8_t |
value |
|
) |
| |
Writes one byte to the specified destination register.
- Parameters
-
reg | The address of the register to write to |
value | The value to set the register to |
◆ readRegister()
uint8_t Adafruit_ADXL345_Unified::readRegister |
( |
uint8_t |
reg | ) |
|
Reads one byte from the specified register.
- Parameters
-
reg | The address of the register to read from |
- Returns
- The single byte value of the requested register
◆ read16()
int16_t Adafruit_ADXL345_Unified::read16 |
( |
uint8_t |
reg | ) |
|
Reads two bytes from the specified register.
- Parameters
-
reg | The address of the register to read from |
- Returns
- The two bytes read from the sensor starting at the given address
◆ getX()
int16_t Adafruit_ADXL345_Unified::getX |
( |
void |
| ) |
|
Gets the most recent X axis value.
- Returns
- The raw
int16_t
unscaled x-axis acceleration value
◆ getY()
int16_t Adafruit_ADXL345_Unified::getY |
( |
void |
| ) |
|
Gets the most recent Y axis value.
- Returns
- The raw
int16_t
unscaled y-axis acceleration value
◆ getZ()
int16_t Adafruit_ADXL345_Unified::getZ |
( |
void |
| ) |
|
Gets the most recent Z axis value.
- Returns
- The raw
int16_t
unscaled z-axis acceleration value
The documentation for this class was generated from the following files: