Library containing Crazyflie 2.0 sensors drivers: - LPS25H (barometer) - MPU9250 (IMU) - PMW3901 (optical flow) - VL53L0X (range)
Dependents: Drones-Controlador controladoatitude_cteste Drone_Controlador_Atitude optical_test
VL53L0X/VL53L0X.h@11:b3a7164c4e12, 2018-09-24 (annotated)
- Committer:
- fbob
- Date:
- Mon Sep 24 17:25:20 2018 +0000
- Revision:
- 11:b3a7164c4e12
- Child:
- 12:2bbe233d25fb
Started including VL53L0X (range) sensor class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fbob | 11:b3a7164c4e12 | 1 | #ifndef VL53L0X_h |
fbob | 11:b3a7164c4e12 | 2 | #define VL53L0X_h |
fbob | 11:b3a7164c4e12 | 3 | |
fbob | 11:b3a7164c4e12 | 4 | #include "mbed.h" |
fbob | 11:b3a7164c4e12 | 5 | |
fbob | 11:b3a7164c4e12 | 6 | /** VL53L0X (lidar sensor) class |
fbob | 11:b3a7164c4e12 | 7 | * |
fbob | 11:b3a7164c4e12 | 8 | * Example code (print pressure and altitude data on serial port every 0.2 second): |
fbob | 11:b3a7164c4e12 | 9 | * @code |
fbob | 11:b3a7164c4e12 | 10 | * #include "mbed.h" |
fbob | 11:b3a7164c4e12 | 11 | * #include "USBSerial.h" |
fbob | 11:b3a7164c4e12 | 12 | * #include "VL53L0X.h" |
fbob | 11:b3a7164c4e12 | 13 | * |
fbob | 11:b3a7164c4e12 | 14 | * USBSerial pc; |
fbob | 11:b3a7164c4e12 | 15 | * VL53L0X lidar(PC_9,PA_8); |
fbob | 11:b3a7164c4e12 | 16 | * |
fbob | 11:b3a7164c4e12 | 17 | * int main() |
fbob | 11:b3a7164c4e12 | 18 | * { |
fbob | 11:b3a7164c4e12 | 19 | * if(!lidar.init()) |
fbob | 11:b3a7164c4e12 | 20 | * { |
fbob | 11:b3a7164c4e12 | 21 | * pc.printf("Failed to detect and initialize lidar on I2C bus!"); |
fbob | 11:b3a7164c4e12 | 22 | * while(1); |
fbob | 11:b3a7164c4e12 | 23 | * } |
fbob | 11:b3a7164c4e12 | 24 | * while(1) |
fbob | 11:b3a7164c4e12 | 25 | * { |
fbob | 11:b3a7164c4e12 | 26 | * lidar.read(); |
fbob | 11:b3a7164c4e12 | 27 | * pc.printf("Distance [m]: %6.2f \n\n", lidar.z); |
fbob | 11:b3a7164c4e12 | 28 | * wait(0.2); |
fbob | 11:b3a7164c4e12 | 29 | * } |
fbob | 11:b3a7164c4e12 | 30 | * } |
fbob | 11:b3a7164c4e12 | 31 | * @endcode |
fbob | 11:b3a7164c4e12 | 32 | * (Need to target to NUCLEO-F401RE board platform) |
fbob | 11:b3a7164c4e12 | 33 | */ |
fbob | 11:b3a7164c4e12 | 34 | class VL53L0X |
fbob | 11:b3a7164c4e12 | 35 | { |
fbob | 11:b3a7164c4e12 | 36 | public: |
fbob | 11:b3a7164c4e12 | 37 | /** Class constructor */ |
fbob | 11:b3a7164c4e12 | 38 | VL53L0X(PinName sda, PinName scl); |
fbob | 11:b3a7164c4e12 | 39 | private: |
fbob | 11:b3a7164c4e12 | 40 | /** I2C bus */ |
fbob | 11:b3a7164c4e12 | 41 | I2C i2c; |
fbob | 11:b3a7164c4e12 | 42 | }; |
fbob | 11:b3a7164c4e12 | 43 | |
fbob | 11:b3a7164c4e12 | 44 | #endif |