File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -251,15 +251,18 @@ uint8_t VL53L1X::getDistanceMode()
251
251
}
252
252
253
253
// Set a custom zone from the array of sensors. Minimum of 4x4, maximum of 16x16.
254
+ // Custom zone must be centered
254
255
void VL53L1X::setUserRoi (UserRoi *roi)
255
256
{
256
257
uint8_t centerX = (roi->topLeftX + roi->bottomRightX + 1 ) / 2 ;
257
258
uint8_t centerY = (roi->topLeftY + roi->bottomRightY + 1 ) / 2 ;
258
259
uint8_t width = roi->bottomRightX - roi->topLeftX ;
259
260
uint8_t height = roi->topLeftY - roi->bottomRightY ;
260
261
261
- if (width < 3 || height < 3 ){
262
- return ;
262
+ // Check boundary conditions, if incorrect set to default values.
263
+ if (width < 3 || width > 15 || height < 3 || height > 15 ){
264
+ setCenter ((uint8_t )8 , (uint8_t )8 );
265
+ setZoneSize ((uint8_t )15 , (uint8_t )8 );
263
266
}
264
267
else {
265
268
setCenter (centerX, centerY);
You can’t perform that action at this time.
0 commit comments