BMP280から気圧データを取得します。updateで更新動作、getpressで値を読み出します
Diff: BMP280.h
- Revision:
- 1:a65c7f637b1e
- Parent:
- 0:54d7f18450e6
diff -r 54d7f18450e6 -r a65c7f637b1e BMP280.h --- a/BMP280.h Sun Dec 04 14:38:21 2016 +0000 +++ b/BMP280.h Tue Feb 13 04:19:43 2018 +0000 @@ -9,7 +9,7 @@ int main() { - bmp.init(OSR_1,OSR_4,T_SB_0_5,IIR_0); + bmp.init(OSR_1,OSR_4,IIR_0); while(1) { @@ -26,18 +26,9 @@ #define OSR_8 0b100 #define OSR_16 0b101 -#define T_SB_0_5 0b000 -#define T_SB_62_5 0b001 -#define T_SB_125 0b010 -#define T_SB_250 0b011 -#define T_SB_500 0b100 -#define T_SB_1000 0b101 -#define T_SB_2000 0b110 -#define T_SB_4000 0b111 - #define IIR_0 0b000 #define IIR_4 0b100 -#define IIR_16 0b10000 +#define IIR_16 0b111 @@ -47,7 +38,7 @@ public: BMP280(PinName mosi,PinName miso,PinName sck,PinName _cs); - void init(char t_osr,char p_osr,char t_sb,char IIR); + void init(char t_osr,char p_osr,char IIR); char readbyte(char adr); void writebyte(char adr,char data); void readnbyte(char adr,char *data,char num); @@ -55,7 +46,7 @@ int bmp280_compensate_T_int32(int adc_T); unsigned int bmp280_compensate_P_int64(int adc_P); bool update(); - float getpress(); + unsigned int getpress(); private: @@ -66,6 +57,9 @@ short dig_T2,dig_T3,dig_P2,dig_P3,dig_P4,dig_P5,dig_P6,dig_P7,dig_P8,dig_P9; unsigned int press; + char _t_osr; + char _p_osr; + char _IIR; };