Simple VL6180x demo for VL6180x Explorer shield with Nucleo F401 adapted from SparkFun example.

Dependents:   VL6180X VL6180X_Explorer VL6180X_Explorer VL6180X ... more

Revision:
5:fa7d17a114d2
Parent:
3:4a20f2102acf
Child:
6:99fb447bba81
--- a/VL6180x.cpp	Mon May 11 20:17:53 2015 +0000
+++ b/VL6180x.cpp	Fri Jun 17 17:07:43 2016 +0000
@@ -127,7 +127,7 @@
   if( new_address > 127) return old_address;
    
    VL6180x_setRegister(VL6180X_I2C_SLAVE_DEVICE_ADDRESS, new_address);
-   
+   m_addr=new_address<<1;
    return VL6180x_getRegister(VL6180X_I2C_SLAVE_DEVICE_ADDRESS); 
 }
   
@@ -142,6 +142,15 @@
   return distance;
 }
 
+float VL6180x::getDistance_m() {
+  float distance;
+  VL6180x_setRegister(VL6180X_SYSRANGE_START, 0x01); //Start Single shot mode
+  wait_ms(10);
+  distance = 0.001*(float)VL6180x_getRegister(VL6180X_RESULT_RANGE_VAL);
+  VL6180x_setRegister(VL6180X_SYSTEM_INTERRUPT_CLEAR, 0x07);
+  return distance;
+}
+
 float VL6180x::getAmbientLight(vl6180x_als_gain VL6180X_ALS_GAIN)
 {
   //First load in Gain we are using, do it everytime incase someone changes it on us.