気圧センサ LPS25H を I2C 接続で使うためのライブラリ. Library for atmospheric pressure sensor LPS25H using I2C interface.
LPS25H_I2C.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-12-18
- Revision:
- 0:888288e9f8d5
File content as of revision 0:888288e9f8d5:
//--------------------------------------------------------- // Class for atmospheric pressure sensor LPS25H (Header) // Interface: I2C only // Pin assignment // VDD: pin1 // SCL: pin2 // SDA: pin3 // GND: pin8 // // 2016/12/18, Copyright (c) 2016 MIKAMI, Naoki //--------------------------------------------------------- #ifndef LPS25H_I2C_HPP #define LPS25H_I2C_HPP #include "mbed.h" namespace Mikami { class Lps25hI2c { public: // Constructor Lps25hI2c(PinName sda = D14, // SDA PinName scl = D15, // SCL uint8_t addr = 0xB8); // 0xB8: SA0 => GND ~Lps25hI2c() { delete i2cPtr_; } // Read atmospheric pressure // Unit of return value: hPa float Read(); // Operator shorthand for Read() operator float() { return Read(); } private: const uint8_t ADDR_; I2C *i2cPtr_; // Pointer of I2C object // disallow copy constructor and assignment operator Lps25hI2c(const Lps25hI2c&); Lps25hI2c& operator=(const Lps25hI2c&); }; } #endif // LPS25H_I2C_HPP