Library for use with VL53L1X, intended to represent the Proximity sensor expansion board with the same name.

Dependencies:   VL53L1X_mbed

Dependents:   HelloWorld_53L1A1 VL53L1A1_Simple_Ranging_With_One_Device VL53L1A1_Simple_Ranging_With_All_Devices VL53L1X_Ranging_With_Multiple_Devices_MbedOS ... more

Revision:
11:ceaa5a026412
Parent:
10:faf8d62ce6d1
Child:
12:f6e2bad00dc7
diff -r faf8d62ce6d1 -r ceaa5a026412 Components/VL53L0X/vl53l0x_class.h
--- a/Components/VL53L0X/vl53l0x_class.h	Wed Jun 07 14:58:36 2017 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Mon Jun 12 13:59:20 2017 +0000
@@ -61,7 +61,7 @@
 #define STATUS_FAIL            0x01
 
 
-#define VL53L0X_OsDelay(...) HAL_Delay(2)
+#define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
 
 #ifdef USE_EMPTY_STRING
 	#define  VL53L0X_STRING_DEVICE_INFO_NAME                             ""
@@ -303,7 +303,7 @@
      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] DevAddr device address, 0x29 by default  
      */
-    VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), gpio0(&pin)
+    VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), gpio0(&pin)
     {
        MyDevice.I2cDevAddr=DevAddr;		 
        MyDevice.comms_type=1; // VL53L0X_COMMS_I2C
@@ -320,7 +320,7 @@
      * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] device address, 0x29 by default  
      */		
-    VL53L0X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), expgpio0(&pin)
+    VL53L0X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), expgpio0(&pin)
     {
        MyDevice.I2cDevAddr=DevAddr;		 
        MyDevice.comms_type=1; // VL53L0X_COMMS_I2C
@@ -479,6 +479,7 @@
 //			return 1;
     }
 
+
 /**
  *
  * @brief One time device initialization
@@ -495,9 +496,16 @@
  * @param void
  * @return     0 on success,  @a #CALIBRATION_WARNING if failed
  */		
+ 	virtual int init(void *init)
+	{
+		return VL53L0X_DataInit(Device);
+	}
+	
+/** deprecated Init funtion from ComponentObject. for backward compatibility
+*/	
     virtual int Init(void * NewAddr)
     {
-       return VL53L0X_DataInit(Device);
+    	return init(NewAddr);
     }
 
 /**
@@ -687,7 +695,7 @@
  * @param pRange_mm  Pointer to range distance
  * @return           0 on success
  */		
-    virtual int GetDistance(uint32_t *piData)
+    virtual int get_distance(uint32_t *piData)
     {
         int status=0;
         VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
@@ -707,7 +715,11 @@
         StopMeasurement(range_single_shot_polling);
         return status;
     }
-		
+/* Deprecated funtion from RangeSensor class. For backward compatibility*/	
+	virtual int GetDistance(uint32_t *piData)
+	{
+		return get_distance(piData);
+	}	
 /**
  * @brief Configure ranging interrupt reported to application
  *
@@ -1339,9 +1351,13 @@
     		uint8_t *Revision,
     		VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
 
-    /* Read function of the ID device */
-//    virtual int ReadID();
+	/* deprecated Read function from Component class for backward compatibility*/
+	//   virtual int ReadID();
     virtual int ReadID(uint8_t *id);
+
+	/* Read function of the ID device */
+	//   virtual int read_id();    
+    virtual int read_id(uint8_t *id);
     
     VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev);
     VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev);