Files at this revision

API Documentation at this revision

Comitter:
thinesh
Date:
Tue Nov 29 07:34:05 2022 +0000
Parent:
7:71da0dbf4400
Commit message:
Updated to Mbed OS 6

Changed in this revision

hcsr04.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/hcsr04.cpp	Sat Mar 30 18:55:03 2013 +0000
+++ b/hcsr04.cpp	Tue Nov 29 07:34:05 2022 +0000
@@ -26,8 +26,8 @@
 {
     pulsetime.stop();
     pulsetime.reset();
-    echo.rise(this,&HCSR04::isr_rise);
-    echo.fall(this,&HCSR04::isr_fall);
+    echo.rise(callback(this,&HCSR04::isr_rise)); //echo.rise(this,&HCSR04::isr_fall)
+    echo.fall(callback(this,&HCSR04::isr_fall)); //echo.fall(this,&HCSR04::isr_fall)
     trigger=0;
 }
 
@@ -49,7 +49,7 @@
 void HCSR04::isr_fall(void)
 {
     pulsetime.stop();
-    pulsedur = pulsetime.read_us();
+    pulsedur = (pulsetime.elapsed_time()).count(); //pulsetime.read_us();
     distance= (pulsedur*343)/20000;
     pulsetime.reset();
 }