upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the DFRobot MMA7361 Analog Accelerometer. More...
This library was tested with the DFRobot MMA7361 Analog Accelerometer. It supports 3 Axes with a selectable 1.5G and 6G sensitivity.
Public Member Functions | |
MMA7361 (int x_pin, int y_pin, int z_pin, int selftest_pin, int sleep_pin, int freefall_pin, int range_pin, float a_ref=5.0) | |
~MMA7361 () | |
void | setRange (bool range) |
void | setSleep (bool sleep) |
bool | isInFreefall () |
void | enableSelftest (bool enable) |
void | update () |
void | setOffset (float x, float y, float z) |
void | setScale (float x, float y, float z) |
void | getAcceleration (float *x, float *y, float *z) |
float * | getAcceleration () |
void | getVolts (float *x, float *y, float *z) |
float * | getVolts () |
void | getNormalized (float *x, float *y, float *z) |
float * | getNormalized () |
Protected Attributes | |
mma7361_context | m_mma7361 |
MMA7361 | ( | int | x_pin, |
int | y_pin, | ||
int | z_pin, | ||
int | selftest_pin, | ||
int | sleep_pin, | ||
int | freefall_pin, | ||
int | range_pin, | ||
float | a_ref = 5.0 |
||
) |
MMA7361 object constructor
x_pin | Analog pin to use for X axis. -1 to disable. |
y_pin | Analog pin to use for Y axis. -1 to disable. |
z_pin | Analog pin to use for Z axis. -1 to disable. |
selftest_pin | GPIO pin to use for self test. -1 to disable. |
sleep_pin | GPIO pin to use for sleep function. -1 to disable. |
freefall_pin | GPIO pin to use for free fall (0g) detection. -1 to disable. |
range_pin | GPIO pin to select range (1.5g or 6g). -1 to disable. |
a_ref | The analog reference voltage in use. Default 5.0. |
void setRange | ( | bool | range | ) |
Set the range of the device. This device supports two G ranges: 1.5 and 6. The default is 1.5G.
range | true for 6G, false for 1.5G |
void setSleep | ( | bool | sleep | ) |
Set sleep mode. When in sleep mode the sensor uses minimal power.
sleep | true to go into sleep mode, false to wake up |
bool isInFreefall | ( | ) |
Get freefall detection status.
void enableSelftest | ( | bool | enable | ) |
Enable self test mode.
enable | true to enable the self test mode, false otherwise. |
void update | ( | void | ) |
Read the sensor status an update internal state. update() must have been called before calling getAcceleration(), getNormalized(), or getVolts().
void setOffset | ( | float | x, |
float | y, | ||
float | z | ||
) |
Set sensor offset. This offset is applied to the return values before scaling. Default is 0.0.
x | Offset to apply to X value |
y | Offset to apply to Y value |
z | Offset to apply to Z value |
void setScale | ( | float | x, |
float | y, | ||
float | z | ||
) |
Set sensor scale. The acceleration return values are scaled by this value before the offset is applied. Default is 1.0.
x | Scale to apply to X value |
y | Scale to apply to Y value |
z | Scale to apply to Z value |
void getAcceleration | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Get computed acceleration from the sensor. update() must have been called prior to calling this function.
x | a pointer in which X acceleration data will be returned |
y | a pointer in which Y acceleration data will be returned |
z | a pointer in which Z acceleration data will be returned |
float * getAcceleration | ( | ) |
Get computed acceleration from the sensor. update() must have been called prior to calling this function.
void getVolts | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Get the measured volts from the sensor. update() must have been called prior to calling this function.
x | a pointer in which X volt data will be returned |
y | a pointer in which Y volt data will be returned |
z | a pointer in which Z volt data will be returned |
float * getVolts | ( | ) |
Get the measured volts from the sensor. update() must have been called prior to calling this function.
void getNormalized | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Get the normalized ADC values from the sensor. update() must have been called prior to calling this function.
x | a pointer in which X normalized ADC data will be returned |
y | a pointer in which Y normalized ADC data will be returned |
z | a pointer in which Z normalized ADC data will be returned |
float * getNormalized | ( | ) |
Get the normalized ADC values from the sensor. update() must have been called prior to calling this function.