HDC1050 Library
HDC1050.h@1:db08a3faa811, 2017-07-11 (annotated)
- Committer:
- zebrin1422
- Date:
- Tue Jul 11 05:17:33 2017 +0000
- Revision:
- 1:db08a3faa811
- Parent:
- 0:771ed287f6a8
HDC1050 Library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zebrin1422 | 0:771ed287f6a8 | 1 | #ifndef HDC1050 |
zebrin1422 | 0:771ed287f6a8 | 2 | #define HDC1050 |
zebrin1422 | 0:771ed287f6a8 | 3 | |
zebrin1422 | 0:771ed287f6a8 | 4 | #define SLV_WRITE 0b10000000 |
zebrin1422 | 0:771ed287f6a8 | 5 | #define SLV_READ 0b10000001 |
zebrin1422 | 0:771ed287f6a8 | 6 | |
zebrin1422 | 0:771ed287f6a8 | 7 | #define check_reg 0xFF |
zebrin1422 | 0:771ed287f6a8 | 8 | #define Ctrl_reg 0x02 |
zebrin1422 | 0:771ed287f6a8 | 9 | #define Temperature_reg 0x00 |
zebrin1422 | 0:771ed287f6a8 | 10 | #define Humidity_reg 0x01 |
zebrin1422 | 0:771ed287f6a8 | 11 | |
zebrin1422 | 0:771ed287f6a8 | 12 | //I2C i2c(PB_7, PB_6); // sda, scl |
zebrin1422 | 0:771ed287f6a8 | 13 | //Serial pc(USBTX, USBRX); //tx, rx |
zebrin1422 | 0:771ed287f6a8 | 14 | |
zebrin1422 | 0:771ed287f6a8 | 15 | /** |
zebrin1422 | 0:771ed287f6a8 | 16 | * @bref HDC1050 Class |
zebrin1422 | 0:771ed287f6a8 | 17 | * @author Seiya Maemura |
zebrin1422 | 0:771ed287f6a8 | 18 | */ |
zebrin1422 | 0:771ed287f6a8 | 19 | |
zebrin1422 | 0:771ed287f6a8 | 20 | /* |
zebrin1422 | 0:771ed287f6a8 | 21 | 温度の値は信頼出来るが湿度の値は全く信用できない |
zebrin1422 | 0:771ed287f6a8 | 22 | 注意されたし |
zebrin1422 | 0:771ed287f6a8 | 23 | ※少なくとも試験用に使ったモジュールでは |
zebrin1422 | 0:771ed287f6a8 | 24 | */ |
zebrin1422 | 0:771ed287f6a8 | 25 | |
zebrin1422 | 0:771ed287f6a8 | 26 | |
zebrin1422 | 0:771ed287f6a8 | 27 | |
zebrin1422 | 0:771ed287f6a8 | 28 | class myHDC1050 |
zebrin1422 | 0:771ed287f6a8 | 29 | { |
zebrin1422 | 0:771ed287f6a8 | 30 | public: |
zebrin1422 | 0:771ed287f6a8 | 31 | |
zebrin1422 | 0:771ed287f6a8 | 32 | |
zebrin1422 | 0:771ed287f6a8 | 33 | myHDC1050(I2C &i2cBus); |
zebrin1422 | 0:771ed287f6a8 | 34 | |
zebrin1422 | 1:db08a3faa811 | 35 | void setup(int i);//詳細は.cppを参照 |
zebrin1422 | 0:771ed287f6a8 | 36 | |
zebrin1422 | 0:771ed287f6a8 | 37 | int Connection_check();//0が返ってくればOK,1ならばError |
zebrin1422 | 0:771ed287f6a8 | 38 | |
zebrin1422 | 1:db08a3faa811 | 39 | void get_temp_hum(float *temp, float *hum);//同時にとる方が演算量は少ない |
zebrin1422 | 0:771ed287f6a8 | 40 | |
zebrin1422 | 1:db08a3faa811 | 41 | float get_temp();//個別でデータが欲しい時はこちら |
zebrin1422 | 0:771ed287f6a8 | 42 | |
zebrin1422 | 1:db08a3faa811 | 43 | float get_hum(); |
zebrin1422 | 0:771ed287f6a8 | 44 | |
zebrin1422 | 0:771ed287f6a8 | 45 | |
zebrin1422 | 0:771ed287f6a8 | 46 | private: |
zebrin1422 | 0:771ed287f6a8 | 47 | |
zebrin1422 | 0:771ed287f6a8 | 48 | I2C *i2c; |
zebrin1422 | 0:771ed287f6a8 | 49 | double temp,hum; |
zebrin1422 | 0:771ed287f6a8 | 50 | unsigned int val[4]; |
zebrin1422 | 0:771ed287f6a8 | 51 | char cmd[2][2],buff[4],reg,check[2]; |
zebrin1422 | 0:771ed287f6a8 | 52 | |
zebrin1422 | 0:771ed287f6a8 | 53 | |
zebrin1422 | 0:771ed287f6a8 | 54 | |
zebrin1422 | 0:771ed287f6a8 | 55 | }; |
zebrin1422 | 0:771ed287f6a8 | 56 | |
zebrin1422 | 0:771ed287f6a8 | 57 | #endif |
zebrin1422 | 0:771ed287f6a8 | 58 | |
zebrin1422 | 0:771ed287f6a8 | 59 | |
zebrin1422 | 0:771ed287f6a8 | 60 | |
zebrin1422 | 0:771ed287f6a8 | 61 | |
zebrin1422 | 0:771ed287f6a8 | 62 | |
zebrin1422 | 0:771ed287f6a8 | 63 |