MMA7361L interface

Dependents:   MMA7361L_Example ARLISS2012_Hidaka

Embed: (wiki syntax)

« Back to documentation index

MMA7361L Class Reference

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.

Enumerator:
SCALE_1_5G 

1.5G mode

SCALE_6G 

6G mode

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:
xoutPinxout pin
youtPinyout pin
zoutPinzout pin
zeroGDetectPin0G detect pin
gSelectPinselect 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:
scalescale for calibration
minXmin X value when the X axis is vertical and stable under 1g
maxXmax X value when the X axis is vertical and stable under 1g
minYmin Y value when the Y axis is vertical and stable under 1g
maxYmax Y value when the Y axis is vertical and stable under 1g
minZmin Z value when the Z axis is vertical and stable under 1g
maxZmax 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:
forceReadtrue 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:
forceReadtrue 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:
forceReadtrue 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:
forceReadtrue 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:
forceReadtrue 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:
forceReadtrue 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:
forceReadtrue 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:
scaleSCALE_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:
ontrue 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:
tpointer to the object to call the member function on
funcpointer 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:
funcpointer 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.