Programme de démonstration DHT11
Dependencies: DHT
Diff: MMA7455.h
- Revision:
- 1:61d800d62542
- Parent:
- 0:97c2d4128ff3
diff -r 97c2d4128ff3 -r 61d800d62542 MMA7455.h --- a/MMA7455.h Thu Jul 20 09:05:08 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -#ifndef MMA7455_H -#define MMA7455_H - - -/** - * Freescale Accelerometer MMA7455. - */ -class MMA7455 { -public: - - enum Mode { - ModeStandby = 0, - ModeMeasurement = 1, - }; - - /** Acceleration range */ - enum Range { - Range_8g = 0, - Range_2g = 1, - Range_4g = 2 - }; - - /** - * Create an interface to the MMA7455 accelerometer - * - * @param sda I2C data line pin - * @param scl I2C clock line pin - */ - MMA7455(PinName sda, PinName scl); - - bool setMode(Mode mode); - bool setRange(Range range); - - bool read(int32_t& x, int32_t& y, int32_t& z); - - /** - * Calibrate for 0g, that is, calculate offset to achieve - * 0g values when accelerometer is placed on flat surface. - * - * Please make sure the accelerometer is placed on a flat surface before - * calling this function. - * - * @return true if request was successful; otherwise false - */ - bool calibrate(); - - /** - * Get calculated offset values. Offsets will be calculated by the - * calibrate() method. - * - * Use these values and put them in persistent storage to avoid - * having to calibrate the accelerometer after a reset/power cycle. - * - * @param xOff x offset is written to this argument - * @param yOff y offset is written to this argument - * @param zOff z offset is written to this argument - * - * @return true if request was successful; otherwise false - */ - bool getCalibrationOffsets(int32_t& xOff, int32_t& yOff, int32_t& zOff); - - /** - * Set calibration offset values. These values should normally - * at one point in time have been retrieved by calling the - * getCalibrationOffsets method. - * - * - * @param xOff x offset - * @param yOff y offset - * @param zOff z offset - * - * @return true if request was successful; otherwise false - */ - bool setCalibrationOffsets(int32_t xOff, int32_t yOff, int32_t zOff); - - - -private: - - I2C _i2c; - Mode _mode; - Range _range; - int32_t _xOff; - int32_t _yOff; - int32_t _zOff; - - int getStatus(); - int getModeControl(); - int setModeControl(uint8_t mctl); - -}; - -#endif