拓郎 松坂
/
LPC1768_Multi_VL53L0X
offline test
Revision 1:5bb2524b423c, committed 2018-11-27
- Comitter:
- matu_cat0618
- Date:
- Tue Nov 27 02:34:21 2018 +0000
- Parent:
- 0:c543582b78b1
- Commit message:
- offline test;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 25 06:37:33 2018 +0000 +++ b/main.cpp Tue Nov 27 02:34:21 2018 +0000 @@ -3,12 +3,13 @@ #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 +#define range1_XSHUT p8 //D7 +#define range2_XSHUT p9 //D8 +#define VL53L0_I2C_SDA p28 //D14 +#define VL53L0_I2C_SCL p27 //D15 -Serial pc(SERIAL_TX, SERIAL_RX); +Serial pc(USBTX, USBRX); +Timer t; static DevI2C devI2c(VL53L0_I2C_SDA,VL53L0_I2C_SCL); int main() @@ -27,21 +28,29 @@ uint32_t distance2; int status1; int status2; + uint32_t tm_all_work; + while(1){ + t.reset(); + t.start(); status1 = range1.get_distance(&distance1); if (status1 == VL53L0X_ERROR_NONE) { - printf("Range1 [mm]: %6ld\r\n", distance1); + printf("Range1 [mm]: %6ld ", distance1); } else { - printf("Range1 [mm]: --\r\n"); + printf("Range1 [mm]: -- "); } status2 = range2.get_distance(&distance2); if (status2 == VL53L0X_ERROR_NONE) { - printf("Range2 [mm]: %6ld\r\n", distance2); + printf("Range2 [mm]: %6ld\r\n", distance2); } else { - printf("Range2 [mm]: --\r\n"); + printf("Range2 [mm]: --\r\n"); } - wait(0.5); + tm_all_work = t.read_ms(); + if (tm_all_work < 99){ + wait_ms(100 - tm_all_work); + } + pc.printf(" %d \r\n", tm_all_work); } }