Diff: Accelerometer.h
- Revision:
- 0:f37d59175b91
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Accelerometer.h Mon Jul 09 02:17:49 2012 +0000 @@ -0,0 +1,34 @@ +#ifndef ACCELEROMETER_H +#define ACCELEROMETER_H +#include "mbed.h" + +class Accelerometer{ +public: + Accelerometer (PinName XoutPin, PinName youPin,PinName zoutPin,PinName sleepPin, PinName zeroGDetectPin,PinName gSelectPin); + + enum Scale {SCALE_1_5G,SCALE_6G}; + float getAccel(); + float getAccelX(); + float getAccelY(); + float getAccelZ(); + float getTiltX(); + float getTiltY(); + float getTiltZ(); + + void setScale (Scale scale); + void setSleep(bool on); + bool detectedZeroG(); + void setZeroGDetectListener(void (*func)(void)); + + template<typename T> void setZeroGDetectListener(T* t,void (T::*func)(void)); + private: + + AnalogIn xout,yout,zout; + DigitalIn zeroGDetect; + DigitalOut sleep; + DigitalOut gSelect; + InterruptIn zeroG; + float scale; + + }; + #endif \ No newline at end of file