Library for interfacing with the Parallax Ping))) sensor.
Diff: ping.h
- Revision:
- 5:cbe07c09c64c
- Parent:
- 4:ddffe9339bb1
--- a/ping.h Mon Jul 28 00:17:57 2014 +0000 +++ b/ping.h Tue Jul 29 02:34:02 2014 +0000 @@ -4,9 +4,9 @@ #include "mbed.h" #include "FPointer.h" -#define MEASUREMENT_DELAY_US 200 -#define SPEED_OF_SOUND_CM_PER_US 0.034029 -#define SPEED_OF_SOUND_IN_PER_US 0.0133972441 +#define DEFAULT_MEASUREMENT_DELAY_US 5000 +#define SPEED_OF_SOUND_CM_PER_US 0.034029 +#define SPEED_OF_SOUND_IN_PER_US 0.0133972441 /** * Class for interfacing with the Parallax Ping))) Ultrasonic Sensor @@ -58,6 +58,13 @@ uint32_t getRawReading() { return mRawReading; } /** + * Sets the delay between continuous readings. + * + * @param delay_us Delay between readings in microseconds. + */ + void setContinuousReadingDelay(uint32_t delay_us) { mDelayBetweenReadings = delay_us; } + + /** * Gets the distance sound can travel, in centimeters, for a given time in uS. * * @param time_us Time traveled in microseconds. @@ -96,6 +103,7 @@ bool mBusy; bool mValid; bool mContinuous; + uint32_t mDelayBetweenReadings; Timer mTimer; Ticker mMeasureDelayTicker;