志鈴 謝 / Mbed 2 deprecated Multi_VL53L0X

Dependencies:   VL53L0X mbed

Files at this revision

API Documentation at this revision

Comitter:
jkjk010695
Date:
Thu Jan 25 06:37:33 2018 +0000
Commit message:
Use several VL53L0X sensors with a pair I2C pins

Changed in this revision

VL53L0X.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c543582b78b1 VL53L0X.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VL53L0X.lib	Thu Jan 25 06:37:33 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/teams/ST/code/VL53L0X/#d25c4fa216af
diff -r 000000000000 -r c543582b78b1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 25 06:37:33 2018 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "VL53L0X.h"
+
+#define range1_addr (0x56)
+#define range2_addr (0x60)
+#define range1_XSHUT   D7
+#define range2_XSHUT   D8
+#define VL53L0_I2C_SDA   D14 
+#define VL53L0_I2C_SCL   D15  
+ 
+Serial pc(SERIAL_TX, SERIAL_RX);
+static DevI2C devI2c(VL53L0_I2C_SDA,VL53L0_I2C_SCL); 
+ 
+int main()
+{   
+    /*Contruct the sensors*/ 
+    static DigitalOut shutdown1_pin(range1_XSHUT);
+    static VL53L0X range1(&devI2c, &shutdown1_pin, NC);
+    static DigitalOut shutdown2_pin(range2_XSHUT);
+    static VL53L0X range2(&devI2c, &shutdown2_pin, NC);
+    /*Initial all sensors*/   
+    range1.init_sensor(range1_addr);
+    range2.init_sensor(range2_addr);
+
+    /*Get datas*/
+    uint32_t distance1;
+    uint32_t distance2;
+    int status1;
+    int status2;
+    while(1){
+        status1 = range1.get_distance(&distance1);
+        if (status1 == VL53L0X_ERROR_NONE) {
+            printf("Range1 [mm]:            %6ld\r\n", distance1);
+        } else {
+            printf("Range1 [mm]:                --\r\n");
+        }
+
+        status2 = range2.get_distance(&distance2);
+        if (status2 == VL53L0X_ERROR_NONE) {
+            printf("Range2 [mm]:            %6ld\r\n", distance2);
+        } else {
+            printf("Range2 [mm]:                --\r\n");
+        }
+        wait(0.5);                 
+    }
+ 
+}
+ 
diff -r 000000000000 -r c543582b78b1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 25 06:37:33 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file