upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _mma7361_context |
Functions | |
mma7361_context | mma7361_init (int x_pin, int y_pin, int z_pin, int selftest_pin, int sleep_pin, int freefall_pin, int range_pin, float a_ref) |
void | mma7361_close (mma7361_context dev) |
void | mma7361_set_range (const mma7361_context dev, bool range) |
upm_result_t | mma7361_sleep (const mma7361_context dev, bool sleep) |
upm_result_t | mma7361_freefall (const mma7361_context dev, bool *freefall) |
upm_result_t | mma7361_selftest (const mma7361_context dev, bool selftest) |
upm_result_t | mma7361_update (const mma7361_context dev) |
void | mma7361_set_offset (const mma7361_context dev, float x, float y, float z) |
void | mma7361_set_scale (const mma7361_context dev, float x, float y, float z) |
void | mma7361_get_acceleration (const mma7361_context dev, float *x, float *y, float *z) |
void | mma7361_get_volts (const mma7361_context dev, float *x, float *y, float *z) |
void | mma7361_get_normalized (const mma7361_context dev, float *x, float *y, float *z) |
Typedefs | |
typedef struct _mma7361_context * | mma7361_context |
mma7361_context mma7361_init | ( | int | x_pin, |
int | y_pin, | ||
int | z_pin, | ||
int | selftest_pin, | ||
int | sleep_pin, | ||
int | freefall_pin, | ||
int | range_pin, | ||
float | a_ref | ||
) |
MMA7361 Initializer
This sensor isn't designed for navigational purposes - rather it's intended for less precise measurements such as determining tilt and orientation.
All of these pins are optional, and will depend on how your device is connected. For those pins you do not need, supply -1 as the pin. You must supply a valid pin for at least one of the axes, or what's the point?
The DFRobot variant of this sensor uses a mechanical switch on the board to determine the G-range to use, so on this board you would supply -1 for the range_pin, but be sure to call mma7361_set_range() with the correct parameter so that the internal logic will generate correct results.
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 |
void mma7361_close | ( | mma7361_context | dev | ) |
MMA7361 sensor close function
void mma7361_set_range | ( | const mma7361_context | dev, |
bool | range | ||
) |
Set the range of the device. This device supports two G ranges: 1.5 and 6. The default is 1.5G.
dev | sensor context |
range | true for 6G, false for 1.5G |
upm_result_t mma7361_sleep | ( | const mma7361_context | dev, |
bool | sleep | ||
) |
Set sleep mode. When in sleep mode the sensor uses minimal power.
dev | sensor context |
sleep | true to go into sleep mode, false to wake up |
upm_result_t mma7361_freefall | ( | const mma7361_context | dev, |
bool * | freefall | ||
) |
Get freefall detection status.
dev | sensor context |
freefall | O pointer to a boolean value indicating whether a freefall condition is being detected. |
upm_result_t mma7361_selftest | ( | const mma7361_context | dev, |
bool | selftest | ||
) |
Enable self test mode.
dev | sensor context |
selftest | true to enable the self test mode, false otherwise. |
upm_result_t mma7361_update | ( | const mma7361_context | dev | ) |
Read the sensor status an update internal state. mma7361_update() must have been called before calling mma7361_get_acceleration(), mma7361_get_normalized(), or mma7361_get_volts().
dev | sensor context |
void mma7361_set_offset | ( | const mma7361_context | dev, |
float | x, | ||
float | y, | ||
float | z | ||
) |
Set sensor offset. This offset is applied to the return values before scaling. Default is 0.0.
dev | sensor context pointer |
x | Scale to apply to X value |
y | Scale to apply to Y value |
z | Scale to apply to Z value |
void mma7361_set_scale | ( | const mma7361_context | dev, |
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.
dev | sensor context pointer |
x | Offset to apply to X value |
y | Offset to apply to Y value |
z | Offset to apply to Z value |
void mma7361_get_acceleration | ( | const mma7361_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Get computed acceleration from the sensor. mma7361_update() must have been called prior to calling this function.
dev | sensor context pointer |
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 |
void mma7361_get_volts | ( | const mma7361_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Get the measured volts from the sensor. mma7361_update() must have been called prior to calling this function.
dev | sensor context pointer |
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 |
void mma7361_get_normalized | ( | const mma7361_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Get the normalized ADC values from the sensor. mma7361_update() must have been called prior to calling this function.
dev | sensor context pointer |
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 |
typedef struct _mma7361_context * mma7361_context |
Device context