SOFT564Z Group 3 / Mbed 2 deprecated SOFT564Z_Group_3v46666

Dependencies:   mbed Servo ros_lib_kinetic

Revision:
4:36a04230554d
Parent:
2:6197e1cf2cd1
Child:
10:276cc357015c
--- a/TOFs/TOF.cpp	Thu Oct 24 14:37:51 2019 +0000
+++ b/TOFs/TOF.cpp	Thu Nov 07 15:31:52 2019 +0000
@@ -9,6 +9,28 @@
 I2C i2c(I2C_SDA, I2C_SCL); // Set up I²C on the STM board
 
 /*--------------------------------------------------------------------------------
+Function name: ServiceTOF
+Input Parameters: address - address of target TOF sensor
+Output Parameters: range - distance measurement in mm
+Description: performs measurement routine on a given sensor
+----------------------------------------------------------------------------------*/
+uint8_t serviceTOF(cAdafruit_VL6180X VL6180X, uint8_t address){
+        
+        uint8_t range = 0;
+        
+        // poll the VL6180X till new sample ready
+        VL6180X.Poll_Range(address);
+
+        // read range result
+        range = VL6180X.Read_Range(address);
+        
+        // clear the interrupt on VL6180X
+        VL6180X.Clear_Interrupts(address);
+        
+        return range;
+}
+
+/*--------------------------------------------------------------------------------
 Function name: cAdafruit_VL6180X
 Input Parameters: N/A
 Output Parameters: N/A
@@ -35,23 +57,23 @@
     //Enable and configure sensor 2
     sensor2 = 1;
     wait(0.01);
-    Setup(DEFAULT_ADDR, ADDR2); //Change address
-    Init(ADDR2);        //Perform standard initialisation routine
-    Start_Range(ADDR2); //Begin sampling in continuous mode
+    Setup(DEFAULT_ADDR, ADDR4); //Change address
+    Init(ADDR4);        //Perform standard initialisation routine
+    Start_Range(ADDR4); //Begin sampling in continuous mode
     
     //Enable and configure sensor 3
     sensor3 = 1;
     wait(0.01);
-    Setup(DEFAULT_ADDR, ADDR3); //Change address
-    Init(ADDR3);        //Perform standard initialisation routine
-    Start_Range(ADDR3); //Begin sampling in continuous mode
+    Setup(DEFAULT_ADDR, ADDR6); //Change address
+    Init(ADDR6);        //Perform standard initialisation routine
+    Start_Range(ADDR6); //Begin sampling in continuous mode
     
     //Enable and configure sensor 4
     sensor4 = 1;
     wait(0.01);
-    Setup(DEFAULT_ADDR, ADDR4); //Change address
-    Init(ADDR4);        //Perform standard initialisation routine
-    Start_Range(ADDR4); //Begin sampling in continuous mode
+    Setup(DEFAULT_ADDR, ADDR7); //Change address
+    Init(ADDR7);        //Perform standard initialisation routine
+    Start_Range(ADDR7); //Begin sampling in continuous mode
     
     printf("INITIALISED\n\r");
 }