MMA7361L interface
Dependents: MMA7361L_Example ARLISS2012_Hidaka
MMA7361L Class Reference
MMA7361L accelerometer. More...
#include <MMA7361L.h>
Public Types | |
enum | Scale { SCALE_1_5G, SCALE_6G } |
Scale enumeration declaration. More... | |
Public Member Functions | |
MMA7361L (PinName xoutPin, PinName youtPin, PinName zoutPin, PinName zeroGDetectPin=NC, PinName gSelectPin=NC, PinName sleepPin=NC) | |
Creates an MMA7361L accelerometer interface, connected to the specified pins. | |
float | getAccel (bool forceRead=false) |
Gets the current total acceleration. | |
float | getAccelX (bool forceRead=false) |
Gets the current acceleration along the X axis. | |
float | getAccelY (bool forceRead=false) |
Gets the current acceleration along the Y axis. | |
float | getAccelZ (bool forceRead=false) |
Gets the current acceleration along the Z axis. | |
float | getTiltX (bool forceRead=false) |
Computes the inclination of the X axis. | |
float | getTiltY (bool forceRead=false) |
Computes the inclination of the Y axis. | |
float | getTiltZ (bool forceRead=false) |
Computes the inclination of the Z axis. | |
void | setScale (Scale scale) |
Specifies the scale to use. | |
void | setSleep (bool on) |
Sets sleep mode. | |
bool | zeroGDetected () |
Tests whether 0G is detected. | |
void | setZeroGDetectListener (void(*func)(void)) |
Sets fucntion to be called when 0G is detected. | |
template<typename T > | |
void | setZeroGDetectListener (T *t, void(T::*func)(void)) |
Sets member fucntion to be called when 0G is detected. | |
void | printInfo () |
Prints instance info for debugging. | |
void | calibrate (Scale scale, float minX, float maxX, float minY, float maxY, float minZ, float maxZ) |
Sets calibration info. |
Detailed Description
MMA7361L accelerometer.
Definition at line 9 of file MMA7361L.h.
Member Enumeration Documentation
enum Scale |
Scale enumeration declaration.
Definition at line 27 of file MMA7361L.h.
Constructor & Destructor Documentation
MMA7361L | ( | PinName | xoutPin, |
PinName | youtPin, | ||
PinName | zoutPin, | ||
PinName | zeroGDetectPin = NC , |
||
PinName | gSelectPin = NC , |
||
PinName | sleepPin = NC |
||
) |
Creates an MMA7361L accelerometer interface, connected to the specified pins.
- Parameters:
-
xoutPin xout pin youtPin yout pin zoutPin zout pin zeroGDetectPin 0G detect pin gSelectPin select 1.5G/6G pin nSleepPin ~sleep pin
Definition at line 3 of file MMA7361L.cpp.
Member Function Documentation
void calibrate | ( | Scale | scale, |
float | minX, | ||
float | maxX, | ||
float | minY, | ||
float | maxY, | ||
float | minZ, | ||
float | maxZ | ||
) |
Sets calibration info.
- Parameters:
-
scale scale for calibration minX min X value when the X axis is vertical and stable under 1g maxX max X value when the X axis is vertical and stable under 1g minY min Y value when the Y axis is vertical and stable under 1g maxY max Y value when the Y axis is vertical and stable under 1g minZ min Z value when the Z axis is vertical and stable under 1g maxZ max Z value when the Z axis is vertical and stable under 1g
Definition at line 149 of file MMA7361L.cpp.
float getAccel | ( | bool | forceRead = false ) |
Gets the current total acceleration.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- total acceleration in g
Definition at line 23 of file MMA7361L.cpp.
float getAccelX | ( | bool | forceRead = false ) |
Gets the current acceleration along the X axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- acceleration along the X axis
Definition at line 28 of file MMA7361L.cpp.
float getAccelY | ( | bool | forceRead = false ) |
Gets the current acceleration along the Y axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- acceleration along the Y axis
Definition at line 33 of file MMA7361L.cpp.
float getAccelZ | ( | bool | forceRead = false ) |
Gets the current acceleration along the Z axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- acceleration along the Z axis
Definition at line 38 of file MMA7361L.cpp.
float getTiltX | ( | bool | forceRead = false ) |
Computes the inclination of the X axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- the inclination of the X axis
Definition at line 43 of file MMA7361L.cpp.
float getTiltY | ( | bool | forceRead = false ) |
Computes the inclination of the Y axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- the inclination of the Y axis
Definition at line 48 of file MMA7361L.cpp.
float getTiltZ | ( | bool | forceRead = false ) |
Computes the inclination of the Z axis.
- Parameters:
-
forceRead true to read the device, false to use cache whenever appropriate
- Returns:
- the inclination of the Z axis
Definition at line 53 of file MMA7361L.cpp.
void printInfo | ( | ) |
Prints instance info for debugging.
Definition at line 123 of file MMA7361L.cpp.
void setScale | ( | Scale | scale ) |
Specifies the scale to use.
- Parameters:
-
scale SCALE_1_5G (for 1.5G) or SCALE_6G (for 6G)
Definition at line 58 of file MMA7361L.cpp.
void setSleep | ( | bool | on ) |
Sets sleep mode.
- Parameters:
-
on true to activate sleep mode, false to resume normal operation
Definition at line 75 of file MMA7361L.cpp.
void setZeroGDetectListener | ( | T * | t, |
void(T::*)(void) | func | ||
) |
Sets member fucntion to be called when 0G is detected.
- Parameters:
-
t pointer to the object to call the member function on func pointer to the member function to be called when 0G is detected, 0 to reset as none
Definition at line 92 of file MMA7361L.cpp.
void setZeroGDetectListener | ( | void(*)(void) | func ) |
Sets fucntion to be called when 0G is detected.
- Parameters:
-
func pointer to a function called when 0G is detected, 0 to reset as none
Definition at line 87 of file MMA7361L.cpp.
bool zeroGDetected | ( | ) |
Tests whether 0G is detected.
- Returns:
- true if 0G is detected, false otherwise
Definition at line 80 of file MMA7361L.cpp.
Generated on Sat Jul 23 2022 18:02:38 by 1.7.2