Ultrasonic Range Finder Sensors Library. May be used for SRF05 and all others sensors of the same kind (50ms period, 10us pulse)
Dependents: FRC_2018 TestVMA 0hackton_08_06_18 lib_FRC_2019 ... more
Diff: VMA306.h
- Revision:
- 3:4d9c742b860b
- Parent:
- 1:4f394d75bc7f
- Child:
- 4:a2c81d32d058
--- a/VMA306.h Tue May 22 17:15:57 2018 +0000 +++ b/VMA306.h Thu May 31 17:27:14 2018 +0000 @@ -57,45 +57,60 @@ /** Constructor : Create a VMA306 object, connected to the specified pins * - * @param trigger : DigitalOut to the VMA306 trigger - * @param echo : InterruptIn to measure the return pulse + * @param trigger (PinName) : DigitalOut to trigger the VMA306 + * @param echo (PinName) : InterruptIn to measure the return pulse width */ - VMA306(PinName trigger, PinName echo); - - /** Start periodic Trigger - * - * @param period : float time in second between two trig pulses - * - * @note This function allows user to start each instance of Ultra Sonic range finder with a delay from the others (delay managment must be done by users). - * @note The first pulse will be send 1 period after. - */ - void startPeriodicTrigger (float period = 0.15); + VMA306(PinName trigG, PinName echoG, PinName trigB, PinName echoB, PinName trigD, PinName echoD); /** Gives indication of a new mesurement * * @return 1 if new data is ready, else 0 */ - int isDataReady (); + int isUSGReady (); + + /** A non-blocking function that will return the last measurement + * + * @returns floating point representation of distance in cm + */ + float readUSG(); + /** Gives indication of a new mesurement + * + * @return 1 if new data is ready, else 0 + */ + int isUSBReady (); /** A non-blocking function that will return the last measurement * * @returns floating point representation of distance in cm */ - float read(); + float readUSB(); + /** Gives indication of a new mesurement + * + * @return 1 if new data is ready, else 0 + */ + int isUSDReady (); + + /** A non-blocking function that will return the last measurement + * + * @returns floating point representation of distance in cm + */ + float readUSD(); - /** A short hand way of using the read function */ - operator float(); - private : - DigitalOut _trigger; - InterruptIn _echo; - Timer _timer; - Ticker _ticker; - void _rising (void); - void _falling (void); - void _startRange (void); - float _dist; - int _VMA306Flag; + DigitalOut _trig1, _trig2, _trig3; + InterruptIn _echo1, _echo2, _echo3; + Timer _timer; + Ticker _ticker; + void _rise1 (void); + void _fall1 (void); + void _rise2 (void); + void _fall2 (void); + void _rise3 (void); + void _fall3 (void); + void _startRanging (void); + float _dist1, _dist2, _dist3; + int _VMA306Flag1, _VMA306Flag2, _VMA306Flag3; + int _startValue1, _startValue2, _startValue3; }; #endif