Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: VL53L1X.cpp
- Revision:
- 2:f570ff03fb81
- Parent:
- 1:e54ded4af43a
- Child:
- 3:7777bbcf11f6
--- a/VL53L1X.cpp Wed Aug 08 21:44:33 2018 +0000
+++ b/VL53L1X.cpp Thu Aug 09 18:12:38 2018 +0000
@@ -18,6 +18,7 @@
//Set I2C fast and bring reset line high
_i2c.frequency(400000);
address = AddressDefault << 1;
+ turnOff();
}
/*VL53L1X::VL53L1X()
@@ -678,7 +679,7 @@
// Basically, this appears to scale the result by 2011/2048, or about 98%
// (with the 1024 added for proper rounding).
ranging_data.range_mm = ((uint32_t)range * 2011 + 0x0400) / 0x0800;
- wait(.02);
+ wait(.01);
// VL53L1_copy_sys_and_core_results_to_range_results() end
// set range_status in ranging_data based on value of RESULT__RANGE_STATUS register
@@ -832,13 +833,14 @@
wait_ms(100);
setTimeout(500);
if (!init()) {
+ didInitialize = false;
return false;
}
// setDistanceMode(VL53L1X::Short);//Short Medium Long
setAddress(addr);//change I2C address for next sensor
setMeasurementTimingBudget(timing_budget);//min 20ms for Short, 33ms for Medium and Long
wait_ms(100);
-
+ didInitialize = true;
return true;
}
//*************************************
@@ -858,14 +860,21 @@
wait(.05);
_shutDown = false;
wait(.05);
-/* turnOff();
- wait_ms(10);
- turnOn();
- wait_ms(10);
- turnOff();*/
+
}
void VL53L1X::turnOn(void)
{
//turn pin HIGH
_shutDown = true;
+}
+int VL53L1X::readFromOneSensor(void)
+{
+ startContinuous(50);
+ int variable;
+ if (didInitialize) //create bool
+ variable = read();
+ else
+ variable = -1;
+ stopContinuous();
+ return variable;
}
\ No newline at end of file