Kenji Arai / VL53L0X_simple

Dependents:   Check_VL53L0X_simple_with_three_ToF Check_VL53L0X_simple_ToF_Sensor Check_VL53L0X_simple_with_three_ToF Check_VL53L0X_simple_ToF_Sensor ... more

Fork of VL53L0X by ST

Revision:
7:174594acca0d
Parent:
6:083fbed585c5
Child:
8:ac14de4512e8
--- a/VL53L0X.h	Sun Feb 04 02:39:20 2018 +0000
+++ b/VL53L0X.h	Mon Feb 05 22:30:58 2018 +0000
@@ -29,7 +29,7 @@
 #ifndef __VL53L0X_CLASS_H
 #define __VL53L0X_CLASS_H
 
-//------- Feburary 4th, 2018 by JH1PJL / K.Arai --------------------------------
+//------- Feburary 6th, 2018 by JH1PJL / K.Arai --------------------------------
 //ORIGINAL=1 does NOT mean anything but just keep original source code as it is!
 //You can NOT compile with ORIGINAL=1 !!
 #define		ORIGINAL		0	// Just keep = 0
@@ -134,6 +134,7 @@
  *     int status = VL53L0X_ERROR_NONE;
  *     uint32_t data;
  *
+ *     status = sensor.init_sensor(0x33);   // set new addres(not equal others)
  *     status = sensor.set_mode(range_long_distance_33ms_200cm);
  *     //status = sensor.set_mode(range_hi_accurate_200ms_120cm);
  *     //status = sensor.set_mode(range_hi_speed_20ms_120cm);
@@ -158,6 +159,7 @@
 public:
     /** Constructor
      * @param[in] &i2c device I2C to be used for communication
+     * @param[in] pin Mbed DigitalInOut PinName to be used for XSHUT
      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName
      *             to be used as component GPIO_1 INT
      */
@@ -170,28 +172,26 @@
             _gpio1Int = NULL;
         }
 		preparation();
-        init_sensor(VL53L0X_DEFAULT_ADDRESS);
+        //init_sensor(VL53L0X_DEFAULT_ADDRESS);
     }
 
     /** Constructor 2 (another simple way)
      * @param[in] Pin for I2C SDA & SDL
-     * @param[in] pin Mbed DigitalOut PinName to be used for XSHUT
+     * @param[in] pin Mbed DigitalInOut PinName to be used for XSHUT
      */
     VL53L0X(PinName p_sda, PinName p_scl, PinName xshut)
         : _i2c_p(new I2C(p_sda, p_scl)), _i2c(*_i2c_p), _gpio0(xshut) {
         _gpio1Int = NULL;
 		preparation();
-        init_sensor(VL53L0X_DEFAULT_ADDRESS);
     }
 
     /** Constructor 3 (another simple way)
      * @param[in] &i2c device I2C to be used for communication
-     * @param[in] pin Mbed DigitalOut PinName to be used for XSHUT
+     * @param[in] pin Mbed DigitalInOut PinName to be used for XSHUT
      */
     VL53L0X(I2C& p_i2c, PinName xshut) : _i2c(p_i2c), _gpio0(xshut) {
         _gpio1Int = NULL;
 		preparation();
-        init_sensor(VL53L0X_DEFAULT_ADDRESS);
     }
 
     /** Destructor
@@ -220,8 +220,8 @@
         _my_device.comms_type = 1; // VL53L0X_COMMS_I2C
         _my_device.comms_speed_khz = 400;
         _device = &_my_device;
-		_gpio0 = 0;
-		_gpio0.output();
+        _range_mode = range_long_distance_33ms_200cm;
+        VL53L0X_off();
     }
 #endif
 
@@ -274,11 +274,12 @@
 
     /**
      * @brief       Initialize the sensor with default values
+     * @param[in]   new I2C address
      * @return      "0" on success
      */
     int init_sensor(uint8_t new_addr);
 
-
+#if !ORIGINAL
     /**
      * @brief       Start the measure by single shot operating mode
      * @param[in]   operating mode
@@ -289,7 +290,6 @@
         return start_measurement(range_single_shot_polling, NULL);
     }
 
-#if !ORIGINAL
     /**
      * @brief Get ranging result and only that
      *
@@ -412,5 +412,4 @@
     VL53L0X_DEV _device;
 };
 
-
 #endif /* _VL53L0X_CLASS_H_ */