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
Diff: PMW3901/PMW3901.h
- Revision:
- 7:56608cce81ee
- Parent:
- 6:c7bc001826ba
- Child:
- 12:2bbe233d25fb
diff -r c7bc001826ba -r 56608cce81ee PMW3901/PMW3901.h --- a/PMW3901/PMW3901.h Tue May 08 13:35:42 2018 +0000 +++ b/PMW3901/PMW3901.h Mon May 14 20:18:02 2018 +0000 @@ -15,31 +15,27 @@ /** PMW3901 (optical flow sensor) class * - * Example code (print optical flow data on serial port every 1 second): + * Example code (print optical flow data on serial port every 0.2 second): * @code * #include "mbed.h" * #include "USBSerial.h" * #include "PMW3901.h" * - * // Declare serial object * USBSerial pc; - * // Declare sensor object with correpondent SPI pins (miso, mosi, sclk, csel) * PMW3901 flow(PA_7,PA_6,PA_5,PB_4); * - * // Main program * int main() - * { - * // Initialize sensor - * flow.init(); - * // Infinite loop + * { + * if(!flow.init()) + * { + * pc.printf("Failed to detect and initialize optical flow on I2C bus!"); + * while(1); + * } * while(1); * { - * // Read data from sensor * flow.read(); - * // Print data from sensor - * pc.printf("Optical flow []: %6.2f %6.2f \n\n", flow.x, flow.y); - * // Wait 0.5 seconds - * wait(0.5); + * pc.printf("Optical flow [px]: %6.2f %6.2f \n\n", flow.x, flow.y); + * wait(0.2); * } * } * @endcode