modified to work with MultiTech mDot on UDK2.0

Dependents:   HelloWorld_53L0A1 unh-hackathon-example unh-hackathon-example-raw

Fork of X_NUCLEO_53L0A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
johnAlexander
Date:
Fri Dec 02 10:44:40 2016 +0000
Parent:
2:58b5e9097aa3
Child:
5:c82a48da3c9e
Commit message:
UpDate GetDistance() to return an error upon invalid range.

Changed in this revision

Components/VL53L0X/vl53l0x_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/Components/VL53L0X/vl53l0x_class.h	Thu Dec 01 14:17:46 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Fri Dec 02 10:44:40 2016 +0000
@@ -721,7 +721,6 @@
  */		
     virtual int GetDistance(uint32_t *piData)
     {
-//       return VL6180x_RangeGetResult(Device, piData);
         int status=0;
         VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
 
@@ -729,8 +728,15 @@
         if (!status) {
             status=GetMeasurement(range_single_shot_polling, &pRangingMeasurementData);
         }
+        if (pRangingMeasurementData.RangeStatus == 0) {
+        // we have a valid range.
+            *piData = pRangingMeasurementData.RangeMilliMeter;
+        }
+        else {
+            *piData = 0;
+            status = VL53L0X_ERROR_RANGE_ERROR;
+        }
         StopMeasurement(range_single_shot_polling);
-        *piData = pRangingMeasurementData.RangeMilliMeter;
         return status;
     }