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

Dependents:   VL6180X VL6180X_Explorer VL6180X_Explorer VL6180X ... more

Files at this revision

API Documentation at this revision

Comitter:
highroads
Date:
Fri Jun 17 17:07:43 2016 +0000
Parent:
4:ebaf8038c8ed
Child:
6:99fb447bba81
Commit message:
Change address working

Changed in this revision

VL6180x.cpp Show annotated file Show diff for this revision Revisions of this file
VL6180x.h Show annotated file Show diff for this revision Revisions of this file
--- 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.
--- a/VL6180x.h	Mon May 11 20:17:53 2015 +0000
+++ b/VL6180x.h	Fri Jun 17 17:07:43 2016 +0000
@@ -262,6 +262,11 @@
 */
   uint8_t getDistance();
 /**
+* Get Range distance in meters
+* @returns TOF distance in meters  
+*/
+  float getDistance_m();
+/**
 * Get ALS level in Lux
 * @param vl6180x_als_gain gain setting for sensor
 * @returns light level in Lux