please publish my library
Fork of accelerometer by
Diff: Accelerometer.h
- Revision:
- 1:e965533a31b2
- Parent:
- 0:f37d59175b91
- Child:
- 2:2c7a73d3ae57
--- a/Accelerometer.h Mon Jul 09 02:17:49 2012 +0000 +++ b/Accelerometer.h Tue Aug 06 10:07:46 2013 +0000 @@ -1,34 +1,43 @@ #ifndef ACCELEROMETER_H #define ACCELEROMETER_H + #include "mbed.h" - -class Accelerometer{ +struct xyz { + float x; + float y; + float z; +}; +class Accel { 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(); + /** create a accelerometer Object + * + * @param xpin analogin pin to connect to for x axis + * @param ypin analogin pin to connect to for y axis + * @param zpin analogin pin to connect to for z axis**/ + + Accel(PinName xpin, PinName ypin, PinName zpin); + float readx(); + /** read analog value from pin y axis + * @param Percent voltage/ref voltage- full range (0.0 - 1.0) + */ + float ready(); + /** read analog value from pin z axis + * + * @param Percent voltage/ref voltage- full range (0.0 - 1.0) + */ + float readz(); + /** read analog value from all pins xy&z + * + * @param Percent voltage/ref voltage- full range (0.0 - 1.0) + */ + float readall(); + +private : + AnalogIn _zpin; + AnalogIn _ypin; + AnalogIn _xpin; - 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 + }; + #endif + + \ No newline at end of file