File tree Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change 11name =SparkFun VL53L1X 4m Laser Distance Sensor
2- version =1.2.8
2+ version =1.2.9
33author =SparkFun Electronics <techsupport@sparkfun.com>
44maintainer =SparkFun Electronics <sparkfun.com>
55sentence =Library for the SparkFun Qwiic 4m Distance Sensor - VL53L1X
Original file line number Diff line number Diff line change @@ -166,28 +166,23 @@ VL53L1X_ERROR VL53L1X::VL53L1X_SetI2CAddress(uint8_t new_address)
166166VL53L1X_ERROR VL53L1X::VL53L1X_SensorInit ()
167167{
168168 VL53L1X_ERROR status = 0 ;
169- uint8_t Addr = 0x00 , tmp = 0 , timeout = 0 ;
169+ uint8_t Addr = 0x00 , dataReady = 0 , timeout = 0 ;
170170
171171 for (Addr = 0x2D ; Addr <= 0x87 ; Addr++)
172172 {
173173 status = VL53L1_WrByte (Device, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D ]);
174174 }
175175 status = VL53L1X_StartRanging ();
176176
177- delay ( 103 ); // Wait the default intermeasurement period of 103ms before checking for dataready
178-
179- while (tmp == 0 )
177+ // We need to wait at least the default intermeasurement period of 103ms before dataready will occur
178+ // But if a unit has already been powered and polling, it may happen much faster
179+ while (dataReady == 0 )
180180 {
181- status = VL53L1X_CheckForDataReady (&tmp);
182- timeout++;
183- if (timeout > 50 )
184- {
185- status = VL53L1_ERROR_TIME_OUT;
186- return status;
187- }
181+ status = VL53L1X_CheckForDataReady (&dataReady);
182+ if (timeout++ > 150 )
183+ return VL53L1_ERROR_TIME_OUT;
188184 delay (1 );
189185 }
190- tmp = 0 ;
191186 status = VL53L1X_ClearInterrupt ();
192187 status = VL53L1X_StopRanging ();
193188 status = VL53L1_WrByte (Device, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09 ); /* two bounds VHV */
You can’t perform that action at this time.
0 commit comments