Files at this revision

API Documentation at this revision

Comitter:
JohnnyK
Date:
Mon May 31 07:02:00 2021 +0000
Parent:
11:e91c151d1798
Commit message:
Update to MbedOS6+

Changed in this revision

DHT11.cpp Show annotated file Show diff for this revision Revisions of this file
DHT11.h Show annotated file Show diff for this revision Revisions of this file
diff -r e91c151d1798 -r af1eadec17e5 DHT11.cpp
--- a/DHT11.cpp	Thu Sep 25 14:13:10 2014 +0000
+++ b/DHT11.cpp	Mon May 31 07:02:00 2021 +0000
@@ -21,8 +21,8 @@
 // Constructor
 DHT11::DHT11(PinName pin) : io(pin, PIN_INPUT, OpenDrain, 1), io_irq(pin)
 {
-    io_irq.rise(this, &DHT11::pos_edge);
-    io_irq.fall(this, &DHT11::neg_edge);
+    io_irq.rise(callback(this, &DHT11::pos_edge));
+    io_irq.fall(callback(this, &DHT11::neg_edge));
     io_irq.disable_irq();
     t.start();
     first_time = true;
@@ -39,7 +39,7 @@
 int DHT11::readData(void)
 {
     // Checking the measurement frequency
-    if (t.read_ms() < 2000 && first_time == false) {
+    if (chrono::duration_cast<chrono::milliseconds>(t.elapsed_time()).count() < 2000 && first_time == false) {
         t.reset();
         return READ_TOO_OFTEN;
     }
@@ -58,7 +58,7 @@
     io.output();
     io = 0;
     do {
-    } while (t.read_ms() < 20 + t_tol_start);
+    } while (chrono::duration_cast<chrono::milliseconds>(t.elapsed_time()).count() < 20 + t_tol_start);
     io.input();
     io = 1;
     
@@ -66,7 +66,7 @@
     // Waiting for the start of the response signal
     t.reset();
     do {
-        if (t.read_us() > 100) {
+        if (t.elapsed_time().count() > 100) {
             t.reset();
             return NOT_PRESENT;
         }
@@ -75,7 +75,7 @@
     // Wainting for the start of the ready signal
     t.reset();
     do {
-        if (t.read_us() > 100) {
+        if (t.elapsed_time().count() > 100) {
             t.reset();
             return NOT_READY;
         }
@@ -84,7 +84,7 @@
     // Wainting for the end of the ready signal
     t.reset();
     do {
-        if (t.read_us() > 100) {
+        if (t.elapsed_time().count() > 100) {
             t.reset();
             return WATCHDOG_ERR;
         }
@@ -161,7 +161,7 @@
     io_irq.disable_irq();
 
     // Reading the positive pulse width
-    t_pulse_us = t.read_us();
+    t_pulse_us = t.elapsed_time().count();
 
     // Detecting 0 if the pulse width ranges around 25 us
     if (25 - t_tol_pulse <= t_pulse_us && t_pulse_us <= 30 + t_tol_pulse) {
diff -r e91c151d1798 -r af1eadec17e5 DHT11.h
--- a/DHT11.h	Thu Sep 25 14:13:10 2014 +0000
+++ b/DHT11.h	Mon May 31 07:02:00 2021 +0000
@@ -25,7 +25,7 @@
  * #include "mbed.h"
  * #include "DHT11.h"
  *
- * DHT11 d;
+ * DHT11 d(D8); // Here fill your PIN mask/name
  *
  * main()
  * {