Сбор информации о погодных условиях
Dependencies: RF24 USBDevice mbed
Sensors/ThermometerTmp36.h@6:db4538895ae7, 2015-12-05 (annotated)
- Committer:
- pro100kot14
- Date:
- Sat Dec 05 16:57:30 2015 +0000
- Revision:
- 6:db4538895ae7
- Parent:
- 4:7cd67d988145
Added unit testing. Test results are displayed on the device LEDs.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pro100kot14 | 0:1e03d2cd238f | 1 | #ifndef ThermometerTMP36_H |
pro100kot14 | 0:1e03d2cd238f | 2 | #define ThermometerTMP36_H |
pro100kot14 | 0:1e03d2cd238f | 3 | |
pro100kot14 | 0:1e03d2cd238f | 4 | #include "mbed.h" |
pro100kot14 | 2:ad2653bcf93f | 5 | /** |
pro100kot14 | 0:1e03d2cd238f | 6 | * Reads the data from the sensor TMP36, |
pro100kot14 | 0:1e03d2cd238f | 7 | * connected to the analog input and converts them to Celsius |
pro100kot14 | 0:1e03d2cd238f | 8 | */ |
pro100kot14 | 0:1e03d2cd238f | 9 | class ThermometerTmp36{ |
pro100kot14 | 0:1e03d2cd238f | 10 | public: |
pro100kot14 | 0:1e03d2cd238f | 11 | /** |
pro100kot14 | 0:1e03d2cd238f | 12 | * Constructor |
pro100kot14 | 0:1e03d2cd238f | 13 | * |
pro100kot14 | 0:1e03d2cd238f | 14 | * @param inputChanel The analog input is connected to the sensor |
pro100kot14 | 0:1e03d2cd238f | 15 | */ |
pro100kot14 | 0:1e03d2cd238f | 16 | ThermometerTmp36(AnalogIn inputChanel):input(inputChanel){} |
pro100kot14 | 0:1e03d2cd238f | 17 | |
pro100kot14 | 0:1e03d2cd238f | 18 | /** |
pro100kot14 | 0:1e03d2cd238f | 19 | * The temperature in degrees Celsius |
pro100kot14 | 0:1e03d2cd238f | 20 | * |
pro100kot14 | 0:1e03d2cd238f | 21 | * @returns Temperature |
pro100kot14 | 0:1e03d2cd238f | 22 | */ |
pro100kot14 | 0:1e03d2cd238f | 23 | double getTemperature(); |
pro100kot14 | 0:1e03d2cd238f | 24 | |
pro100kot14 | 6:db4538895ae7 | 25 | /** |
pro100kot14 | 6:db4538895ae7 | 26 | * The temperature in degrees Celsius, calculated based on a parameter. |
pro100kot14 | 6:db4538895ae7 | 27 | * Сomfortably for testing. |
pro100kot14 | 6:db4538895ae7 | 28 | * |
pro100kot14 | 6:db4538895ae7 | 29 | * @param adcVal ADC value on the port to which the sensor is connected |
pro100kot14 | 6:db4538895ae7 | 30 | * |
pro100kot14 | 6:db4538895ae7 | 31 | * @returns Temperature |
pro100kot14 | 6:db4538895ae7 | 32 | */ |
pro100kot14 | 6:db4538895ae7 | 33 | static double getTemperatureByAdcValue(float adcVal); |
pro100kot14 | 6:db4538895ae7 | 34 | |
pro100kot14 | 0:1e03d2cd238f | 35 | private: |
pro100kot14 | 0:1e03d2cd238f | 36 | AnalogIn input; |
pro100kot14 | 0:1e03d2cd238f | 37 | }; |
pro100kot14 | 0:1e03d2cd238f | 38 | |
pro100kot14 | 6:db4538895ae7 | 39 | /** |
pro100kot14 | 6:db4538895ae7 | 40 | * Tested the class ThermometerTmp36 |
pro100kot14 | 6:db4538895ae7 | 41 | */ |
pro100kot14 | 6:db4538895ae7 | 42 | class ThermometerTmp36Test{ |
pro100kot14 | 6:db4538895ae7 | 43 | public: |
pro100kot14 | 6:db4538895ae7 | 44 | static bool adcValue_0_15_is_0_degree(); |
pro100kot14 | 6:db4538895ae7 | 45 | static bool adcValue_0_196_is_15_degree(); |
pro100kot14 | 6:db4538895ae7 | 46 | static bool adcValue_0_242_is_30_degree(); |
pro100kot14 | 6:db4538895ae7 | 47 | }; |
pro100kot14 | 6:db4538895ae7 | 48 | |
pro100kot14 | 0:1e03d2cd238f | 49 | #endif |