Based on Robinson Lopez Monzon library: This library contains all the functions necesary to perform an application using the SRF02 sensor. Modified by Dury: replaced wait() functions that are not usefull for program performance. Esta librería contiene los métodos necesarios para poder configurar todos los parámetros del sensor SRF02.
Fork of SRF02 by
SRF02.h@1:d624771f0bd3, 2013-02-09 (annotated)
- Committer:
- dury
- Date:
- Sat Feb 09 22:26:47 2013 +0000
- Revision:
- 1:d624771f0bd3
- Parent:
- 0:559a18121e83
This library contains all the functions necesary to perform an application using the SRF02 sensor.; Modified: replaced wait() functions that are not usefull for program performance.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nydus | 0:559a18121e83 | 1 | #ifndef SRF02_H |
nydus | 0:559a18121e83 | 2 | #define SRF02_H |
nydus | 0:559a18121e83 | 3 | |
nydus | 0:559a18121e83 | 4 | #include "mbed.h" |
nydus | 0:559a18121e83 | 5 | |
nydus | 0:559a18121e83 | 6 | |
dury | 1:d624771f0bd3 | 7 | /** Library to control SRF02 ultrasonic sensor */ |
nydus | 0:559a18121e83 | 8 | class SRF02 |
nydus | 0:559a18121e83 | 9 | { |
dury | 1:d624771f0bd3 | 10 | public: |
dury | 1:d624771f0bd3 | 11 | /** Creates an instance of the class |
dury | 1:d624771f0bd3 | 12 | * |
dury | 1:d624771f0bd3 | 13 | * @param sda I2C sda Pin |
dury | 1:d624771f0bd3 | 14 | * @param scl I2C scl Pin |
dury | 1:d624771f0bd3 | 15 | */ |
dury | 1:d624771f0bd3 | 16 | SRF02(PinName sda, PinName scl, int addr); |
nydus | 0:559a18121e83 | 17 | |
dury | 1:d624771f0bd3 | 18 | /** Destroys instance */ |
dury | 1:d624771f0bd3 | 19 | ~SRF02(); |
nydus | 0:559a18121e83 | 20 | |
dury | 1:d624771f0bd3 | 21 | /** Read the range data in centimeters */ |
dury | 1:d624771f0bd3 | 22 | int readcm(); |
dury | 1:d624771f0bd3 | 23 | |
dury | 1:d624771f0bd3 | 24 | /** Read the range data in inches */ |
dury | 1:d624771f0bd3 | 25 | int readinch(); |
nydus | 0:559a18121e83 | 26 | |
dury | 1:d624771f0bd3 | 27 | /** Change the adress of the device. This is very usefull when there are more sensors. |
dury | 1:d624771f0bd3 | 28 | * This function must be executed with only one sensor conected. |
dury | 1:d624771f0bd3 | 29 | */ |
dury | 1:d624771f0bd3 | 30 | void change_addr(char new_addr); |
nydus | 0:559a18121e83 | 31 | |
dury | 1:d624771f0bd3 | 32 | private: |
dury | 1:d624771f0bd3 | 33 | /** wait for ranging to complete |
dury | 1:d624771f0bd3 | 34 | * This function is for internal use |
dury | 1:d624771f0bd3 | 35 | */ |
dury | 1:d624771f0bd3 | 36 | void wait_ranging(void); |
dury | 1:d624771f0bd3 | 37 | I2C m_i2c; |
dury | 1:d624771f0bd3 | 38 | int m_addr; |
nydus | 0:559a18121e83 | 39 | |
nydus | 0:559a18121e83 | 40 | }; |
nydus | 0:559a18121e83 | 41 | |
nydus | 0:559a18121e83 | 42 | #endif |