Barometer.h@1:b6a29c7aeaa9, 2016-08-19 (annotated)
- Committer:
- Soyoon
- Date:
- Fri Aug 19 07:56:26 2016 +0000
- Revision:
- 1:b6a29c7aeaa9
- Parent:
- 0:f6f6f699ab24
deliver;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Soyoon | 0:f6f6f699ab24 | 1 | #ifndef Barometer_H |
| Soyoon | 0:f6f6f699ab24 | 2 | #define Barometer_H |
| Soyoon | 0:f6f6f699ab24 | 3 | #include "mbed.h" |
| Soyoon | 0:f6f6f699ab24 | 4 | |
| Soyoon | 0:f6f6f699ab24 | 5 | |
| Soyoon | 0:f6f6f699ab24 | 6 | enum Barometer_oss { |
| Soyoon | 0:f6f6f699ab24 | 7 | Barometer_oss1 = 0, ///< ultra low power (1 time) |
| Soyoon | 0:f6f6f699ab24 | 8 | Barometer_oss2 = 1, ///< standard (2 times) |
| Soyoon | 0:f6f6f699ab24 | 9 | Barometer_oss4 = 2, ///< high resolution (4 times) |
| Soyoon | 0:f6f6f699ab24 | 10 | Barometer_oss8 = 3 ///< ultra high resolution (8 times) |
| Soyoon | 0:f6f6f699ab24 | 11 | }; |
| Soyoon | 0:f6f6f699ab24 | 12 | |
| Soyoon | 0:f6f6f699ab24 | 13 | |
| Soyoon | 0:f6f6f699ab24 | 14 | class Barometer { |
| Soyoon | 0:f6f6f699ab24 | 15 | public: |
| Soyoon | 1:b6a29c7aeaa9 | 16 | Barometer(PinName p_sda, PinName p_scl, Barometer_oss p_oss = Barometer_oss2); |
| Soyoon | 1:b6a29c7aeaa9 | 17 | Barometer(I2C& p_i2c, Barometer_oss p_oss = Barometer_oss2); |
| Soyoon | 0:f6f6f699ab24 | 18 | |
| Soyoon | 0:f6f6f699ab24 | 19 | float get_temperature(); |
| Soyoon | 0:f6f6f699ab24 | 20 | float get_pressure(); |
| Soyoon | 1:b6a29c7aeaa9 | 21 | float get_altitude_m(); |
| Soyoon | 0:f6f6f699ab24 | 22 | void update(); |
| Soyoon | 0:f6f6f699ab24 | 23 | |
| Soyoon | 0:f6f6f699ab24 | 24 | protected: |
| Soyoon | 0:f6f6f699ab24 | 25 | void init(Barometer_oss); |
| Soyoon | 0:f6f6f699ab24 | 26 | unsigned short twi_readshort (int, int); |
| Soyoon | 0:f6f6f699ab24 | 27 | unsigned long twi_readlong (int, int); |
| Soyoon | 0:f6f6f699ab24 | 28 | void twi_writechar (int, int, int); |
| Soyoon | 0:f6f6f699ab24 | 29 | |
| Soyoon | 0:f6f6f699ab24 | 30 | I2C i2c; |
| Soyoon | 0:f6f6f699ab24 | 31 | float temperature; |
| Soyoon | 0:f6f6f699ab24 | 32 | float pressure; |
| Soyoon | 1:b6a29c7aeaa9 | 33 | float altitude; |
| Soyoon | 0:f6f6f699ab24 | 34 | |
| Soyoon | 0:f6f6f699ab24 | 35 | private: |
| Soyoon | 0:f6f6f699ab24 | 36 | |
| Soyoon | 0:f6f6f699ab24 | 37 | short ac1, ac2, ac3, b1, b2, mb, mc, md, oss; |
| Soyoon | 0:f6f6f699ab24 | 38 | unsigned short ac4, ac5, ac6; |
| Soyoon | 0:f6f6f699ab24 | 39 | }; |
| Soyoon | 0:f6f6f699ab24 | 40 | |
| Soyoon | 0:f6f6f699ab24 | 41 | #endif |