Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HCSR04 by
Revision 4:33938a97d904, committed 2013-03-30
- Comitter:
- prabhuvd
- Date:
- Sat Mar 30 18:46:01 2013 +0000
- Parent:
- 3:e6795cb9439c
- Child:
- 5:e70a24a88131
- Commit message:
- Updated comments
Changed in this revision
| hcsr04.cpp | Show annotated file Show diff for this revision Revisions of this file |
| hcsr04.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/hcsr04.cpp Sat Mar 30 18:43:21 2013 +0000
+++ b/hcsr04.cpp Sat Mar 30 18:46:01 2013 +0000
@@ -53,7 +53,7 @@
distance= (pulsedur*343)/20000;
pulsetime.reset();
}
-
+
void DistMeasure::rise (void (*fptr)(void))
{
echo.rise(fptr);
--- a/hcsr04.h Sat Mar 30 18:43:21 2013 +0000
+++ b/hcsr04.h Sat Mar 30 18:46:01 2013 +0000
@@ -41,15 +41,19 @@
/** Return the distance from obstacle in cm
* @param distance in cms and returns -1, in case of failure
*/
-
unsigned int get_dist_cm(void);
+ /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
+ * @param pulse duration in microseconds.
+ */
unsigned int get_pulse_us(void);
+ /** Generates the trigger pulse of 10us on the trigger PIN.
+ */
void start(void );
void isr_rise(void);
void isr_fall(void);
void fall (void (*fptr)(void));
void rise (void (*fptr)(void));
-
+
private:
@@ -58,7 +62,7 @@
DigitalOut trigger;
InterruptIn echo;
unsigned int pulsedur;
- unsigned int distance;
+ unsigned int distance;
};
#endif
\ No newline at end of file
