![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Regenerating PPM signal based on distances from ultrasonic sensors, ESP8266 for connectin via wifi. Autonomous quadcopter behaviour, autonomou height holding. Flying direction based on front and back ultrasonic sensors.
Dependencies: ConfigFile HCSR04 PID PPM2 mbed-rtos mbed
SRFO2/srf02.h@2:d172c9963f87, 2017-10-26 (annotated)
- Committer:
- edy05
- Date:
- Thu Oct 26 15:54:47 2017 +0000
- Revision:
- 2:d172c9963f87
stable release with distanceRegulation thread
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edy05 | 2:d172c9963f87 | 1 | #ifndef SRF02_H |
edy05 | 2:d172c9963f87 | 2 | #define SRF02_H |
edy05 | 2:d172c9963f87 | 3 | |
edy05 | 2:d172c9963f87 | 4 | #include "mbed.h" |
edy05 | 2:d172c9963f87 | 5 | |
edy05 | 2:d172c9963f87 | 6 | |
edy05 | 2:d172c9963f87 | 7 | /** Library to control SRF02 ultrasonic sensor */ |
edy05 | 2:d172c9963f87 | 8 | class SRF02 |
edy05 | 2:d172c9963f87 | 9 | { |
edy05 | 2:d172c9963f87 | 10 | public: |
edy05 | 2:d172c9963f87 | 11 | /** Creates an instance of the class |
edy05 | 2:d172c9963f87 | 12 | * |
edy05 | 2:d172c9963f87 | 13 | * @param sda I2C sda Pin |
edy05 | 2:d172c9963f87 | 14 | * @param scl I2C scl Pin |
edy05 | 2:d172c9963f87 | 15 | */ |
edy05 | 2:d172c9963f87 | 16 | SRF02(PinName sda, PinName scl, int addr); |
edy05 | 2:d172c9963f87 | 17 | |
edy05 | 2:d172c9963f87 | 18 | /** Destroys instance */ |
edy05 | 2:d172c9963f87 | 19 | ~SRF02(); |
edy05 | 2:d172c9963f87 | 20 | |
edy05 | 2:d172c9963f87 | 21 | /** Read the range data in centimeters */ |
edy05 | 2:d172c9963f87 | 22 | int readcm(); |
edy05 | 2:d172c9963f87 | 23 | |
edy05 | 2:d172c9963f87 | 24 | /** Read the range data in inches */ |
edy05 | 2:d172c9963f87 | 25 | int readinch(); |
edy05 | 2:d172c9963f87 | 26 | |
edy05 | 2:d172c9963f87 | 27 | /** Change the adress of the device. This is very usefull when there are more sensors. |
edy05 | 2:d172c9963f87 | 28 | * This function must be executed with only one sensor conected. |
edy05 | 2:d172c9963f87 | 29 | */ |
edy05 | 2:d172c9963f87 | 30 | void change_addr(char new_addr); |
edy05 | 2:d172c9963f87 | 31 | |
edy05 | 2:d172c9963f87 | 32 | private: |
edy05 | 2:d172c9963f87 | 33 | /** wait for ranging to complete |
edy05 | 2:d172c9963f87 | 34 | * This function is for internal use |
edy05 | 2:d172c9963f87 | 35 | */ |
edy05 | 2:d172c9963f87 | 36 | void wait_ranging(void); |
edy05 | 2:d172c9963f87 | 37 | I2C m_i2c; |
edy05 | 2:d172c9963f87 | 38 | int m_addr; |
edy05 | 2:d172c9963f87 | 39 | |
edy05 | 2:d172c9963f87 | 40 | }; |
edy05 | 2:d172c9963f87 | 41 | |
edy05 | 2:d172c9963f87 | 42 | #endif |