Dependents:   accelerometer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MMA7361L.h Source File

MMA7361L.h

00001 #ifndef MMA7361L_H
00002 #define MMA7361L_H
00003 
00004 #include "mbed.h"
00005 /**accelerometer*/
00006 class MMA7361L {
00007 public:
00008     /**
00009     * Creates an MMA7361L accelerometer interface, connected to the specified pins
00010     * @param xoutPin xout pin
00011     * @param youtPin yout pin
00012     * @param zoutPin zout pin
00013     * @param zeroGDetectPin 0G detect pin
00014     */
00015     MMA7361L(PinName xoutPin, PinName youtPin,PinName zoutPin,
00016              PinName zeroGDetectPin);         
00017     /**
00018     * Gets the current total acceleration
00019     * @returns total acceleration in g
00020     */          
00021     float getAccel();
00022     /** 
00023     * Gets the current acceleration along the X axis 
00024     * @returns acceleration along the X axis in g
00025     */
00026     float getAccelX();
00027     /** 
00028     * Gets the current acceleration along the Y axis 
00029     * @returns acceleration along the Y axis in g
00030     */
00031     float getAccelY();
00032     /** 
00033     * Gets the current acceleration along the Z axis 
00034     * @returns acceleration along the Z axis in g
00035     */
00036     float getAccelZ();
00037     /**
00038     * Computes the inclination of the X axis
00039     * @returns the inclination of the X axis
00040     */
00041     float getTiltX();
00042     /**
00043     * Computes the inclination of the Y axis
00044     * @returns the inclination of the Y axis
00045     */    
00046     float getTiltY();
00047     /**
00048     * Computes the inclination of the Z axis
00049     * @returns the inclination of the Z axis
00050     */
00051     float getTiltZ();
00052     /**
00053      * Tests whether 0G is detected
00054      * @returns true if 0G is detected, false otherwise
00055      */
00056     bool zeroGDetected();
00057     /**
00058     * Sets fucntion to be called when 0G is detected
00059     * @param func pointer to a function called when 0G is detected, 0 to reset as none
00060     */ 
00061     void setZeroGDetectListener(void (*func)(void));
00062     /**
00063     * Sets member fucntion to be called when 0G is detected  
00064     * @param t pointer to the object to call the member function on
00065     * @param func pointer to the member function tobe called when 0G is detected, 0 to reset as none
00066     */
00067     template<typename T> void setZeroGDetectListener(T* t, void (T::*func)(void));
00068 
00069 private:
00070     void prepare();
00071 
00072     AnalogIn xout, yout, zout;
00073     InterruptIn zeroGDetect;
00074     float accelX;
00075     float accelY;
00076     float accelZ;
00077     float scaleX;
00078     float scaleY;
00079     float scaleZ;
00080     float Xo;
00081     float Yo;
00082     float Zo;
00083 };
00084 
00085 #endif