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()
251251}
252252
253253// Set a custom zone from the array of sensors. Minimum of 4x4, maximum of 16x16.
254+ // Custom zone must be centered
254255void VL53L1X::setUserRoi (UserRoi *roi)
255256{
256257 uint8_t centerX = (roi->topLeftX + roi->bottomRightX + 1 ) / 2 ;
257258 uint8_t centerY = (roi->topLeftY + roi->bottomRightY + 1 ) / 2 ;
258259 uint8_t width = roi->bottomRightX - roi->topLeftX ;
259260 uint8_t height = roi->topLeftY - roi->bottomRightY ;
260261
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 );
263266 }
264267 else {
265268 setCenter (centerX, centerY);
You can’t perform that action at this time.
0 commit comments