altb_pmic / Mbed 2 deprecated Test_optical_flow_PX4

Dependencies:   mbed

Revision:
12:19fe4f6a8b6b
Parent:
11:d367224f2194
Child:
13:89b65bfe6dda
--- a/PX4Flow.cpp	Fri Sep 20 13:01:26 2019 +0000
+++ b/PX4Flow.cpp	Sun Apr 05 08:47:25 2020 +0000
@@ -1,6 +1,6 @@
 #include "PX4Flow.h"
 
-PX4Flow::PX4Flow( I2C& i2c): i2c(i2c)
+PX4Flow::PX4Flow( I2C& i2c): i2c(i2c), dout1(PA_10)
 {
     i2c_commands[0] = FRAME;
     i2c_commands[1] = INTEGRAL_FRAME;
@@ -38,8 +38,12 @@
 bool PX4Flow::update_integral()
 {  
     //send 0x16 to PX4FLOW module and receive back 26 Bytes data
-    if( i2c.write(PX4FLOW_ADDRESS, &i2c_commands[1], 1 ) == 0 ) {
-        if(i2c.read(PX4FLOW_ADDRESS, bufferI, 26 ) == 0 ) {
+    int b1 = i2c.write(PX4FLOW_ADDRESS, &i2c_commands[1], 1 );
+    if( b1 == 0 ) {
+//        dout1.write(1);
+        b1 = i2c.read(PX4FLOW_ADDRESS, bufferI, 26 );
+//        dout1.write(0);
+        if(b1 == 0 ) {
             // assign the data
             iframe.frame_count_since_last_readout   = (uint16_t)(read16(bufferI, FRAME_COUNT_SINCE_LAST_READOUT));
             iframe.pixel_flow_x_integral            = (int16_t) (read16(bufferI, PIXEL_FLOW_X_INTEGRAL));