ToF sensor code by Pololu translated from Arduino to mbed
Diff: VL53L1X.h
- Revision:
- 1:bc3ff1b884b3
- Parent:
- 0:76ea242a637f
- Child:
- 2:bb0cd79ef201
--- a/VL53L1X.h Mon Jul 30 18:45:53 2018 +0000 +++ b/VL53L1X.h Tue Jul 31 16:03:14 2018 +0000 @@ -1301,8 +1301,8 @@ // assumes interrupt is active low (GPIO_HV_MUX__CTRL bit 4 is 1) bool dataReady() { int isThereData = readReg(GPIO__TIO_HV_STATUS); - printf("%x\r\n", isThereData); - return (isThereData & 0x01) == 0; +// printf("%x\r\n", isThereData); + return (readReg(GPIO__TIO_HV_STATUS) & 0x01) == 0; } static const char * rangeStatusToString(RangeStatus status); @@ -1372,10 +1372,10 @@ DistanceMode distance_mode; // Record the current time to check an upcoming timeout against - void startTimeout() { timeout_start_ms = t.read()/10000; } + void startTimeout() { timeout_start_ms = t.read()*1000; } // Check if timeout is enabled (set to nonzero value) and has expired - bool checkTimeoutExpired() {return (io_timeout > 0) && ((uint16_t)(t.read()/10000 - timeout_start_ms) > io_timeout); } + bool checkTimeoutExpired() {return (io_timeout > 0) && ((uint16_t)(t.read()*1000 - timeout_start_ms) > io_timeout); } void setupManualCalibration(); void readResults();