Fork of DHT component - https://os.mbed.com/teams/components/code/DHT/ and update for MbedOS6+
Diff: DHT.h
- Revision:
- 4:655ecec987ca
- Parent:
- 2:df22ddf10d75
--- a/DHT.h Sat May 28 11:11:34 2016 +0000 +++ b/DHT.h Mon May 31 07:47:49 2021 +0000 @@ -29,14 +29,47 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +/* + * Example: + * @code + * #include "mbed.h" + * #include "DHT.h" + * + * DHT sensor(D4, DHT11); + * + * int main() + * { + * int error = 0; + * float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; + * + * while(1) { + * thread_sleep_for(2000); + * error = sensor.readData(); + * if (0 == error) { + * c = sensor.ReadTemperature(CELCIUS); + * f = sensor.ReadTemperature(FARENHEIT); + * k = sensor.ReadTemperature(KELVIN); + * h = sensor.ReadHumidity(); + * dp = sensor.CalcdewPoint(c, h); + * dpf = sensor.CalcdewPointFast(c, h); + * printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f); + * printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf); + * } else { + * printf("Error: %d\n", error); + * } + * } + * } + * @endcode + */ #ifndef MBED_DHT_H #define MBED_DHT_H #include "mbed.h" -typedef enum eType eType; -enum eType { + +typedef enum e_Type { DHT11 = 11, SEN11301P = 11, RHT01 = 11, @@ -45,10 +78,9 @@ SEN51035P = 22, RHT02 = 22, RHT03 = 22 -}; +}eType; -typedef enum eError eError; -enum eError { +typedef enum e_Error { ERROR_NONE = 0, BUS_BUSY, ERROR_NOT_PRESENT, @@ -57,14 +89,13 @@ ERROR_DATA_TIMEOUT, ERROR_CHECKSUM, ERROR_NO_PATIENCE -}; +}eError; -typedef enum eScale eScale; -enum eScale { +typedef enum e_Scale { CELCIUS = 0, FARENHEIT, KELVIN -}; +}eScale; class DHT